public CareContextInterfaceVo getCareContextFromPasEpisodeId(String pasEpisodeId, String visitId) { DomainFactory factory=getDomainFactory(); ArrayList<String> objects=new ArrayList<String>(); objects.add("pasEvent"); IMSCriteria imsc=new IMSCriteria(CareContext.class,objects,factory); imsc.equal("pasEvent.pasEpisodeId", pasEpisodeId); imsc.equal("pasEvent.pasEventId", visitId); List careContexts=imsc.find(); if (careContexts.size()>0) { CareContext careContext=(CareContext)careContexts.get(careContexts.size()-1); return CareContextInterfaceVoAssembler.create(careContext); } return null; }
public void cancelAppointment(OutPatientAttendanceVo attendance, CareContextInterfaceVo voCareContext) throws StaleObjectException { DomainFactory factory = getDomainFactory(); OutpatientAttendance domAtt = OutPatientAttendanceVoAssembler.extractOutpatientAttendance(factory, attendance); if(ConfigFlag.HL7.INSTANTIATE_EPISODE_FROM_ADT.getValue()) { if(voCareContext != null) factory.save(CareContextInterfaceVoAssembler.extractCareContext(factory, voCareContext)); } // WDEV-13455 // We may want to record this appointment within the Patient Diary if (ConfigFlag.DOM.RECORD_INTO_PATIENT_DIARY.getValue()) { PatientApptDiary diary = createDiaryEntry(domAtt,attendance.getApptType(),attendance.getRecordingUser()); factory.save(diary); } factory.save(domAtt); }
public AdmissionDetailVo getAdmissionForSelectedCareContext(CareContextInterfaceVo careContext) { if( careContext == null || careContext.getPasEvent() == null ) throw new CodingRuntimeException("CareContextInterfaceVo is null"); DomainFactory factory = getDomainFactory(); String hql = " select a1_1 from AdmissionDetail as a1_1 left join a1_1.pasEvent as p1_1 where (p1_1.id = :pasEventId) order by a1_1.admissionDateTime desc"; List<?> lst = factory.find(hql,new String[]{"pasEventId"},new Object[]{careContext.getPasEvent().getID_PASEvent()}); if (lst != null && lst.size() > 0) { AdmissionDetailVoCollection tempColl = AdmissionDetailVoAssembler.createAdmissionDetailVoCollectionFromAdmissionDetail(lst) ; if(tempColl != null && tempColl.size() > 0) { return tempColl.get(0); } } return null; }
public CareContextRefVo getCareContextFromPV1(PV1 pv) throws DataTypeException { String visitId=pv.getVisitNumber().getID().getValue() + "_" + pv.getVisitNumber().getComponent(1); String pasEpisodeId = pv.getAlternateVisitID().getID().getValue(); CareContextInterfaceVo careContext; if (pasEpisodeId!=null) { careContext=careSpellDialog.getCareContextFromPasEpisodeId(pasEpisodeId,visitId); if (careContext!=null) { if (careContext.getEpisodeOfCare()!=null) { setCareContextContext(careContext.getID_CareContext(),careContext.getEpisodeOfCare().getID_EpisodeOfCare()); return (CareContextRefVo)careContext; } } } return null; }
public CareContextInterfaceVo saveCareContext(CareContextInterfaceVo careContext) throws StaleObjectException { if (careContext == null || !careContext.isValidated()) throw new CodingRuntimeException("Care Spell is null or has not been validated"); DomainFactory factory=getDomainFactory(); CareContext doCareContext = CareContextInterfaceVoAssembler.extractCareContext(factory, careContext); //WDEV-10231 - add any new status record to history if(doCareContext.getCurrentStatus() != null && doCareContext.getCurrentStatus().getId() == null) doCareContext.getStatusHistory().add(doCareContext.getCurrentStatus()); factory.save(doCareContext); return CareContextInterfaceVoAssembler.create(doCareContext); }
public CareContextInterfaceVo getCareContextByPasEvent(PASEventRefVo pasEvent) { if (pasEvent == null || pasEvent.getID_PASEvent() == null) throw new CodingRuntimeException("pasEvent is null or id not provided in method getCareContextByPasEvent"); CareContext doCareContext = (CareContext) getDomainFactory().findFirst("from CareContext cc where cc.pasEvent.id = " + pasEvent.getID_PASEvent()); return CareContextInterfaceVoAssembler.create(doCareContext); }
public ims.core.vo.CareContextInterfaceVo getCareContextById(ims.core.admin.vo.CareContextRefVo careContextRef) { if( careContextRef == null) throw new CodingRuntimeException("This CareContextRefVo is null"); DomainFactory factory = getDomainFactory(); CareContext doCareContext = (CareContext) factory.getDomainObject(CareContext.class, careContextRef.getID_CareContext()); return CareContextInterfaceVoAssembler.create(doCareContext); }
public DischargedEpisodeVo saveRecord(DischargedEpisodeVo record, PatientShort patient, CareContextInterfaceVo careContext) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException { ADT Adt = (ADT)getDomainImpl(ADTImpl.class); if( patient != null) patient.validate(); return Adt.dischargePatient(patient, record, careContext); }
public OutPatientAttendanceVo recordOPAttendance(PatientShort patVo, OutPatientAttendanceVo attVo, CareContextInterfaceVo ccVo) throws StaleObjectException { if (!patVo.isValidated()) { throw new DomainRuntimeException("Patient VO has not been validated!"); } if (!attVo.isValidated()) { throw new DomainRuntimeException("Attendance VO has not been validated!"); } if(patVo.getID_Patient() == null) { throw new DomainRuntimeException("Internal Patient ID must be valued."); } DomainFactory factory = getDomainFactory(); OutpatientAttendance attDo = OutPatientAttendanceVoAssembler.extractOutpatientAttendance(factory, attVo); if(ConfigFlag.HL7.INSTANTIATE_EPISODE_FROM_ADT.getValue()) { if(ccVo != null) factory.save(CareContextInterfaceVoAssembler.extractCareContext(factory, ccVo)); } try { factory.save(attDo); // WDEV-13455 // We may want to record this appointment within the Patient Diary if (ConfigFlag.DOM.RECORD_INTO_PATIENT_DIARY.getValue()) { PatientApptDiary diary = createDiaryEntry(attDo,attVo.getApptType(),attVo.getRecordingUser()); factory.save(diary); } } catch (DomainException e) { throw new DomainRuntimeException(e); } return OutPatientAttendanceVoAssembler.create(attDo); }
private void updateInpatientDetails(Patient patVo, InpatientEpisodeVo episVo, Message msg, PV1 pv1,ProviderSystemVo providerSystem) throws Exception { // wdev-12588 Hold on to previous PasEvent, as if location changed, we have to set bed number to null // we may also have to update the EpisodeOfCare hcp, start date etc.. PasEventVo originalPE = (PasEventVo) episVo.getPasEvent().clone(); fillEpisFromMsg(episVo, msg, getOrgLoc(), getHcpAdmin(),providerSystem); //Force the update of the admission date by taking it from PV1.44 if (pv1.getAdmitDateTime().getTimeOfAnEvent() != null && pv1.getAdmitDateTime().getTimeOfAnEvent().getValue() != null) { episVo.getPasEvent().setEventDateTime(new DateTime(pv1.getAdmitDateTime().getTimeOfAnEvent().getValue())); } episVo.getPasEvent().setPatient(patVo); String[] errs = episVo.validate(); if (errs != null) { throw new HL7Exception("Validation of Admission failed. " + VoMapper.toDisplayString(errs)); } //WDEV-10231 CareContextInterfaceVo voCareContext = null; if(ConfigFlag.HL7.INSTANTIATE_EPISODE_FROM_ADT.getValue() || ConfigFlag.HL7.INPATIENT_EPISODE_MANAGEMENT_FROM_PAS.getValue()) { if(episVo != null && episVo.getPasEventIsNotNull()) { voCareContext = getADT().getCareContextByPasEvent(episVo.getPasEvent()); if(voCareContext != null) { // WDEV-13901 may need to create the history record // check if history records required for CC and EpisodeOfCare voCareContext = createHistoryCareContextAndEpis(voCareContext, true, pv1, providerSystem.getCodeSystem().getText()); voCareContext.setStartDateTime(episVo.getPasEvent().getEventDateTime()); voCareContext.setResponsibleHCP(episVo.getPasEvent().getConsultant()); // wdev-12588 voCareContext.setEstimatedDischargeDate(episVo.getEstDischargeDate()); voCareContext.getEpisodeOfCare().setStartDate(episVo.getPasEvent().getEventDateTime().getDate()); voCareContext.getEpisodeOfCare().setResponsibleHCP(episVo.getPasEvent().getConsultant()); voCareContext.getEpisodeOfCare().getCareSpell().setStartDate(episVo.getPasEvent().getEventDateTime().getDate()); LocSiteShortVo loc = orgLoc.getLocSiteShortByTaxonomyType(pv1.getAssignedPatientLocation().getBuilding().getValue(), TaxonomyType.PAS); LocSiteRefVo orderingHospRef = new LocSiteRefVo(); if (loc!=null) { orderingHospRef.setID_Location(loc.getBoId()); voCareContext.setOrderingHospital(orderingHospRef); } // wdev-12588 If location changes, we need to set the carecontext bed number to null if (episVo.getPasEventIsNotNull() && episVo.getPasEvent().getLocationIsNotNull() && originalPE != null && originalPE.getLocationIsNotNull() && !originalPE.getLocation().equals(episVo.getPasEvent().getLocation())) { voCareContext.setBedNumber(null); } //specialty in episode of care if(voCareContext.getEpisodeOfCareIsNotNull() && providerSystem != null && providerSystem.getCodeSystemIsNotNull()) { voCareContext.getEpisodeOfCare().setSpecialty((Specialty) svc.getLocalLookup(Specialty.class, Specialty.TYPE_ID, providerSystem.getCodeSystem().getText(), pv1.getHospitalService().getValue())); if (!voCareContext.getEpisodeOfCare().getSpecialtyIsNotNull()) { throw new HL7Exception("Specialty not found with mapping value = " + pv1.getHospitalService().getValue()); } } } } } getADT().updateInpatient(episVo, voCareContext); }
private void updateDischargeDetails(Patient patVo, DischargedEpisodeVo dischVo, Message msg, PV1 pv1,ProviderSystemVo providerSystem) throws Exception { fillDischargeFromMsg(dischVo, msg, getOrgLoc(), getHcpAdmin(),providerSystem); dischVo.getPasEvent().setPatient(patVo); String[] errs = dischVo.validate(); if (errs != null) { throw new HL7Exception("Validation of Admission failed. " + VoMapper.toDisplayString(errs)); } // wdev-8924 - Validate Patient too errs = patVo.validate(); if (errs != null) { throw new HL7Exception("Validation of Patient failed. " + VoMapper.toDisplayString(errs)); } //WDEV-10231 CareContextInterfaceVo voCareContext = null; if(ConfigFlag.HL7.INSTANTIATE_EPISODE_FROM_ADT.getValue() || ConfigFlag.HL7.INPATIENT_EPISODE_MANAGEMENT_FROM_PAS.getValue()) { if(dischVo != null && dischVo.getPasEventIsNotNull()) { voCareContext = getADT().getCareContextByPasEvent(dischVo.getPasEvent()); if(voCareContext != null) { // WDEV-13901 may need to create the history record // check if history records required for CC and EpisodeOfCare voCareContext = createHistoryCareContextAndEpis(voCareContext, true, pv1, providerSystem.getCodeSystem().getText()); voCareContext.setEndDateTime(dischVo.getPasEvent().getEventDateTime()); voCareContext.setResponsibleHCP(dischVo.getPasEvent().getConsultant()); voCareContext.getEpisodeOfCare().setResponsibleHCP(dischVo.getPasEvent().getConsultant()); if(voCareContext.getEpisodeOfCareIsNotNull() && providerSystem != null && providerSystem.getCodeSystemIsNotNull()) voCareContext.getEpisodeOfCare().setSpecialty((Specialty) svc.getLocalLookup(Specialty.class, Specialty.TYPE_ID, providerSystem.getCodeSystem().getText(), pv1.getHospitalService().getValue())); if (pv1.getAdmitDateTime().getTimeOfAnEvent() != null && pv1.getAdmitDateTime().getTimeOfAnEvent().getValue() != null) { Date newStartDate = new Date(pv1.getAdmitDateTime().getTimeOfAnEvent().getValue().substring(0,8), DateFormat.ISO); voCareContext.setStartDateTime(new DateTime(pv1.getAdmitDateTime().getTimeOfAnEvent().getValue())); voCareContext.getEpisodeOfCare().setStartDate(newStartDate); voCareContext.getEpisodeOfCare().getCareSpell().setStartDate(newStartDate); } } } } getADT().dischargePatient(patVo, dischVo, voCareContext); }
public void updateInpatient(InpatientEpisodeVo inpatientRecord, CareContextInterfaceVo voCareContext) throws StaleObjectException { updateInpatient(inpatientRecord, voCareContext, true); }
private void updateInpatientDetails(Patient patVo, InpatientEpisodeVo episVo, Message msg, PV1 pv1,ProviderSystemVo providerSystem) throws Exception { // wdev-12588 Hold on to previous PasEvent, as if location changed, we have to set bed number to null // we may also have to update the EpisodeOfCare hcp, start date etc.. PasEventVo originalPE = (PasEventVo) episVo.getPasEvent().clone(); fillEpisFromMsg(episVo, msg, getOrgLoc(), getHcpAdmin(),providerSystem); //Force the update of the admission date by taking it from PV1.44 if (pv1.getAdmitDateTime().getTimeOfAnEvent() != null && pv1.getAdmitDateTime().getTimeOfAnEvent().getValue() != null) { episVo.getPasEvent().setEventDateTime(new DateTime(pv1.getAdmitDateTime().getTimeOfAnEvent().getValue())); } episVo.getPasEvent().setPatient(patVo); String[] errs = episVo.validate(); if (errs != null) { throw new HL7Exception("Validation of Admission failed. " + VoMapper.toDisplayString(errs)); } //WDEV-10231 CareContextInterfaceVo voCareContext = null; if(ConfigFlag.HL7.INSTANTIATE_EPISODE_FROM_ADT.getValue() || ConfigFlag.HL7.INPATIENT_EPISODE_MANAGEMENT_FROM_PAS.getValue()) { if(episVo != null && episVo.getPasEventIsNotNull()) { voCareContext = getADT().getCareContextByPasEvent(episVo.getPasEvent()); if(voCareContext != null) { // WDEV-13901 may need to create the history record // check if history records required for CC and EpisodeOfCare voCareContext = createHistoryCareContextAndEpis(voCareContext, true, pv1, providerSystem.getCodeSystem().getText()); voCareContext.setStartDateTime(episVo.getPasEvent().getEventDateTime()); voCareContext.setResponsibleHCP(episVo.getPasEvent().getConsultant()); // wdev-12588 voCareContext.setEstimatedDischargeDate(episVo.getEstDischargeDate().getDate()); voCareContext.getEpisodeOfCare().setStartDate(episVo.getPasEvent().getEventDateTime().getDate()); voCareContext.getEpisodeOfCare().setResponsibleHCP(episVo.getPasEvent().getConsultant()); voCareContext.getEpisodeOfCare().getCareSpell().setStartDate(episVo.getPasEvent().getEventDateTime().getDate()); //WDEV-20278 // LocSiteShortVo loc = orgLoc.getLocSiteShortByTaxonomyType(pv1.getAssignedPatientLocation().getBuilding().getValue(), TaxonomyType.PAS); LocSiteShortVo loc = orgLoc.getLocSiteShortByTaxonomyType(pv1.getAssignedPatientLocation().getBuilding().getValue(), providerSystem.getCodeSystem()); //WDEV-20278 LocSiteRefVo orderingHospRef = new LocSiteRefVo(); if (loc!=null) { orderingHospRef.setID_Location(loc.getBoId()); voCareContext.setOrderingHospital(orderingHospRef); } // wdev-12588 If location changes, we need to set the carecontext bed number to null if (episVo.getPasEventIsNotNull() && episVo.getPasEvent().getLocationIsNotNull() && originalPE != null && originalPE.getLocationIsNotNull() && !originalPE.getLocation().equals(episVo.getPasEvent().getLocation())) { voCareContext.setBedNumber(null); } //specialty in episode of care if(voCareContext.getEpisodeOfCareIsNotNull() && providerSystem != null && providerSystem.getCodeSystemIsNotNull()) { voCareContext.getEpisodeOfCare().setSpecialty((Specialty) svc.getLocalLookup(Specialty.class, Specialty.TYPE_ID, providerSystem.getCodeSystem().getText(), pv1.getHospitalService().getValue())); if (!voCareContext.getEpisodeOfCare().getSpecialtyIsNotNull()) { throw new HL7Exception("Specialty not found with mapping value = " + pv1.getHospitalService().getValue()); } } } } } getADT().updateInpatient(episVo, voCareContext); }