Skip to content

Commit

Permalink
8456 pbf prac name (#174)
Browse files Browse the repository at this point in the history
* Added support for Prac name.
Improved formatting for multi rows.
Improved formatting for lower resolution.

* Fixed formatting error.

* Entity and unit test updates.

* Updated not null fields on entities.
Moved BcscPayeeMapping to default schema.
Fixed UI typo.

* Backend fixes.

* Added archived flag to PatientRegister queries.
Added support for null cancel date.
Fixed issues with auditing when message is absent.
Added unit tests.
Updated test data.

---------

Co-authored-by: weskubo-cgi <Wesley.Kubo@gov.bc.ca>
  • Loading branch information
weskubo-cgi and weskubo-cgi authored Feb 23, 2023
1 parent 5e75e20 commit 52d9cd0
Show file tree
Hide file tree
Showing 12 changed files with 294 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public ResponseEntity<PatientRegistrationResponse> getPatientRegistration(
Transaction transaction = transactionStart(request, TransactionType.GET_PATIENT_REGISTRATION);
addAffectedParty(transaction, IdentifierType.PHN, patientRegistrationRequest.getPhn(),
AffectedPartyDirection.INBOUND);
addAffectedParty(transaction, IdentifierType.PAYEE_NUMBER, patientRegistrationRequest.getPayee(),
AffectedPartyDirection.INBOUND);

try {
validatePayeeNumberMapping(patientRegistrationRequest);
Expand Down Expand Up @@ -122,8 +124,11 @@ public ResponseEntity<PatientRegistrationResponse> getPatientRegistration(
ResponseEntity<PatientRegistrationResponse> responseEntity = ResponseEntity.ok(response);

transactionComplete(transaction);
registrationRecords.forEach(record -> addAffectedParty(transaction, IdentifierType.PHN, record.getPhn(),
AffectedPartyDirection.OUTBOUND));
addAffectedParty(transaction, IdentifierType.PHN, personDetailsResponse.getPhn(), AffectedPartyDirection.OUTBOUND);
registrationRecords.forEach(record -> {
addAffectedParty(transaction, IdentifierType.PAYEE_NUMBER, record.getPayeeNumber(), AffectedPartyDirection.OUTBOUND);
addAffectedParty(transaction, IdentifierType.PRACTITIONER_NUMBER, record.getRegisteredPractitionerNumber(), AffectedPartyDirection.OUTBOUND);
});

return responseEntity;
} catch (Exception e) {
Expand Down Expand Up @@ -202,6 +207,9 @@ private List<PatientRegisterModel> convertPatientRegistration(List<PatientRegist
: patientRegistration.getDeregistrationReasonCode());
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);
Expand All @@ -212,6 +220,9 @@ private List<PatientRegisterModel> convertPatientRegistration(List<PatientRegist
}

private String formatDate(Date date) {
if (date == null) {
return null;
}
LocalDate localDate = convertDate(date);
return localDate.format(DATE_TIME_FORMATTER_yyyyMMdd);
}
Expand All @@ -223,8 +234,15 @@ private LocalDate convertDate(Date date) {
private String setPatientRegistrationStatus(Date cancelDate, Date effectiveDate) {
String currentStatus = "";
LocalDate today = LocalDate.now();
LocalDate convertedCancelDate = convertDate(cancelDate);
LocalDate convertedEffectiveDate = convertDate(effectiveDate);

LocalDate convertedCancelDate = null;
if (cancelDate != null) {
convertedCancelDate = convertDate(cancelDate);
} else {
// Default the cancelDate to end of time to simplify logic
convertedCancelDate = LocalDate.of(9999, 12, 31);
}

// “Registered” when the current date is greater than or equal to the effective
// date and less than or equal to the cancel date.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ public class PatientRegisterModel {

private String registeredPractitionerNumber;

private String registeredPractitionerFirstName;

private String registeredPractitionerMiddleName;

private String registeredPractitionerSurname;

private String effectiveDate;

private String cancelDate;
Expand All @@ -19,7 +25,7 @@ public class PatientRegisterModel {
private String deregistrationReasonCode;

private String cancelReasonCode;

private String currentStatus;

public String getPhn() {
Expand All @@ -46,6 +52,30 @@ public void setRegisteredPractitionerNumber(String registeredPractitionerNumber)
this.registeredPractitionerNumber = registeredPractitionerNumber;
}

public String getRegisteredPractitionerFirstName() {
return registeredPractitionerFirstName;
}

public void setRegisteredPractitionerFirstName(String registeredPractitionerFirstName) {
this.registeredPractitionerFirstName = registeredPractitionerFirstName;
}

public String getRegisteredPractitionerMiddleName() {
return registeredPractitionerMiddleName;
}

public void setRegisteredPractitionerMiddleName(String registeredPractitionerMiddleName) {
this.registeredPractitionerMiddleName = registeredPractitionerMiddleName;
}

public String getRegisteredPractitionerSurname() {
return registeredPractitionerSurname;
}

public void setRegisteredPractitionerSurname(String registeredPractitionerSurname) {
this.registeredPractitionerSurname = registeredPractitionerSurname;
}

public String getEffectiveDate() {
return effectiveDate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ public enum IdentifierType {
GROUP_NUMBER("Group Number"),
GROUP_MEMBER_NUMBER("Group Member Number"),
CONTRACT_NUMBER("Contract Number"),
DEPARTMENT_NUMBER("Department Number");
DEPARTMENT_NUMBER("Department Number"),
PAYEE_NUMBER("Payee Number"),
PRACTITIONER_NUMBER("Practitioner Number");

private String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
*
*/
@Entity
@Table(name = "bcsc_payee_mapping", schema = "pbf")
@Table(name = "bcsc_payee_mapping")
public class BcscPayeeMapping {

@Id
@Column(name = "bcsc_guid")
private String bcscGuid;

@Column(name = "msp_payee_number")
@Column(name = "msp_payee_number", nullable = false)
private String payeeNumber;

public String getBcscGuid() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ public class PBFClinicPayee {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long pbfClinicPayeeId;

@Column(name = "payee_number")
@Column(name = "payee_number", nullable = false)
private String payeeNumber;

@Column(name = "effective_date", nullable = false)
@Temporal(TemporalType.DATE)
private Date effectiveDate;

@Column(name = "cancel_date", nullable = false)
@Column(name = "cancel_date", nullable = true)
@Temporal(TemporalType.DATE)
private Date cancelDate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,33 @@ public class PatientRegister {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long patientRegisterId;

@Column(name = "phn")
@Column(name = "phn", nullable = false)
private String phn;

@Column(name = "payee_number")
@Column(name = "payee_number", nullable = false)
private String payeeNumber;

@Column(name = "registered_practitioner_number", nullable = false)
private String registeredPractitionerNumber;

@Column(name = "registered_practitioner_first_name", nullable = true)
private String registeredPractitionerFirstName;

@Column(name = "registered_practitioner_middle_name", nullable = true)
private String registeredPractitionerMiddleName;

@Column(name = "registered_practitioner_surname", nullable = true)
private String registeredPractitionerSurname;

@Column(name = "effective_date", nullable = false)
@Temporal(TemporalType.DATE)
private Date effectiveDate;

@Column(name = "cancel_date", nullable = false)
@Column(name = "cancel_date", nullable = true)
@Temporal(TemporalType.DATE)
private Date cancelDate;

@Column(name = "adminstrative_code", nullable = false)
@Column(name = "adminstrative_code", nullable = true)
private String administrativeCode;

@Column(name = "registration_reason_code", nullable = true)
Expand Down Expand Up @@ -84,6 +93,30 @@ public void setRegisteredPractitionerNumber(String registeredPractitionerNumber)
this.registeredPractitionerNumber = registeredPractitionerNumber;
}

public String getRegisteredPractitionerFirstName() {
return registeredPractitionerFirstName;
}

public void setRegisteredPractitionerFirstName(String registeredPractitionerFirstName) {
this.registeredPractitionerFirstName = registeredPractitionerFirstName;
}

public String getRegisteredPractitionerMiddleName() {
return registeredPractitionerMiddleName;
}

public void setRegisteredPractitionerMiddleName(String registeredPractitionerMiddleName) {
this.registeredPractitionerMiddleName = registeredPractitionerMiddleName;
}

public String getRegisteredPractitionerSurname() {
return registeredPractitionerSurname;
}

public void setRegisteredPractitionerSurname(String registeredPractitionerSurname) {
this.registeredPractitionerSurname = registeredPractitionerSurname;
}

public Date getEffectiveDate() {
return effectiveDate;
}
Expand Down Expand Up @@ -140,4 +173,15 @@ public void setArchived(Boolean archived) {
this.archived = archived;
}

@Override
public String toString() {
return "PatientRegister [patientRegisterId=" + patientRegisterId + ", phn=" + phn + ", payeeNumber=" + payeeNumber
+ ", registeredPractitionerNumber=" + registeredPractitionerNumber + ", registeredPractitionerFirstName="
+ registeredPractitionerFirstName + ", registeredPractitionerMiddleName=" + registeredPractitionerMiddleName
+ ", registeredPractitionerSurname=" + registeredPractitionerSurname + ", effectiveDate=" + effectiveDate + ", cancelDate="
+ cancelDate + ", administrativeCode=" + administrativeCode + ", registrationReasonCode=" + registrationReasonCode
+ ", deregistrationReasonCode=" + deregistrationReasonCode + ", cancelReasonCode=" + cancelReasonCode + ", archived="
+ archived + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

public interface PatientRegisterRepository extends JpaRepository<PatientRegister, Long> {

@Query("select p from PatientRegister p where p.payeeNumber in ("
@Query("select p from PatientRegister p where archived = false and p.payeeNumber in ("
+ "select p2.payeeNumber from PBFClinicPayee p1 inner join PBFClinicPayee p2 on p1.reportGroup = "
+ "p2.reportGroup where p1.payeeNumber= :payee ) and "
+ "p.phn = :phn ")
+ "p.phn = :phn order by p.effectiveDate desc" )
List<PatientRegister> findPatientRegisterByPayeeClinic(@Param("payee") String payee, @Param("phn") String phn);

@Query("select p.payeeNumber from PatientRegister p where p.phn = :phn")
@Query("select p.payeeNumber from PatientRegister p where p.phn = :phn and p.archived = false")
List<String> findPayeeByphn(@Param("phn") String phn);

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public class AuditService {

private static final CSVFormat FORMAT = CSVFormat.DEFAULT.withHeader(HEADERS);

private static final String MESSAGE_UNKNOWN = "Uknown";

@Autowired
private AffectedPartyRepository affectedPartyRepository;

Expand Down Expand Up @@ -201,7 +203,7 @@ public EventMessage createEventMessage(TransactionEvent transactionEvent, ErrorL
EventMessage eventMessage = new EventMessage();
eventMessage.setErrorCode(Integer.toString(status.value()));
eventMessage.setErrorLevel(level);
eventMessage.setMessageText(exception.getMessage());
eventMessage.setMessageText(StringUtils.defaultString(exception.getMessage(), MESSAGE_UNKNOWN));
eventMessage.setTransactionEvent(transactionEvent);
return eventMessageRepository.save(eventMessage);
}
Expand Down
Loading

0 comments on commit 52d9cd0

Please sign in to comment.