private CatsReferralEmergencyAdmissionVo createNewCatsReferralForAdmission(PatientShort patientShort, PatientWithGPForCCGVo patient, CareSpellVo careSpell, AdmissionDetailVo admission, ContractConfigShortVo contract) { CatsReferralEmergencyAdmissionVo referral = new CatsReferralEmergencyAdmissionVo(); referral.setPatient(patientShort); referral.setCareContext(careSpell.getEpisodes().get(0).getCareContexts().get(0)); CatsReferralStatusVo referralStatus = new CatsReferralStatusVo(); referralStatus.setReferralStatus(ReferralApptStatus.REFERRAL_ACCEPTED); referralStatus.setStatusDateTime(new DateTime()); referralStatus.setAuthoringUser((MemberOfStaffRefVo) domain.getMosUser()); referral.setCurrentStatus(referralStatus); referral.setStatusHistory(new CATSReferralStatusRefVoCollection()); referral.getStatusHistory().add(referralStatus); String codeCCG = getCCGCode(patient); referral.setContract(contract); referral.setHasAppointments(false); referral.setAdmissions(new AdmissionDetailVoCollection()); referral.getAdmissions().add(admission); ReferralDetailsEmergencyAdmissionVo referralDetails = new ReferralDetailsEmergencyAdmissionVo(); referralDetails.setService(form.cmbService().getValue()); referralDetails.setConsultant(domain.getHcpFromIMos(form.ccConsultant().getValue())); referralDetails.setAuthoringUser((MemberOfStaffRefVo) domain.getMosUser()); referralDetails.setAuthoringDateTime(new DateTime()); referralDetails.setDateReferralReceived(new Date()); referralDetails.setDateOfReferral(new Date()); referralDetails.setEnd18WW(calculateEnd18WW(contract)); referralDetails.setPCT(codeCCG); referralDetails.setGPName(patient.getGp()); referralDetails.setPractice(getPatientGpDefaultPractice(patient)); referral.setReferralDetails(referralDetails); return referral; }
private OrganisationRefVo getPatientGpDefaultPractice(PatientWithGPForCCGVo patient) { if (patient == null || patient.getGp() == null || patient.getGp().getPractices() == null) return null; for (GpToPracticesVo gpToPractices : patient.getGp().getPractices()) { if (Boolean.TRUE.equals(gpToPractices.getIsPrimaryPractice())) return gpToPractices.getPractice(); } return null; }
public PatientWithGPForCCGVo getPatientForCCG(PatientRefVo patient) { if (patient == null || patient.getID_Patient() == null) return null; return PatientWithGPForCCGVoAssembler.create((ims.core.patient.domain.objects.Patient) getDomainFactory().getDomainObject(ims.core.patient.domain.objects.Patient.class, patient.getID_Patient())); }
private PatientWithGPForCCGVo getPatientForCCG(PatientRefVo patient) { if (patient == null || patient.getID_Patient() == null) return null; PatientWithGPForCCGVo patientWithGP = (PatientWithGPForCCGVo) PatientWithGPForCCGVoAssembler.create((ims.core.patient.domain.objects.Patient) getDomainFactory().getDomainObject(ims.core.patient.domain.objects.Patient.class, patient.getID_Patient())); return patientWithGP; }
public PatientWithGPForCCGVo getPatientForCCG(PatientRefVo patientRef) { if (patientRef == null) return null; DomainFactory domainFactory = getDomainFactory(); ims.core.patient.domain.objects.Patient record = (ims.core.patient.domain.objects.Patient) domainFactory.getDomainObject(ims.core.patient.domain.objects.Patient.class, patientRef.getID_Patient()); if (record != null && Boolean.TRUE.equals(record.isIsActive())) { return PatientWithGPForCCGVoAssembler.create(record); } return null; }
public CatsReferralRepatriationRequestVo save(PasEventRepatriationVo pasEvent, CareSpellRepatriationVo careSpell, CatsReferralRepatriationRequestVo repatriationReferral) throws ims.domain.exceptions.DomainInterfaceException, ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException, ims.domain.exceptions.UniqueKeyViolationException { if (pasEvent == null || careSpell == null || repatriationReferral == null) throw new CodingRuntimeException("Cannot save null records."); if (!pasEvent.isValidated() || !careSpell.isValidated() || !repatriationReferral.isValidated()) throw new CodingRuntimeException("Records to save are not validated."); @SuppressWarnings("rawtypes") HashMap hashMap = new HashMap(); PASEvent domPasEvent = PasEventRepatriationVoAssembler.extractPASEvent(getDomainFactory(), pasEvent, hashMap); getDomainFactory().save(domPasEvent); CareSpell domCareSpell = CareSpellRepatriationVoAssembler.extractCareSpell(getDomainFactory(), careSpell, hashMap); getDomainFactory().save(domCareSpell); CatsReferral domCatsReferral = CatsReferralRepatriationRequestVoAssembler.extractCatsReferral(getDomainFactory(), repatriationReferral, hashMap); //WDEV-21767 Pending Emergency Admissions - Ensure referral has a valid CCG Code (PCT) if (domCatsReferral.getReferralDetails().getPCT() == null) { PatientWithGPForCCGVo patientWithGP = PatientWithGPForCCGVoAssembler.create(domCatsReferral.getPatient()); String ccgCode = getCCGCode(patientWithGP); if (ccgCode != null) { domCatsReferral.getReferralDetails().setPCT(ccgCode); } } getDomainFactory().save(domCatsReferral); return CatsReferralRepatriationRequestVoAssembler.create(domCatsReferral); }
public ims.core.vo.CatsReferralRepatriationRequestVo save(ims.core.vo.CatsReferralRepatriationRequestVo repatriationReferral) throws ims.domain.exceptions.DomainInterfaceException, ims.domain.exceptions.StaleObjectException, ims.domain.exceptions.ForeignKeyViolationException, ims.domain.exceptions.UniqueKeyViolationException { if (repatriationReferral == null) throw new CodingRuntimeException("Cannot save null record."); if (!repatriationReferral.isValidated()) throw new CodingRuntimeException("Record to save is not validated."); @SuppressWarnings("rawtypes") HashMap map = new HashMap(); CatsReferral domCats = CatsReferralRepatriationRequestVoAssembler.extractCatsReferral(getDomainFactory(), repatriationReferral, map); //WDEV-21767 Pending Emergency Admissions - Ensure referral has a valid CCG Code (PCT) if (domCats.getReferralDetails().getPCT() == null) { PatientWithGPForCCGVo patientWithGP = PatientWithGPForCCGVoAssembler.create(domCats.getPatient()); String ccgCode = getCCGCode(patientWithGP); if (ccgCode != null) { domCats.getReferralDetails().setPCT(ccgCode); } } getDomainFactory().save(domCats); return CatsReferralRepatriationRequestVoAssembler.create(domCats); }
public PatientWithGPForCCGVo getPatientWithGp(PatientRefVo patientRef) { if (patientRef == null || patientRef.getID_Patient() == null) return null; PatientWithGPForCCGVo patientWithGP = (PatientWithGPForCCGVo) PatientWithGPForCCGVoAssembler.create((ims.core.patient.domain.objects.Patient) getDomainFactory().getDomainObject(ims.core.patient.domain.objects.Patient.class, patientRef.getID_Patient())); return patientWithGP; }
private CatsReferralEmergencyAdmissionVo createCatsReferral(PatientLite_IdentifiersVo patient, AdmissionDetailVo admission, CareSpellAdmitVo careSpell) { if (careSpell == null || careSpell.getEpisodes() == null || careSpell.getEpisodes().size() < 1 || careSpell.getEpisodes().get(0).getCareContexts() == null) throw new CodingRuntimeException("Invalid care spell created."); CatsReferralEmergencyAdmissionVo referral = new CatsReferralEmergencyAdmissionVo(); referral.setPatient(patient); for (CareContextAdmitVo careContext : careSpell.getEpisodes().get(0).getCareContexts()) { if (ContextType.REFERRAL.equals(careContext.getContext())) { referral.setCareContext(careContext); referral.setEpisodeOfCare(careSpell.getEpisodes().get(0)); break; } } //WDEV-22214 PatientWithGPForCCGVo patientWithGP = domain.getPatientForCCG(patient); String codeCCG = getCCGCode(patientWithGP); CatsReferralStatusVo referralStatus = new CatsReferralStatusVo(); referralStatus.setReferralStatus(ReferralApptStatus.REFERRAL_ACCEPTED); referralStatus.setStatusDateTime(new DateTime()); referralStatus.setAuthoringUser((MemberOfStaffRefVo) domain.getMosUser()); referral.setCurrentStatus(referralStatus); referral.setStatusHistory(new CATSReferralStatusRefVoCollection()); referral.getStatusHistory().add(referralStatus); referral.setContract(null); referral.setHasAppointments(false); referral.setAdmissions(new AdmissionDetailVoCollection()); referral.getAdmissions().add(admission); ReferralDetailsEmergencyAdmissionVo referralDetails = new ReferralDetailsEmergencyAdmissionVo(); referralDetails.setReferrerType(form.cmbSourceOfReferral().getValue() != null ? form.cmbSourceOfReferral().getValue() : SourceOfReferral.ED); referralDetails.setService(admission.getService()); referralDetails.setConsultant(domain.getHcpFromIMos(admission.getConsultant())); referralDetails.setAuthoringUser((MemberOfStaffRefVo) domain.getMosUser()); referralDetails.setAuthoringDateTime(new DateTime()); //referralDetails.setDateReferralReceived(new Date());WDEV-22688 referralDetails.setDateOfReferral(new Date()); referralDetails.setEnd18WW(null); referralDetails.setPCT(codeCCG); referral.setReferralDetails(referralDetails); referral.setIsEmergencyReferral(Boolean.TRUE); referral.setUrgency(ReferralUrgency.EMERGENCY); //WDEV-22229 return referral; }
private CatsReferralEmergencyAdmissionVo createCatsReferral(PatientLite_IdentifiersVo patient, AdmissionDetailVo admission, CareSpellAdmitVo careSpell) { if (careSpell == null || careSpell.getEpisodes() == null || careSpell.getEpisodes().size() < 1 || careSpell.getEpisodes().get(0).getCareContexts() == null) throw new CodingRuntimeException("Invalid care spell created."); CatsReferralEmergencyAdmissionVo referral = new CatsReferralEmergencyAdmissionVo(); referral.setPatient(patient); for (CareContextAdmitVo careContext : careSpell.getEpisodes().get(0).getCareContexts()) { if (ContextType.REFERRAL.equals(careContext.getContext())) { referral.setCareContext(careContext); referral.setEpisodeOfCare(careSpell.getEpisodes().get(0)); break; } } PatientWithGPForCCGVo patientWithGP = domain.getPatientForCCG(patient); String codeCCG = getCCGCode(patientWithGP); CatsReferralStatusVo referralStatus = new CatsReferralStatusVo(); referralStatus.setReferralStatus(ReferralApptStatus.REFERRAL_ACCEPTED); referralStatus.setStatusDateTime(new DateTime()); referralStatus.setAuthoringUser((MemberOfStaffRefVo) domain.getMosUser()); referral.setCurrentStatus(referralStatus); referral.setStatusHistory(new CATSReferralStatusRefVoCollection()); referral.getStatusHistory().add(referralStatus); referral.setContract(null); referral.setHasAppointments(false); referral.setAdmissions(new AdmissionDetailVoCollection()); referral.getAdmissions().add(admission); ReferralDetailsEmergencyAdmissionVo referralDetails = new ReferralDetailsEmergencyAdmissionVo(); referralDetails.setReferrerType(form.cmbSourceOfReferral().getValue() != null ? form.cmbSourceOfReferral().getValue() : SourceOfReferral.ED); referralDetails.setService(admission.getService()); referralDetails.setConsultant(domain.getHcpFromIMos(admission.getConsultant())); referralDetails.setAuthoringUser((MemberOfStaffRefVo) domain.getMosUser()); referralDetails.setAuthoringDateTime(new DateTime()); //referralDetails.setDateReferralReceived(new Date());//WDEV-22688 referralDetails.setDateOfReferral(new Date()); referralDetails.setEnd18WW(null); referralDetails.setPCT(codeCCG); referral.setReferralDetails(referralDetails); referral.setIsEmergencyReferral(Boolean.TRUE); referral.setUrgency(ReferralUrgency.EMERGENCY); //WDEV-22229 return referral; }
public PatientWithGPForCCGVo getPatientWithGPForCCG() { return patient; }
private void setCCGCode(PatientWithGPForCCGVo patientWithGP) { this.cCGCode = getCCGCode(patientWithGP); }
private String getCCGCode(PatientWithGPForCCGVo patient) { if (patient == null) return null; String ccG = null; if (!Boolean.TRUE.equals(ConfigFlag.DOM.GP_USE_SURGERIES.getValue())) { // 1 - Patient.Gp.practices.practice (with isDefault).PCTCode (this is a CCG so no lookup of CCGPCTPCCodes needed) // 2 - Patient.Gp.practices.practice (with isDefault).Address.Postcode if (patient.getGp() != null && patient.getGp().getPractices() != null) { for (GpToPracticesVo gpToPractice : patient.getGp().getPractices()) { if (Boolean.TRUE.equals(gpToPractice.getIsPrimaryPractice())) { // Case 1 if (gpToPractice.getPractice() != null && gpToPractice.getPractice().getPctCode() != null && gpToPractice.getPractice().getPctCode().trim().length() > 0) return gpToPractice.getPractice().getPctCode(); // Case 2 if (gpToPractice.getPractice() != null && gpToPractice.getPractice().getAddress() != null) { ccG = getCCGCodeFromPostCode(gpToPractice.getPractice().getAddress().getPostCode()); if (ccG != null) return ccG; } } } } } // 3 - Patient.gpSurgery.address.postcode if (patient.getGpSurgery() != null && patient.getGpSurgery().getAddress() != null) { ccG = getCCGCodeFromPostCode(patient.getGpSurgery().getAddress().getPostCode()); if (ccG != null) return ccG; } // 4 - Patient.Address.Postcode if (patient.getAddress() != null) { ccG = getCCGCodeFromPostCode(patient.getAddress().getPostCode()); if (ccG != null) return ccG; } return null; }
@Override public PatientWithGPForCCGVo getPatientForCCG(PatientRefVo patientRef) { BedAdmissionComponent implBedAdmissionComponent = (BedAdmissionComponent) getDomainImpl(BedAdmissionComponentImpl.class); return implBedAdmissionComponent.getPatientForCCG(patientRef);//WDEV-22214 }