public static ch.elexis.data.Patient getElexisPatient(Patient ehcPatient) { // try to look up via ids List<Identificator> ids = ehcPatient.getIds(); for (Identificator identificator : ids) { String idRoot = identificator.getRoot(); if (idRoot.equals(CodeSystems.SwissSSNDeprecated.getCodeSystemId()) || idRoot.equals(CodeSystems.SwissSSN.getCodeSystemId())) { IPersistentObject ret = Xid.findObject(Xid.DOMAIN_AHV, identificator.getExtension()); if (ret instanceof Kontakt) { if (((Kontakt) ret).istPatient()) { return ch.elexis.data.Patient.load(ret.getId()); } } System.out.println("foud ret " + ret); if (ret instanceof ch.elexis.data.Patient) { return (ch.elexis.data.Patient) ret; } } } Query<ch.elexis.data.Patient> qpa = new Query<ch.elexis.data.Patient>(ch.elexis.data.Patient.class); // initialize data Name ehcName = ehcPatient.getName(); Date ehcBirthdate = ehcPatient.getBirthday(); String gender = ehcPatient.getAdministrativeGenderCode() == AdministrativeGender.FEMALE ? Person.FEMALE : Person.MALE; TimeTool ttBirthdate = new TimeTool(); // add data to query if (ehcName.getFamilyName() != null && !ehcName.getFamilyName().isEmpty()) { qpa.add(ch.elexis.data.Patient.FLD_NAME, Query.EQUALS, ehcName.getFamilyName()); } if (ehcName.getGivenNames() != null && !ehcName.getGivenNames().isEmpty()) { qpa.add(ch.elexis.data.Patient.FLD_FIRSTNAME, Query.EQUALS, ehcName.getGivenNames()); } if (ehcBirthdate != null) { ttBirthdate.setTime(ehcBirthdate); qpa.add(Person.BIRTHDATE, Query.EQUALS, ttBirthdate.toString(TimeTool.DATE_COMPACT)); } List<ch.elexis.data.Patient> existing = qpa.execute(); // create or overwrite Patient ch.elexis.data.Patient ret = null; if (existing.isEmpty()) { ret = new ch.elexis.data.Patient( ehcName.getFamilyName(), ehcName.getGivenNames(), ttBirthdate.toString(TimeTool.DATE_COMPACT), gender); } else { ret = existing.get(0); } return ret; }
private Identificator getPatientId(Patient elexisPatient) { // patient AHV String socialSecurityNumber = elexisPatient.getXid(DOMAIN_AHV); if (socialSecurityNumber != null) { socialSecurityNumber = socialSecurityNumber.trim(); socialSecurityNumber = socialSecurityNumber.replaceAll("\\.", ""); if (socialSecurityNumber.length() == 11) { return new Identificator( CodeSystems.SwissSSNDeprecated.getCodeSystemId(), socialSecurityNumber); } else if (socialSecurityNumber.length() == 13) { return new Identificator(CodeSystems.SwissSSN.getCodeSystemId(), socialSecurityNumber); } } return null; }
public static Patient getEhcPatient(ch.elexis.data.Patient elexisPatient) { Patient ret = new Patient( getEhcPersonName(elexisPatient), getEhcGenderCode(elexisPatient), getDate(elexisPatient.getGeburtsdatum())); // PHONE Telecoms telecoms = new Telecoms(); String value = elexisPatient.get(Kontakt.FLD_PHONE1); if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("0")) { telecoms.addPhone(value, AddressUse.PRIVATE); } value = elexisPatient.get(Kontakt.FLD_MOBILEPHONE); if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("0")) { telecoms.addPhone(value, AddressUse.MOBILE); } ret.setTelecoms(telecoms); // ADDRESS Anschrift elexisAddress = elexisPatient.getAnschrift(); if (elexisAddress != null) { ret.addAddress(getEhcAddress(elexisAddress)); } String socialSecurityNumber = elexisPatient.getXid(Xid.DOMAIN_AHV); if (socialSecurityNumber != null) { socialSecurityNumber = socialSecurityNumber.trim(); socialSecurityNumber = socialSecurityNumber.replaceAll("\\.", ""); if (socialSecurityNumber.length() == 11) { ret.addId( new Identificator( CodeSystems.SwissSSNDeprecated.getCodeSystemId(), socialSecurityNumber)); } else if (socialSecurityNumber.length() == 13) { ret.addId(new Identificator(CodeSystems.SwissSSN.getCodeSystemId(), socialSecurityNumber)); } } return ret; }