@Override public PatientLiteVoCollection listPatientsByIdentifier(PatientId patId) { if(patId == null || patId.getValue() == null || patId.getType() == null) throw new CodingRuntimeException("Invalid arguments for listPatientsByIdentifier !"); DomainFactory factory = getDomainFactory(); 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[]{patId.getType().getId(), patId.getIdValue()}); if (patientList != null && !patientList.isEmpty()) { return PatientLiteVoAssembler.createPatientLiteVoCollectionFromPatient(patientList); } return null; }
/** * getPatientList * This method will return an active patient, either the patient matching * the search criteria provided, or it's equivalent new merged patient * Used by HL7engine. */ public PatientLiteVo getPatientLite(PatientShort patVo) { ims.core.patient.domain.objects.Patient domPatient = getDomPatient(patVo); if (domPatient != null) { // Check associated value if not null, then get this patient while(domPatient.getAssociatedPatient() != null) { domPatient = domPatient.getAssociatedPatient(); } } return PatientLiteVoAssembler.create(domPatient); }
public PatientLiteVo getPatient(PatientRefVo patientRef) { if (patientRef == null || patientRef.getID_Patient()==null) throw new CodingRuntimeException("Patient not provided"); DomainFactory factory = getDomainFactory(); Patient doPatient = (Patient) factory.getDomainObject(Patient.class, patientRef.getID_Patient()); return PatientLiteVoAssembler.create(doPatient); }
public PatientLiteVo getPatientByCareContext(CareContextRefVo careContext) { if(careContext == null || careContext.getID_CareContext() == null) { throw new CodingRuntimeException("CareContextRefVo is null"); } if(careContext.getID_CareContext() == null) { throw new CodingRuntimeException("CareContextRefVo id is null"); } DomainFactory factory = getDomainFactory(); List domainObjectList = factory.find("select p from CareContext as cc left join cc.episodeOfCare as eoc left join eoc.careSpell as cs left join cs.patient as p where (cc.id = :idCareContext)", new String[]{"idCareContext"}, new Object[]{careContext.getID_CareContext()}); PatientLiteVoCollection patient = PatientLiteVoAssembler.createPatientLiteVoCollectionFromPatient(domainObjectList); return patient != null && patient.size() > 0 ? (patient.get(0) != null ? patient.get(0) : null) : null; }
@Override public PatientLiteVoCollection listPatientsByKeyFields(String snm, String fnm, Integer dob, Sex gender) throws DomainInterfaceException { if(snm == null || snm.length() == 0) throw new CodingRuntimeException("Invalid surname for listPatientsByKeyFields !"); if(fnm == null || fnm.length() == 0) throw new CodingRuntimeException("Invalid forename for listPatientsByKeyFields !"); DomainFactory factory = getDomainFactory(); ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); // WDEV-21866 - Listing patients by key fields, use the first 3 characters of surname, first char of forrename and 2 out of 3 elements of dob String hql = "select pat from Patient as pat where pat.name.upperSurname like :SNM and pat.name.upperForename like :FNM "; markers.add("SNM"); if (snm.length() > 3) values.add(snm.substring(0, 3) + "%"); else values.add(snm); markers.add("FNM"); if (fnm.length() > 1) values.add(fnm.substring(0,1) + "%"); else values.add(fnm); if(dob != null) { // WDEV-21866 Need to match by two parts of DOB i.e. YYMM String fullDob = dob.toString(); if (fullDob.length() == 8) { String yymmFrom = fullDob.substring(0, 6) + "01"; String yymmTo = fullDob.substring(0,6) + "31"; markers.add("yymmFrom"); values.add(new Integer(yymmFrom)); markers.add("yymmTo"); values.add(new Integer(yymmTo)); hql += " and pat.dob >= :yymmFrom and pat.dob <= :yymmTo "; } } if(gender != null) { markers.add("SEX"); values.add(gender.getId()); hql += " and pat.sex.id = :SEX"; } hql += " and not exists (select 1 from Patient as ppp left join ppp.identifiers as idd left join idd.type as lkp where ppp.id = pat.id and lkp.id = -9)"; List patientList = factory.find(hql.toString(), markers,values); if (patientList != null && !patientList.isEmpty()) { return PatientLiteVoAssembler.createPatientLiteVoCollectionFromPatient(patientList); } return null; }