diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/controller/PatientRegistrationController.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/controller/PatientRegistrationController.java index b551a019..331c6ecc 100644 --- a/backend/src/main/java/ca/bc/gov/hlth/hnweb/controller/PatientRegistrationController.java +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/controller/PatientRegistrationController.java @@ -189,7 +189,7 @@ private PatientRegistrationResponse handlePatientRegistrationResponse( } private List convertPatientRegistration(List patientRegistrations) { - List pateintRegisterModels = new ArrayList<>(); + List patientRegisterModels = new ArrayList<>(); patientRegistrations.forEach(patientRegistration -> { PatientRegisterModel model = new PatientRegisterModel(); @@ -201,11 +201,14 @@ private List convertPatientRegistration(List convertPatientRegistration(List cancelReasons; + + private Map deregistrationReasons; + + private Map registrationReasons; + + public Map getCancelReasons() { + return cancelReasons; + } + + public void setCancelReasons(Map cancelReasons) { + this.cancelReasons = uppercaseKeys(cancelReasons); + } + + public Map getDeregistrationReasons() { + return deregistrationReasons; + } + + public void setDeregistrationReasons(Map deregistrationReasons) { + this.deregistrationReasons = uppercaseKeys(deregistrationReasons); + } + + public Map getRegistrationReasons() { + return registrationReasons; + } + + public void setRegistrationReasons(Map registrationReasons) { + this.registrationReasons = uppercaseKeys(registrationReasons); + } + + private Map uppercaseKeys(Map reasons) { + return reasons.entrySet().stream().collect(Collectors.toMap(e -> e.getKey().toUpperCase(), e -> e.getValue())); + } + +} diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/persistence/entity/pbf/PatientRegister.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/persistence/entity/pbf/PatientRegister.java index ef8f2d70..cbcc2ce8 100644 --- a/backend/src/main/java/ca/bc/gov/hlth/hnweb/persistence/entity/pbf/PatientRegister.java +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/persistence/entity/pbf/PatientRegister.java @@ -10,6 +10,7 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import javax.persistence.Transient; @Entity @Table(name = "patient_register", schema = "pbf") @@ -61,6 +62,15 @@ public class PatientRegister { @Column(name = "archived", nullable = false) private Boolean archived = Boolean.FALSE; + @Transient + private String cancelReasonDesc; + + @Transient + private String registrationReasonDesc; + + @Transient + private String deregistrationReasonDesc; + public Long getPatientRegisterId() { return patientRegisterId; } @@ -173,6 +183,30 @@ public void setArchived(Boolean archived) { this.archived = archived; } + public String getCancelReasonDesc() { + return cancelReasonDesc; + } + + public void setCancelReasonDesc(String cancelReasonDesc) { + this.cancelReasonDesc = cancelReasonDesc; + } + + public String getRegistrationReasonDesc() { + return registrationReasonDesc; + } + + public void setRegistrationReasonDesc(String registrationReasonDesc) { + this.registrationReasonDesc = registrationReasonDesc; + } + + public String getDeregistrationReasonDesc() { + return deregistrationReasonDesc; + } + + public void setDeregistrationReasonDesc(String deregistrationReasonDesc) { + this.deregistrationReasonDesc = deregistrationReasonDesc; + } + @Override public String toString() { return "PatientRegister [patientRegisterId=" + patientRegisterId + ", phn=" + phn + ", payeeNumber=" + payeeNumber @@ -181,7 +215,18 @@ public String toString() { + ", registeredPractitionerSurname=" + registeredPractitionerSurname + ", effectiveDate=" + effectiveDate + ", cancelDate=" + cancelDate + ", administrativeCode=" + administrativeCode + ", registrationReasonCode=" + registrationReasonCode + ", deregistrationReasonCode=" + deregistrationReasonCode + ", cancelReasonCode=" + cancelReasonCode + ", archived=" - + archived + "]"; + + archived + ", cancelReasonDes=" + cancelReasonDesc + ", registrationReasonDesc=" + registrationReasonDesc + + ", deregistrationReasonDesc=" + deregistrationReasonDesc + ", getPatientRegisterId()=" + getPatientRegisterId() + + ", getPhn()=" + getPhn() + ", getPayeeNumber()=" + getPayeeNumber() + ", getRegisteredPractitionerNumber()=" + + getRegisteredPractitionerNumber() + ", getRegisteredPractitionerFirstName()=" + getRegisteredPractitionerFirstName() + + ", getRegisteredPractitionerMiddleName()=" + getRegisteredPractitionerMiddleName() + + ", getRegisteredPractitionerSurname()=" + getRegisteredPractitionerSurname() + ", getEffectiveDate()=" + + getEffectiveDate() + ", getCancelDate()=" + getCancelDate() + ", getAdministrativeCode()=" + getAdministrativeCode() + + ", getRegistrationReasonCode()=" + getRegistrationReasonCode() + ", getDeregistrationReasonCode()=" + + getDeregistrationReasonCode() + ", getCancelReasonCode()=" + getCancelReasonCode() + ", getArchived()=" + getArchived() + + ", getCancelReasonDes()=" + getCancelReasonDesc() + ", getRegistrationReasonDesc()=" + getRegistrationReasonDesc() + + ", getDeregistrationReasonDesc()=" + getDeregistrationReasonDesc() + ", getClass()=" + getClass() + ", hashCode()=" + + hashCode() + ", toString()=" + super.toString() + "]"; } } \ No newline at end of file diff --git a/backend/src/main/java/ca/bc/gov/hlth/hnweb/service/PatientRegistrationService.java b/backend/src/main/java/ca/bc/gov/hlth/hnweb/service/PatientRegistrationService.java index 88b6c8c4..445d95cb 100644 --- a/backend/src/main/java/ca/bc/gov/hlth/hnweb/service/PatientRegistrationService.java +++ b/backend/src/main/java/ca/bc/gov/hlth/hnweb/service/PatientRegistrationService.java @@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import ca.bc.gov.hlth.hnweb.pbf.PBFProperties; import ca.bc.gov.hlth.hnweb.persistence.entity.pbf.PatientRegister; import ca.bc.gov.hlth.hnweb.persistence.repository.pbf.PBFClinicPayeeRepository; import ca.bc.gov.hlth.hnweb.persistence.repository.pbf.PatientRegisterRepository; @@ -23,6 +24,9 @@ public class PatientRegistrationService extends BaseService { @Autowired private PBFClinicPayeeRepository pbfClinicPayeeRepository; + + @Autowired + private PBFProperties pbfProperties; /** * Gets a history of Patient Registration. @@ -61,9 +65,26 @@ public RegistrationResult getPatientRegistration(String payee, String phn) { // Filter out records from outside the reporting group List filteredPatientRegisters = patientRegisters.stream().filter(pr -> validPayees.contains(pr.getPayeeNumber())).collect(Collectors.toList()); + // Populate descriptions + filteredPatientRegisters.forEach(pr -> { + populateDescriptions(pr); + }); + result.setPatientRegisters(filteredPatientRegisters); result.setRegistrationMessage(registrationMessage); return result; } + private void populateDescriptions(PatientRegister patientRegister) { + if (StringUtils.isNotEmpty(patientRegister.getCancelReasonCode())) { + patientRegister.setCancelReasonDesc(pbfProperties.getCancelReasons().get(patientRegister.getCancelReasonCode().toUpperCase())); + } + if (StringUtils.isNotEmpty(patientRegister.getDeregistrationReasonCode())) { + patientRegister.setDeregistrationReasonDesc(pbfProperties.getDeregistrationReasons().get(patientRegister.getDeregistrationReasonCode().toUpperCase())); + } + if (StringUtils.isNotEmpty(patientRegister.getRegistrationReasonCode())) { + patientRegister.setRegistrationReasonDesc(pbfProperties.getRegistrationReasons().get(patientRegister.getRegistrationReasonCode().toUpperCase())); + } + } + } diff --git a/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/PatientRegistrationControllerTest.java b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/PatientRegistrationControllerTest.java index 56064df1..12deb8da 100644 --- a/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/PatientRegistrationControllerTest.java +++ b/backend/src/test/java/ca/bc/gov/hlth/hnweb/controller/PatientRegistrationControllerTest.java @@ -367,16 +367,54 @@ public void testRegistrationHistory_archived() throws Exception { assertEquals(StatusEnum.WARNING, patientRegistrationResponse.getStatus()); assertEquals(0, patientRegistrationHistory.size()); } + + @Test + public void testRegistrationHistory_success_reasonDescriptions() throws Exception { + createPBFClinicPayee(); + createPatientRegister(); + mockBackEnd.enqueue(new MockResponse() + .setBody(TestUtil.convertXMLFileToString("src/test/resources/GetDemographicsResponse.xml")) + .addHeader(CONTENT_TYPE, MediaType.TEXT_XML_VALUE.toString())); + + //Override the base setup of the user to ensure we return the User with the User ID mapped to the this Payee Number + mockStatic.when(SecurityUtil::loadUserInfo).thenReturn(new UserInfo("unittest", "924917e3-970a-482d-88b5-244be4c19d70", "00000010", "Ministry of Health", "hnweb-user", UUID.randomUUID().toString())); + + PatientRegistrationRequest viewPatientRegisterRequest = new PatientRegistrationRequest(); + viewPatientRegisterRequest.setPhn("7363117305"); + viewPatientRegisterRequest.setPayee("X0053"); + ResponseEntity response = patientRegistrationController + .getPatientRegistration(viewPatientRegisterRequest, createHttpServletRequest()); + + assertEquals(HttpStatus.OK, response.getStatusCode()); + PatientRegistrationResponse patientRegistrationResponse = response.getBody(); + List patientRegistrationHistory = patientRegistrationResponse + .getPatientRegistrationHistory(); + + // Check the additional message , status and number of valid records + assertEquals(StatusEnum.SUCCESS, patientRegistrationResponse.getStatus()); + assertEquals(1, patientRegistrationHistory.size()); + + PatientRegisterModel patientRegister = patientRegistrationHistory.get(0); + assertEquals("0", patientRegister.getAdministrativeCode()); + assertEquals("99991231", patientRegister.getCancelDate()); + assertEquals("A", patientRegister.getCancelReasonCode()); + assertEquals("CANCELLED", patientRegister.getCancelReasonDesc()); + assertEquals("Registered", patientRegister.getCurrentStatus()); + assertEquals("A0", patientRegister.getDeregistrationReasonCode()); + assertEquals("DECEASED", patientRegister.getDeregistrationReasonDesc()); + assertEquals("01", patientRegister.getRegistrationReasonCode()); + assertEquals("LIVES IN CATCHMENT AREA", patientRegister.getRegistrationReasonDesc()); + } private void createPatientRegister() throws ParseException { SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); + + Date cancelDate = format.parse("99991231"); PatientRegister patientRegister1 = new PatientRegister(); patientRegister1.setAdministrativeCode("0"); - Date effectiveDate1 = format.parse("20210705"); - patientRegister1.setEffectiveDate(effectiveDate1); - Date cancelDate1 = format.parse("99991231"); - patientRegister1.setCancelDate(cancelDate1); + patientRegister1.setEffectiveDate(format.parse("20210705")); + patientRegister1.setCancelDate(cancelDate); patientRegister1.setCancelReasonCode("Q"); patientRegister1.setRegistrationReasonCode("SL"); patientRegister1.setPayeeNumber("T0055"); @@ -391,10 +429,8 @@ private void createPatientRegister() throws ParseException { PatientRegister patientRegister2 = new PatientRegister(); patientRegister2.setAdministrativeCode("0"); - Date effectiveDate2 = format.parse("20210705"); - patientRegister2.setEffectiveDate(effectiveDate2); - Date cancelDate2 = format.parse("99991231"); - patientRegister2.setCancelDate(cancelDate2); + patientRegister2.setEffectiveDate(format.parse("20210705")); + patientRegister2.setCancelDate(cancelDate); patientRegister2.setRegistrationReasonCode("SL"); patientRegister2.setPayeeNumber("T0053"); patientRegister2.setRegisteredPractitionerNumber("X2753"); @@ -406,10 +442,8 @@ private void createPatientRegister() throws ParseException { PatientRegister patientRegister3 = new PatientRegister(); patientRegister3.setAdministrativeCode("0"); - Date effectiveDate3 = format.parse("20210705"); - patientRegister3.setEffectiveDate(effectiveDate3); - Date cancelDate3 = format.parse("99991231"); - patientRegister3.setCancelDate(cancelDate3); + patientRegister3.setEffectiveDate(format.parse("20210705")); + patientRegister3.setCancelDate(cancelDate); patientRegister3.setRegistrationReasonCode("SL"); patientRegister3.setPayeeNumber("T0053"); patientRegister3.setRegisteredPractitionerNumber("X2753"); @@ -421,10 +455,8 @@ private void createPatientRegister() throws ParseException { PatientRegister patientRegister4 = new PatientRegister(); patientRegister4.setAdministrativeCode("0"); - Date effectiveDate4 = format.parse("20210705"); - patientRegister4.setEffectiveDate(effectiveDate4); - Date cancelDate4 = format.parse("99991231"); - patientRegister4.setCancelDate(cancelDate4); + patientRegister4.setEffectiveDate(format.parse("20210705")); + patientRegister4.setCancelDate(cancelDate); patientRegister4.setRegistrationReasonCode("SL"); patientRegister4.setPayeeNumber("X0058"); patientRegister4.setRegisteredPractitionerNumber("X2753"); @@ -436,10 +468,8 @@ private void createPatientRegister() throws ParseException { PatientRegister patientRegister5 = new PatientRegister(); patientRegister5.setAdministrativeCode("0"); - Date effectiveDate5 = format.parse("20210705"); - patientRegister5.setEffectiveDate(effectiveDate5); - Date cancelDate5 = format.parse("99991231"); - patientRegister5.setCancelDate(cancelDate5); + patientRegister5.setEffectiveDate(format.parse("20210705")); + patientRegister5.setCancelDate(cancelDate); patientRegister5.setRegistrationReasonCode("SL"); patientRegister5.setPayeeNumber("X0053"); patientRegister5.setRegisteredPractitionerNumber("X2753"); @@ -451,8 +481,7 @@ private void createPatientRegister() throws ParseException { PatientRegister patientRegister6 = new PatientRegister(); patientRegister6.setAdministrativeCode("0"); - Date effectiveDate6 = format.parse("20230101"); - patientRegister6.setEffectiveDate(effectiveDate6); + patientRegister6.setEffectiveDate(format.parse("20230101")); patientRegister6.setCancelDate(null); patientRegister6.setRegistrationReasonCode("SL"); patientRegister6.setPayeeNumber("X0053"); @@ -465,8 +494,7 @@ private void createPatientRegister() throws ParseException { PatientRegister patientRegister7 = new PatientRegister(); patientRegister7.setAdministrativeCode("0"); - Date effectiveDate7 = format.parse("20230101"); - patientRegister7.setEffectiveDate(effectiveDate7); + patientRegister7.setEffectiveDate(format.parse("20230101")); patientRegister7.setCancelDate(null); patientRegister7.setRegistrationReasonCode("SL"); patientRegister7.setPayeeNumber("T0053"); @@ -479,8 +507,7 @@ private void createPatientRegister() throws ParseException { PatientRegister patientRegister8 = new PatientRegister(); patientRegister8.setAdministrativeCode("0"); - Date effectiveDate8 = format.parse("20240101"); - patientRegister8.setEffectiveDate(effectiveDate8); + patientRegister8.setEffectiveDate(format.parse("20240101")); patientRegister8.setCancelDate(null); patientRegister8.setRegistrationReasonCode("SL"); patientRegister8.setPayeeNumber("X0053"); @@ -490,6 +517,23 @@ private void createPatientRegister() throws ParseException { patientRegister8.setRegisteredPractitionerSurname("Thomas"); patientRegister8.setArchived(Boolean.FALSE); patientRegister8.setPhn("7363117304"); + + // This record is somewhat artificial in that all the reason codes are set + // It's just used for testing description mapping + PatientRegister patientRegister9 = new PatientRegister(); + patientRegister9.setAdministrativeCode("0"); + patientRegister9.setEffectiveDate(format.parse("20230101")); + patientRegister9.setCancelDate(cancelDate); + patientRegister9.setCancelReasonCode("A"); + patientRegister9.setDeregistrationReasonCode("A0"); + patientRegister9.setRegistrationReasonCode("01"); + patientRegister9.setPayeeNumber("X0053"); + patientRegister9.setRegisteredPractitionerNumber("X2753"); + patientRegister9.setRegisteredPractitionerFirstName("Sam"); + patientRegister9.setRegisteredPractitionerMiddleName("E"); + patientRegister9.setRegisteredPractitionerSurname("Thomas"); + patientRegister9.setArchived(Boolean.FALSE); + patientRegister9.setPhn("7363117305"); patientRegisterRepository.save(patientRegister1); patientRegisterRepository.save(patientRegister2); @@ -499,6 +543,7 @@ private void createPatientRegister() throws ParseException { patientRegisterRepository.save(patientRegister6); patientRegisterRepository.save(patientRegister7); patientRegisterRepository.save(patientRegister8); + patientRegisterRepository.save(patientRegister9); } private void createPBFClinicPayee() { diff --git a/backend/src/test/resources/application-dev.yaml b/backend/src/test/resources/application-dev.yaml index dc8caed7..0b285c80 100644 --- a/backend/src/test/resources/application-dev.yaml +++ b/backend/src/test/resources/application-dev.yaml @@ -118,4 +118,13 @@ security: - ExtendCancelDate - AddPermitHolderWOPHN - AddPermitHolderWithPHN - - AuditReporting \ No newline at end of file + - AuditReporting + +# PBF reason code tables +pbf: + cancelReasons: + A: CANCELLED + deregistrationReasons: + A0: DECEASED + registrationReasons: + "01": LIVES IN CATCHMENT AREA \ No newline at end of file diff --git a/frontend/.nginx/nginx.conf b/frontend/.nginx/nginx.conf index d7388adf..3e734766 100644 --- a/frontend/.nginx/nginx.conf +++ b/frontend/.nginx/nginx.conf @@ -58,7 +58,7 @@ http { add_header X-Content-Type-Options nosniff; add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload'; add_header X-XSS-Protection "1; mode=block"; - add_header Content-Security-Policy "default-src 'self'; connect-src https://*.gov.bc.ca; font-src *;img-src * data:; script-src * 'sha256-uS7/g9fhQwNZS1f/MqYqqKv8y9hCu36IfX9XZB5L7YY=' 'sha256-4m6wOIrq/wFDmi9Xh3mFM2mwI4ik9n3TMgHk6xDtLxk='; style-src * 'sha256-0UTAjn9qJ2+s9AJRZe0Ycl2l+R8GUq+2ZN5DSItWUzo' 'sha256-YU2XW0vVslSGNLLvr2p8c1rK8ZEmd7G+OK0USOToEGs=' 'sha256-ShuEs10HLgCAclz19DAh9OFR4QAZ48fjNAaJ34xfGSk=' 'sha256-fGxkcaQ6Z/i2bi5qKNuJwsclUB391Cn5S2lb5B51AIU=' 'sha256-4+0mt1YoMq+J1WxaN93MYonQ/Hh6YnEeREn78nw1K54=' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' 'sha256-MBVp6JYxbC/wICelYC6eULCRpgi9kGezXXSaq/TS2+I=' 'sha256-utjbDbVPbU5y3EebkVnX7axzZoghI+nz5IQPPznOdYQ=' 'sha256-AeReE7Ma/1yl7yFczYpMbCHhyrMims0SXYdn3Z2TAQI='; "; + add_header Content-Security-Policy "default-src 'self'; connect-src https://*.gov.bc.ca; font-src *;img-src * data:; script-src * 'sha256-uS7/g9fhQwNZS1f/MqYqqKv8y9hCu36IfX9XZB5L7YY=' 'sha256-4m6wOIrq/wFDmi9Xh3mFM2mwI4ik9n3TMgHk6xDtLxk='; style-src * 'sha256-0UTAjn9qJ2+s9AJRZe0Ycl2l+R8GUq+2ZN5DSItWUzo' 'sha256-YU2XW0vVslSGNLLvr2p8c1rK8ZEmd7G+OK0USOToEGs=' 'sha256-ShuEs10HLgCAclz19DAh9OFR4QAZ48fjNAaJ34xfGSk=' 'sha256-fGxkcaQ6Z/i2bi5qKNuJwsclUB391Cn5S2lb5B51AIU=' 'sha256-4+0mt1YoMq+J1WxaN93MYonQ/Hh6YnEeREn78nw1K54=' 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' 'sha256-MBVp6JYxbC/wICelYC6eULCRpgi9kGezXXSaq/TS2+I=' 'sha256-utjbDbVPbU5y3EebkVnX7axzZoghI+nz5IQPPznOdYQ=' 'sha256-AeReE7Ma/1yl7yFczYpMbCHhyrMims0SXYdn3Z2TAQI=' 'sha256-gKpQMMSZTSQsa1l8h8MnFRNmcuzw5kwdeF8CmuhOgXk=' 'sha256-4YPj4R1kppk6JCxy2dHYiheFZ84MlTcmgROd8BB8fLE='; "; add_header Referrer-Policy "strict-origin"; add_header X-Frame-Options "SAMEORIGIN"; } diff --git a/frontend/src/components/patientregistration/PatientRegistrationDetails.vue b/frontend/src/components/patientregistration/PatientRegistrationDetails.vue index 64e5627b..0a837615 100644 --- a/frontend/src/components/patientregistration/PatientRegistrationDetails.vue +++ b/frontend/src/components/patientregistration/PatientRegistrationDetails.vue @@ -5,7 +5,7 @@ - +
@@ -27,16 +27,43 @@ export default { data = `${data} Practitioner Name: ${this.practitionerName}
` } if (this.registration.registrationReasonCode) { - data = `${data} Reg Reason: ${this.registration.registrationReasonCode}
` + data = `${data} Reg Reason: ${this.registrationReason}
` } if (this.registration.deregistrationReasonCode) { - data = `${data} DeReg Reason: ${this.registration.deregistrationReasonCode}
` + data = `${data} DeReg Reason: ${this.deregistrationReason}
` } if (this.registration.cancelReasonCode) { - data = `${data} Cancel Reason: ${this.registration.cancelReasonCode}
` + data = `${data} Cancel Reason: ${this.cancelReason}
` } return data }, + cancelReason() { + let cancelReason = this.registration.cancelReasonCode + if (cancelReason !== 'N/A') { + if (this.registration.cancelReasonDesc) { + cancelReason = cancelReason + ' - ' + this.registration.cancelReasonDesc + } + } + return cancelReason + }, + deregistrationReason() { + let deregistrationReason = this.registration.deregistrationReasonCode + if (deregistrationReason !== 'N/A') { + if (this.registration.deregistrationReasonDesc) { + deregistrationReason = deregistrationReason + ' - ' + this.registration.deregistrationReasonDesc + } + } + return deregistrationReason + }, + registrationReason() { + let registrationReason = this.registration.registrationReasonCode + if (registrationReason !== 'N/A') { + if (this.registration.registrationReasonDesc) { + registrationReason = registrationReason + ' - ' + this.registration.registrationReasonDesc + } + } + return registrationReason + }, practitionerName() { let name = '' if (this.registration.registeredPractitionerSurname) { diff --git a/frontend/src/views/patientregistration/ViewPatientRegistration.vue b/frontend/src/views/patientregistration/ViewPatientRegistration.vue index ee5372b3..0f93c7dc 100644 --- a/frontend/src/views/patientregistration/ViewPatientRegistration.vue +++ b/frontend/src/views/patientregistration/ViewPatientRegistration.vue @@ -70,7 +70,7 @@ - +