Skip to content

Commit

Permalink
Frontend and backend updates to add description to PBF reason codes. (#…
Browse files Browse the repository at this point in the history
…192)

* Frontend and backend updates to add description to PBF reason codes.

* Converted codes to upper case to deal with env variable issue.
Updates to nginx.conf.

* Fixed sha hashes.

---------

Co-authored-by: weskubo-cgi <Wesley.Kubo@gov.bc.ca>
  • Loading branch information
weskubo-cgi and weskubo-cgi authored Apr 28, 2023
1 parent e5a15e3 commit 858d93a
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private PatientRegistrationResponse handlePatientRegistrationResponse(
}

private List<PatientRegisterModel> convertPatientRegistration(List<PatientRegister> patientRegistrations) {
List<PatientRegisterModel> pateintRegisterModels = new ArrayList<>();
List<PatientRegisterModel> patientRegisterModels = new ArrayList<>();
patientRegistrations.forEach(patientRegistration -> {
PatientRegisterModel model = new PatientRegisterModel();

Expand All @@ -201,22 +201,25 @@ private List<PatientRegisterModel> convertPatientRegistration(List<PatientRegist
model.setRegistrationReasonCode(
StringUtils.isEmpty(patientRegistration.getRegistrationReasonCode()) ? NOT_APPLICABLE
: patientRegistration.getRegistrationReasonCode());
model.setRegistrationReasonDesc(patientRegistration.getRegistrationReasonDesc());
model.setCancelReasonCode(StringUtils.isEmpty(patientRegistration.getCancelReasonCode()) ? NOT_APPLICABLE
: patientRegistration.getCancelReasonCode());
model.setCancelReasonDesc(patientRegistration.getCancelReasonDesc());
model.setDeregistrationReasonCode(
StringUtils.isEmpty(patientRegistration.getDeregistrationReasonCode()) ? NOT_APPLICABLE
: patientRegistration.getDeregistrationReasonCode());
model.setDeregistrationReasonDesc(patientRegistration.getDeregistrationReasonDesc());
model.setPayeeNumber(patientRegistration.getPayeeNumber());
model.setRegisteredPractitionerNumber(patientRegistration.getRegisteredPractitionerNumber());
model.setRegisteredPractitionerFirstName(patientRegistration.getRegisteredPractitionerFirstName());
model.setRegisteredPractitionerMiddleName(patientRegistration.getRegisteredPractitionerMiddleName());
model.setRegisteredPractitionerSurname(patientRegistration.getRegisteredPractitionerSurname());
model.setPhn(patientRegistration.getPhn());

pateintRegisterModels.add(model);
patientRegisterModels.add(model);

});
return pateintRegisterModels;
return patientRegisterModels;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ public class PatientRegisterModel {

private String registrationReasonCode;

private String registrationReasonDesc;

private String deregistrationReasonCode;

private String deregistrationReasonDesc;

private String cancelReasonCode;

private String cancelReasonDesc;

private String currentStatus;

public String getPhn() {
Expand Down Expand Up @@ -131,4 +137,29 @@ public String getCurrentStatus() {
public void setCurrentStatus(String currentStatus) {
this.currentStatus = currentStatus;
}

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;
}

public String getCancelReasonDesc() {
return cancelReasonDesc;
}

public void setCancelReasonDesc(String cancelReasonDesc) {
this.cancelReasonDesc = cancelReasonDesc;
}

}
51 changes: 51 additions & 0 deletions backend/src/main/java/ca/bc/gov/hlth/hnweb/pbf/PBFProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package ca.bc.gov.hlth.hnweb.pbf;

import java.util.Map;
import java.util.stream.Collectors;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
* Contains maps for PBF properties including: Cancel Reason, Deregistration
* Reason, Registration Reason
*/
@Component
@ConfigurationProperties(prefix = "pbf")
public class PBFProperties {

private Map<String, String> cancelReasons;

private Map<String, String> deregistrationReasons;

private Map<String, String> registrationReasons;

public Map<String, String> getCancelReasons() {
return cancelReasons;
}

public void setCancelReasons(Map<String, String> cancelReasons) {
this.cancelReasons = uppercaseKeys(cancelReasons);
}

public Map<String, String> getDeregistrationReasons() {
return deregistrationReasons;
}

public void setDeregistrationReasons(Map<String, String> deregistrationReasons) {
this.deregistrationReasons = uppercaseKeys(deregistrationReasons);
}

public Map<String, String> getRegistrationReasons() {
return registrationReasons;
}

public void setRegistrationReasons(Map<String, String> registrationReasons) {
this.registrationReasons = uppercaseKeys(registrationReasons);
}

private Map<String, String> uppercaseKeys(Map<String, String> reasons) {
return reasons.entrySet().stream().collect(Collectors.toMap(e -> e.getKey().toUpperCase(), e -> e.getValue()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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() + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,6 +24,9 @@ public class PatientRegistrationService extends BaseService {

@Autowired
private PBFClinicPayeeRepository pbfClinicPayeeRepository;

@Autowired
private PBFProperties pbfProperties;

/**
* Gets a history of Patient Registration.
Expand Down Expand Up @@ -61,9 +65,26 @@ public RegistrationResult getPatientRegistration(String payee, String phn) {
// Filter out records from outside the reporting group
List<PatientRegister> 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()));
}
}

}
Loading

0 comments on commit 858d93a

Please sign in to comment.