protected Patient getLocalPatient(ims.core.patient.domain.objects.Patient domPatient) { if (domPatient == null) return null; //recurse to get master patient if this patient was merged ims.core.patient.domain.objects.Patient foundPatient = domPatient; boolean isMergedPatient = false; while(domPatient.getAssociatedPatient() != null) { domPatient = domPatient.getAssociatedPatient(); isMergedPatient = true; } if(isMergedPatient) raiseAlert(domPatient.getMergedMessage(foundPatient)); Patient voPatient = PatientAssembler.create(domPatient); if (voPatient != null && voPatient.getAge() == null) //wdev-14325 voPatient.calculateAge(); if (voPatient != null && voPatient.getCommChannels() != null) //wdev-14325 voPatient.getCommChannels().sort(); // Set Allergies & Allerts if(voPatient != null) //wdev-14325 { voPatient.setHasAlerts(hasAlerts(domPatient.getId())); voPatient.setHasAllergies(hasAllergy(domPatient.getId())); } return voPatient; }
private Patient savePatientToDto(DomainFactory factory, ims.core.patient.domain.objects.Patient domPatient, Patient voPatient, Boolean fromInterface, boolean fromDtoReplicate, boolean bBlankTempAddress) throws DomainInterfaceException, StaleObjectException { factory.save(domPatient); if(factory.isDirty(domPatient) || voPatient.getID_Patient() == null) { //WDEV- 6964 - update the pas and if new use the pasa generated hospnum for the local patient if(ConfigFlag.DOM.HEARTS_REPLICATE_PATIENTS.getValue() == true && !fromInterface) { String[] newIds = updateOrInsertDTOPatient(voPatient, fromDtoReplicate, bBlankTempAddress); if(newIds != null) { ims.core.patient.domain.objects.PatientId patHospnumId = new ims.core.patient.domain.objects.PatientId(); patHospnumId.setType(getDomLookup(PatIdType.HOSPNUM)); patHospnumId.setValue(newIds[0]); domPatient.getIdentifiers().add(patHospnumId); ims.core.patient.domain.objects.PatientId patPkeyId = new ims.core.patient.domain.objects.PatientId(); patPkeyId.setType(getDomLookup(PatIdType.PKEY)); patPkeyId.setValue(newIds[1]); domPatient.getIdentifiers().add(patPkeyId); factory.save(domPatient); voPatient = PatientAssembler.create(domPatient); } } } factory.setDirtyCheck(false); return voPatient; }
public ims.core.vo.Patient getMergedPatient(PatientShort patient) { ims.core.patient.domain.objects.Patient domPatient = getDomPatient(patient); // The id sent down for the patient could be the main one, we may need // to check whether this patient id is used as an associated patient anywhere! if (domPatient != null && domPatient.getAssociatedPatient() == null) { DomainFactory factory = getDomainFactory(); List lst = factory.find("from Patient p where p.associatedPatient.id = :assoc", new String[]{"assoc"}, new Object[]{domPatient.getId()}); if (lst != null && lst.size() > 0) return PatientAssembler.create((ims.core.patient.domain.objects.Patient) lst.get(0)); } return PatientAssembler.create(domPatient); }
public ims.core.vo.Patient getDestinationPatient(PatientRefVo patientRef) { if(patientRef == null) return null; return PatientAssembler.create((Patient) getDomainFactory().getDomainObject(Patient.class, patientRef.getID_Patient())); }
/** * getPatient */ public ims.core.vo.Patient getPatient(ims.core.patient.vo.PatientRefVo patient) { if(patient == null || patient.getID_Patient() == null) throw new CodingRuntimeException("patient os null or id not provided for method getPatient"); return PatientAssembler.create((Patient) getDomainFactory().getDomainObject(patient)); }
private PatientIdCollection mergePatientIdentifiers(DomainFactory factory, Patient srcPat, Patient destPat) throws SQLException, DomainInterfaceException, StaleObjectException, UniqueKeyViolationException { ims.core.vo.Patient sourcePatient = PatientAssembler.create(srcPat); PatientIdCollection sourceIds = (PatientIdCollection) sourcePatient.getIdentifiers().clone(); srcPat.getIdentifiers().clear(); // Source identifiers moved to destination factory.save(srcPat); // Need to save source pat with no ids before assigning to destination as otherwise, hibernate complains //add (source) identifiers to new (destination) patient for(int i=0;i<sourceIds.size();i++) { PatientId id = (PatientId) sourceIds.get(i).clone(); // wdev-6169 Do not move the nhsn over if it's the same as the nhsn for the destination patient if (id.getType().getId() == PatIdType.NHSN.getID()) { if (getNHSN(destPat.getIdentifiers()).equals(id.getValue())) continue; // wdev-6148 If moving an NHSN value over and it is verified, set it to unverified id.setVerified(false); } // wdev-10710 Only merge the PATNUM identifier if the source is NOT an ICABDummy Patient if (id.getType().getId() == PatIdType.PATNUM.getID()) { if (sourcePatient.getNameIsNotNull() && sourcePatient.getName().getSurnameIsNotNull() && sourcePatient.getName().getSurname().equals(DUMMY_PATIENT)) continue; // Do no insert them } id.setMerged(true); destPat.getIdentifiers().add(PatientIdAssembler.extractPatientId(factory,id)); } return sourceIds; }
public ims.core.vo.Patient getPatient(PatientShort patient) throws StaleObjectException { DomainFactory factory = getDomainFactory(); PatientId intfId = null; if (patient.getIdentifiers() == null || patient.getIdentifiers().size() == 0 || (intfId = patient.getIdentifiers().get(0)) == null) { throw new DomainRuntimeException("Patient Get call must contain valid identifier"); } String hql = " from Patient p " + " join p.identifiers as ids" + " where ids.value = :idValue " + " and ids.type = :idType "; java.util.List patientList = factory.find(hql, new String[]{"idValue", "idType"}, new Object[]{intfId.getValue(), getDomLookup(intfId.getType())}); ims.core.patient.domain.objects.Patient domPatient=null; if (patientList != null && !patientList.isEmpty()) { // Patient Should be unique per id value and type if (patientList.size() > 1) { throw new DomainRuntimeException("More than one patient found with identifier type = " + PatIdType.TYPE_ID + " and value = " + intfId.getValue()); } domPatient = (ims.core.patient.domain.objects.Patient)patientList.get(0); return PatientAssembler.create(domPatient); } return null; }
private Patient getPatientForCareContext(CareContextRefVo careContext) { if(careContext == null || careContext.getID_CareContext() == null) throw new CodingRuntimeException("CareContext is null or id not provided for getPatientForCareContext"); DomainFactory factory = getDomainFactory(); List pat = factory.find("select careSpell.patient rom CareSpell as careSpell left join careSpell.episodes as epis left join epis.careContexts as cc where cc.id = :idCareContext", new String[]{"idCareContext"}, new Object[]{careContext.getID_CareContext()}); PatientCollection patVo = PatientAssembler.createPatientCollectionFromPatient(pat); return patVo != null && patVo.size() > 0 ? patVo.get(0) : null; }
public Patient getPatient(PatientRefVo patient) throws DomainInterfaceException { if(patient == null || patient.getID_Patient() == null) throw new DomainRuntimeException("Invalid patient"); return PatientAssembler.create((ims.core.patient.domain.objects.Patient)getDomainFactory().getDomainObject(patient)); }
public Patient getPatient(PatientRefVo patient) { if(patient == null) throw new CodingRuntimeException("null patient passed to getPatient() !"); DomainFactory factory = getDomainFactory(); ims.core.patient.domain.objects.Patient boPatient = (ims.core.patient.domain.objects.Patient)factory.getDomainObject(ims.core.patient.domain.objects.Patient.class, patient.getID_Patient()); return PatientAssembler.create(boPatient); }
@Override public ims.core.vo.Patient getPatient(ims.core.patient.vo.PatientRefVo patient) { if(patient == null || patient.getID_Patient() == null) throw new CodingRuntimeException("patient os null or id not provided for method getPatient"); return PatientAssembler.create((ims.core.patient.domain.objects.Patient) getDomainFactory().getDomainObject(patient)); }
@Override public Patient activateDeactivatePatient(Patient patient) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException, UnqViolationUncheckedException { if (patient == null) return null; DomainFactory factory = getDomainFactory(); patient.setIsActive(!patient.getIsActive()); ims.core.patient.domain.objects.Patient domPat = PatientAssembler.extractPatient(factory, patient); //WDEV-20593 Trigger HL7 message //WDEV-21056 Trigger HL7 message when patient is recativated as well if (patient.getIsActive() != null) { if (Boolean.TRUE.equals(patient.getIsActive())) { triggerDemographicEvent(domPat, MsgEventType.A31); } else { triggerDemographicEvent(domPat, MsgEventType.A29); } } factory.save(domPat); return PatientAssembler.create(domPat); }
public Patient getPatientByIdentifier(String ident, PatIdType type) { DomainFactory factory = getDomainFactory(); if (ident == null || ident.length() == 0) { throw new CodingRuntimeException("getPatientByIdentifier: invalid identifier: " + ident); } if (type == null) { throw new CodingRuntimeException("getPatientByIdentifier: invalid identifier type"); } String hql = "select p1_1 from Patient as p1_1 left join p1_1.identifiers as p2_1 left join p2_1.type as l1_1 where (l1_1.id = :type and p2_1.value = :value)"; java.util.List patientList = factory.find(hql, new String[]{"type", "value"}, new Object[]{type.getId(), ident}); if (patientList != null && !patientList.isEmpty()) { // Patient Should be unique per id value and type if (patientList.size() > 1) { throw new DomainRuntimeException("More than one patient found with identifier type = " + type.getText() + " and value = " + ident); } ims.core.patient.domain.objects.Patient domPatient = (ims.core.patient.domain.objects.Patient) patientList.get(0); return PatientAssembler.create(domPatient); } return null; }
public ims.core.vo.Patient getPatient(PatientRefVo ref) { if (ref != null) { Patient patient = (Patient) getDomainFactory().getDomainObject(Patient.class,ref.getID_Patient()); ims.core.vo.Patient voPatient = PatientAssembler.create(patient); return voPatient; } return null; }
public ims.core.vo.Patient getPatientByIdentifier(String nhsNumber, PatIdType idType) { DomainFactory factory = getDomainFactory(); if (nhsNumber == null || nhsNumber.length() == 0) { throw new CodingRuntimeException("getPatientByIdentifier: invalid identifier: " + nhsNumber); } if (idType == null) { throw new CodingRuntimeException("getPatientByIdentifier: invalid identifier type"); } String hql = "select p1_1 from Patient as p1_1 left join p1_1.identifiers as p2_1 left join p2_1.type as l1_1 where (l1_1.id = :type and p2_1.value = :value)"; java.util.List patientList = factory.find(hql, new String[]{"type", "value"}, new Object[]{idType.getId(), nhsNumber}); if (patientList != null && !patientList.isEmpty()) { // Patient Should be unique per id value and type if (patientList.size() > 1) { throw new DomainRuntimeException("More than one patient found with identifier type = " + idType.getText() + " and value = " + nhsNumber); } ims.core.patient.domain.objects.Patient domPatient = (ims.core.patient.domain.objects.Patient) patientList.get(0); return PatientAssembler.create(domPatient); } return null; }
public ims.core.vo.Patient saveLocalPatient(ims.core.vo.Patient patient) throws StaleObjectException { if (patient == null) throw new DomainRuntimeException("Cannot save null record."); if (!patient.isValidated()) throw new DomainRuntimeException("Record not validated."); DomainFactory domainFactory = getDomainFactory(); Patient domPatient = PatientAssembler.extractPatient(domainFactory, patient); domainFactory.save(domPatient); ims.core.vo.Patient item = PatientAssembler.create(domPatient); return item; }
private ims.core.vo.Patient getLocalPatient(PatientShort patVo) { DomainFactory factory = getDomainFactory(); if (patVo.getIdentifiers() == null || patVo.getIdentifiers().size() == 0 || (patVo.getIdentifiers().get(0)) == null) { throw new DomainRuntimeException("Patient Get call must contain valid identifier"); } PatientIdCollection identifiers = patVo.getIdentifiers(); for (int i = 0; i < identifiers.size(); i++) { if (identifiers.get(i).getType().equals(PatIdType.PKEY)) { String idVal = identifiers.get(i).getIdValue().trim(); String hql = " from Patient p join p.identifiers as ids where ids.type = :idType and ids.value = :idValue "; java.util.List<?> patientList = factory.find(hql, new String[]{"idValue", "idType"}, new Object[]{idVal, getDomLookup(identifiers.get(i).getType())}); PatientCollection patients = PatientAssembler.createPatientCollectionFromPatient(patientList); if (patients!=null && patients.size()>0) { return patients.get(0); } } } return null; }
private Patient getPatientForCareContext(CareContextRefVo careContext) { if(careContext == null || careContext.getID_CareContext() == null) throw new CodingRuntimeException("CareContext is null or id not provided for getPatientForCareContext"); DomainFactory factory = getDomainFactory(); List pat = factory.find("select careSpell.patient from CareSpell as careSpell left join careSpell.episodes as epis left join epis.careContexts as cc where cc.id = :idCareContext", new String[]{"idCareContext"}, new Object[]{careContext.getID_CareContext()}); PatientCollection patVo = PatientAssembler.createPatientCollectionFromPatient(pat); return patVo != null && patVo.size() > 0 ? patVo.get(0) : null; }
public Patient getPatient(PatientRefVo patient) { if(patient == null || patient.getID_Patient() == null) return null; return PatientAssembler.create((ims.core.patient.domain.objects.Patient)getDomainFactory().getDomainObject(patient)); }