Skip to content

Commit

Permalink
Merge branch '6994-develop-new-screen-for-pbf'
Browse files Browse the repository at this point in the history
  • Loading branch information
AnumehaSrivastava05 committed Sep 2, 2022
2 parents e68a587 + 77b194c commit a4ace5d
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
Expand Down Expand Up @@ -53,6 +54,10 @@ public class PatientRegistrationController extends BaseController {

private static final String NOT_APPLICABLE = "N/A";

private static final String DATE_FORMAT = "yyyyMMdd";

private static final DateTimeFormatter DATE_TIME_FORMATTER_yyyyMMdd = DateTimeFormatter.ofPattern(DATE_FORMAT);

private static final Logger logger = LoggerFactory.getLogger(PatientRegistrationController.class);

@Autowired
Expand Down Expand Up @@ -150,9 +155,10 @@ private List<PatientRegisterModel> convertPatientRegistration(List<PatientRegist
patientRegistrations.forEach(patientRegistration -> {
PatientRegisterModel model = new PatientRegisterModel();

model.setEffectiveDate(convertDate(patientRegistration.getEffectiveDate()));
model.setCancelDate(convertDate(patientRegistration.getCancelDate()));
model.setCurrentStatus(setPatientRegistrationStatus(model.getCancelDate(), model.getEffectiveDate()));
model.setEffectiveDate(formatDate(patientRegistration.getEffectiveDate()));
model.setCancelDate(formatDate(patientRegistration.getCancelDate()));
model.setCurrentStatus(setPatientRegistrationStatus(patientRegistration.getCancelDate(),
patientRegistration.getEffectiveDate()));
model.setAdministrativeCode(patientRegistration.getAdministrativeCode());
model.setRegistrationReasonCode(
StringUtils.isEmpty(patientRegistration.getRegistrationReasonCode()) ? NOT_APPLICABLE
Expand All @@ -173,25 +179,32 @@ private List<PatientRegisterModel> convertPatientRegistration(List<PatientRegist

}

private String formatDate(Date date) {
LocalDate localDate = convertDate(date);
return localDate.format(DATE_TIME_FORMATTER_yyyyMMdd);
}

private LocalDate convertDate(Date date) {
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
}

private String setPatientRegistrationStatus(LocalDate cancelDate, LocalDate effectiveDate) {
private String setPatientRegistrationStatus(Date cancelDate, Date effectiveDate) {
String currentStatus = "";
LocalDate today = LocalDate.now();
LocalDate convertedCancelDate = convertDate(cancelDate);
LocalDate convertedEffectiveDate = convertDate(effectiveDate);

// “Registered” when the current date is greater than or equal to the effective
// date and less than or equal to the cancel date.
// “De-Registered” when the current date is later than the registration cancel
// date
// “Future Registration” when the registration date is in the future

if (today.compareTo(effectiveDate) >= 0 && today.compareTo(cancelDate) <= 0) {
if (today.compareTo(convertedEffectiveDate) >= 0 && today.compareTo(convertedCancelDate) <= 0) {
currentStatus = REGISTERED;
} else if (today.compareTo(cancelDate) > 0) {
} else if (today.compareTo(convertedCancelDate) > 0) {
currentStatus = DE_REGISTERED;
} else if (effectiveDate.compareTo(today) > 0) {
} else if (convertedEffectiveDate.compareTo(today) > 0) {
currentStatus = FUTURE_REGISTRATION;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ private void buildPersonDetails(GetDemographicsResponse demographicsResponse,
personDetailsResponse.setSurname(nameObj.getSurname());

String birthDate = V3MessageUtil.convertDateToString(demographicsResponse.getPerson().getBirthDate());
personDetailsResponse.setDateOfBirth(birthDate);
String deathDate = demographicsResponse.getPerson().getDeathDate() != null ? V3MessageUtil.convertDateToString(demographicsResponse.getPerson().getDeathDate()) :"N/A";
personDetailsResponse.setDateOfBirth(birthDate);
personDetailsResponse.setDateOfDeath(deathDate);
personDetailsResponse.setGender(demographicsResponse.getPerson().getGender());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class GetPersonDetailsResponse extends BaseResponse {

private String dateOfBirth;

private String dateOfDeath;

private String gender;

public String getPhn() {
Expand Down Expand Up @@ -59,6 +61,14 @@ public void setDateOfBirth(String dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}

public String getDateOfDeath() {
return dateOfDeath;
}

public void setDateOfDeath(String dateOfDeath) {
this.dateOfDeath = dateOfDeath;
}

public String getGender() {
return gender;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package ca.bc.gov.hlth.hnweb.model.rest.patientregistration;

import java.time.LocalDate;

public class PatientRegisterModel {

private String phn;
Expand All @@ -10,9 +8,9 @@ public class PatientRegisterModel {

private String registeredPractitionerNumber;

private LocalDate effectiveDate;
private String effectiveDate;

private LocalDate cancelDate;
private String cancelDate;

private String administrativeCode;

Expand Down Expand Up @@ -48,19 +46,19 @@ public void setRegisteredPractitionerNumber(String registeredPractitionerNumber)
this.registeredPractitionerNumber = registeredPractitionerNumber;
}

public LocalDate getEffectiveDate() {
public String getEffectiveDate() {
return effectiveDate;
}

public void setEffectiveDate(LocalDate effectiveDate) {
public void setEffectiveDate(String effectiveDate) {
this.effectiveDate = effectiveDate;
}

public LocalDate getCancelDate() {
public String getCancelDate() {
return cancelDate;
}

public void setCancelDate(LocalDate cancelDate) {
public void setCancelDate(String cancelDate) {
this.cancelDate = cancelDate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ protected void configure(HttpSecurity http) throws Exception {
.cors(Customizer.withDefaults())
.authorizeRequests()
.mvcMatchers(HttpMethod.GET, "/docs/**").permitAll()
.mvcMatchers(HttpMethod.GET, "/bulletins").fullyAuthenticated()
.mvcMatchers(HttpMethod.GET, "/bulletins").fullyAuthenticated()
.mvcMatchers(HttpMethod.POST, "/patient-registration/get-patient-registration").hasRole("PatientRegistration")
.mvcMatchers(HttpMethod.POST, "/eligibility/check-msp-coverage-status").hasRole("MSPCoverageCheck")
.mvcMatchers(HttpMethod.POST, "/eligibility/check-eligibility").hasRole("CheckEligibility")
.mvcMatchers(HttpMethod.POST, "/eligibility/inquire-phn").hasRole("PHNInquiry")
Expand Down
1 change: 1 addition & 0 deletions frontend/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const createRoutes = (app) => [
name: 'PatientRegistration',
component: ViewPatientRegistration,
meta: {
permission: 'PatientRegistration',
requiresAuth: true,
},
},
Expand Down
42 changes: 35 additions & 7 deletions frontend/src/views/patientregistration/ViewPatientRegistration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<h1>Patient Registration</h1>
<AppHelp>
<p>This shows a patient registration history using a patient's PHN and MSP Payee information.</p>
<p>Enter the individual's 10 digit PHN. The PHN is a mandatory field, if you leave it blank or enter invalid characters, an edit error message will be displayed.</p>
<p>The MSP Payee number is automatically assigned as part of the permissions the user is given during account creation.</p>
<p>It returns patient demographic and registration history, including registration and de-registration dates, and additional information.</p>
<p>It returns patient demographic and the registration history, including registration and de-registration dates, and additional information.</p>
</AppHelp>
<div>
<form @submit.prevent="submitForm">
Expand Down Expand Up @@ -35,16 +34,18 @@
<AppOutput label="PHN" :value="result.personDetail.phn" />
</AppCol>
<AppCol class="col2">
<AppOutput label="Patient" :value="result.personDetail.givenName" />
<AppOutput label="Patient" :value="fullName" />
</AppCol>
<AppCol class="col2">
<AppOutput label="BirthDate" :value="result.personDetail.dateOfBirth" />
<AppOutput label="Birth Date" :value="result.personDetail.dateOfBirth" />
</AppCol>
<AppCol class="col3">
<AppOutput label="DeathDate" :value="result.personDetail.dateOfDeath" />
<AppOutput label="Death Date" :value="result.personDetail.dateOfDeath">
<template #tooltip>Will display death date in ccyymmdd format, or N/A if person is living.</template>
</AppOutput>
</AppCol>
<AppCol class="col2">
<AppOutput label="Gender" :value="result.personDetail.gender" />
<AppOutput label="Gender" :value="gender" />
</AppCol>
</AppRow>
</div>
Expand All @@ -59,7 +60,9 @@
<AppOutput label="Payee" />
</AppCol>
<AppCol class="col2">
<AppOutput label="Reg/DeReg Date" />
<AppOutput label="Reg/DeReg Date">
<template #tooltip>ccyymmdd</template>
</AppOutput>
</AppCol>
<AppCol class="col2">
<AppOutput label="Current Status" />
Expand Down Expand Up @@ -133,6 +136,31 @@ export default {
this.payee = 'A0053'
},
computed: {
fullName() {
let name = ''
if (this.result.personDetail.surname) {
name = name + this.result.personDetail.surname
}
if (this.result.personDetail.givenName) {
name = name + ', ' + this.result.personDetail.givenName
}
return name
},
gender() {
switch (this.result.personDetail.gender) {
case 'M':
return 'Male'
case 'F':
return 'Female'
case 'U':
return 'Unknown'
default:
return ''
}
},
},
methods: {
async submitForm() {
this.result = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ test('Check properly filled form passes validation and validate results', async

test('Check Patient registered with a different msp payee within group', async (t) => {
await t
.click(ViewPatientRegistrationPage.clearButton)
// Given the page is filled out correctly
.typeText(ViewPatientRegistrationPage.phnInput, '9879869673')
.selectText(ViewPatientRegistrationPage.payeeInput)
.pressKey('delete')
.typeText(ViewPatientRegistrationPage.payeeInput, 'A0248')
// When I click the submit button
.click(ViewPatientRegistrationPage.submitButton)
Expand Down Expand Up @@ -208,5 +209,5 @@ test('Check clear button clears the form', async (t) => {
.expect(ViewPatientRegistrationPage.phnInput.value)
.eql('')
.expect(ViewPatientRegistrationPage.payeeInput.value)
.eql('')
.notEql('')
})

0 comments on commit a4ace5d

Please sign in to comment.