class DMZSyncServiceImpl extends RemoteServiceServlet implements
		DMZSyncService {

	@Override
	public void pullFromDMZ(Long standardizedPatientId)  throws DMZSyncException {
		String url = getHostAddress() + "/DataImportExport/exportSP?id="	+ standardizedPatientId;
		String data = getDMZData(url);
		
		data =preProcessData(data);
		JSONDeserializer deserializer = new JSONDeserializer()
				.use("anamnesisForm.createDate",
						new DateTransformer("yyyy-MM-dd'T'HH:mm:ss'Z'"))
				.use("birthday",
						new DateTransformer("yyyy-MM-dd"))
				.use("gender", new GenderTransformer())
				.use("maritalStatus", new MaritalStatusTransformer())
				.use("status",new SPStatusTransformer())
				.use("workPermission", new WorkPermissionTransformer())
				.use("anamnesisForm.anamnesischecksvalues.values.anamnesischeck.title.type", new AnamnesisChecksTypeTransformet())
				.use("anamnesisForm.scars.values.traitType", new TraitTypeTransformet())
				.use("anamnesisForm.anamnesischecksvalues.values.anamnesischeck.type", new AnamnesisChecksTypeTransformet());
		
		String unExpectedData=standardizedPatientId+"not found";
		StandardizedPatient newPatient = null;
		if(!data.equals(unExpectedData)){
			try{
				newPatient = (StandardizedPatient) (deserializer
						.use(null, StandardizedPatient.class).deserialize(data));
			}catch(flexjson.JSONException e){
				Log.error("Error deserialize json data: "+e.getMessage());
				throw new DMZSyncException(DMZSyncExceptionType.SYNC_PATIENT_EXCEPTION,"Error json data.");
			}
		}else{
			throw new DMZSyncException(DMZSyncExceptionType.PATIENT_EXIST_EXCEPTION,"");
		}

		
		
		StandardizedPatient patient = StandardizedPatient.findStandardizedPatient(standardizedPatientId);
	
		if( patient != null){
			if(newPatient!=null){
				updatePatient(patient,newPatient);
			}
		}else{
//			throw new DMZSyncException(DMZSyncExceptionType.PATIENT_EXIST_EXCEPTION,"");
//			savePatient(newPatient);
		}

	}

}