Skip to content

Commit

Permalink
Added provider license and provider license expiry date for SHA Healt…
Browse files Browse the repository at this point in the history
…h Care worker verification
  • Loading branch information
patryllus committed Jun 19, 2024
1 parent f1c3f3e commit c66bff3
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.openmrs.PatientIdentifierType.LocationBehavior;
import org.openmrs.api.context.Context;
import org.openmrs.PersonAttributeType;
import org.openmrs.customdatatype.CustomDatatype;
import org.openmrs.customdatatype.datatype.DateDatatype;
import org.openmrs.module.idgen.validator.LuhnMod25IdentifierValidator;
import org.openmrs.module.kenyaemr.EmrConstants;
import org.openmrs.module.kenyaemr.Metadata;
Expand All @@ -23,6 +25,8 @@
import org.openmrs.customdatatype.datatype.FreeTextDatatype;
import org.openmrs.customdatatype.datatype.ConceptDatatype;

import java.util.Date;

import static org.openmrs.module.metadatadeploy.bundle.CoreConstructors.encounterType;
import static org.openmrs.module.metadatadeploy.bundle.CoreConstructors.form;
import static org.openmrs.module.metadatadeploy.bundle.CoreConstructors.globalProperty;
Expand Down Expand Up @@ -154,6 +158,8 @@ public static final class _Provider {

public static final class _ProviderAttributeType {
public static final String PRIMARY_FACILITY = "5a53dddd-b382-4245-9bf1-03bce973f24b";
public static final String LICENSE_NUMBER = "bcaaa67b-cc72-4662-90c2-e1e992ceda66";
public static final String LICENSE_EXPIRY_DATE = "00539959-a1c7-4848-a5ed-8941e9d5e835";
}

public static final class _RelationshipType {
Expand Down Expand Up @@ -379,7 +385,9 @@ public void install() {
String.class, null, false, 4.5, _PersonAttributeType.DUPLICATE_NUPI_TOTALSITES_WITH_NATIONAL_REGISTRY));

// Provider attribute types.
install(providerAttributeType("Primary Facility", "Default facility for a provider", LocationDatatype.class, "", 0, 9999 , _ProviderAttributeType.PRIMARY_FACILITY ));
install(providerAttributeType("Primary Facility", "Default facility for a provider", LocationDatatype.class, "", 0, 9999 , _ProviderAttributeType.PRIMARY_FACILITY));
install(providerAttributeType("Practising License Number", "Provider Practising License Number", FreeTextDatatype.class, "", 0, 9999 , _ProviderAttributeType.LICENSE_NUMBER));
install(providerAttributeType("License Expiry Date", "Provider Practising License Expiry Date", DateDatatype.class, "", 0, 9999 , _ProviderAttributeType.LICENSE_EXPIRY_DATE));

install(relationshipType("Guardian", "Dependant", "One that guards, watches over, or protects", _RelationshipType.GUARDIAN_DEPENDANT));
install(relationshipType("Spouse", "Spouse", "A spouse is a partner in a marriage, civil union, domestic partnership or common-law marriage a male spouse is a husband and a female spouse is a wife", _RelationshipType.SPOUSE));
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ ${project.parent.artifactId}.EditUserDetailsForm.roles=Roles

${project.parent.artifactId}.EditProviderDetailsForm.identifier=Identifier
${project.parent.artifactId}.EditProviderDetailsForm.providerFacility=Primary Facility
${project.parent.artifactId}.EditProviderDetailsForm.providerLicense=Provider License
${project.parent.artifactId}.EditProviderDetailsForm.providerLicenseExpiryDate=License Expiry Date

# Profile change dialogs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,13 @@ public class CreateAccountForm extends AbstractWebForm {

private Set<Role> roles;

private String providerIdentifier;
private String providerIdentifier;

private String providerFacility;

private String providerLicense;

private Date providerLicenseExpiryDate;

public CreateAccountForm() {
personName = new PersonName();
Expand Down Expand Up @@ -264,6 +268,7 @@ User getUser(Person person) {
defaultLocation.put("kenyaemr.defaultLocation", providerFacility);
ret.setUserProperties(defaultLocation);
}

return ret;
}

Expand All @@ -278,6 +283,14 @@ Provider getProvider(Person person) {
if (attribute != null) {
ret.setAttribute(attribute);
}
ProviderAttribute licenseAttribute = getLicenseAttribute(providerLicense);
if (licenseAttribute != null) {
ret.setAttribute(licenseAttribute);
}
ProviderAttribute licenseExpiryDateAttribute = getLicenseExpiryDateAttribute(providerLicenseExpiryDate);
if (licenseExpiryDateAttribute != null) {
ret.setAttribute(licenseExpiryDateAttribute);
}
return ret;
}

Expand All @@ -291,6 +304,27 @@ ProviderAttribute getFacilityAttribute(String facility) {
attribute.setValue(Context.getLocationService().getLocation(Integer.parseInt(facility)));
return attribute;
}
ProviderAttribute getLicenseAttribute(String license) {
if (StringUtils.isEmpty(license)) {
return null;
}
ProviderAttribute providerLicenseAttr = new ProviderAttribute();
providerLicenseAttr.setAttributeType(Context.getService(ProviderService.class)
.getProviderAttributeTypeByUuid(CommonMetadata._ProviderAttributeType.LICENSE_NUMBER));
providerLicenseAttr.setValue(license);
return providerLicenseAttr;
}
ProviderAttribute getLicenseExpiryDateAttribute(Date providerLicenseExpiryDate) {
if (providerLicenseExpiryDate == null) {
return null;
}
ProviderAttribute providerLicenseAttr = new ProviderAttribute();
providerLicenseAttr.setAttributeType(Context.getService(ProviderService.class)
.getProviderAttributeTypeByUuid(CommonMetadata._ProviderAttributeType.LICENSE_EXPIRY_DATE));
providerLicenseAttr.setValue(providerLicenseExpiryDate);
return providerLicenseAttr;
}


public Person getOriginal() {
return original;
Expand Down Expand Up @@ -423,5 +457,21 @@ public void setProviderFacility(String providerFacility) {
public String getProviderFacility() {
return providerFacility;
}

public Date getProviderLicenseExpiryDate() {
return providerLicenseExpiryDate;
}

public void setProviderLicenseExpiryDate(Date providerLicenseExpiryDate) {
this.providerLicenseExpiryDate = providerLicenseExpiryDate;
}

public String getProviderLicense() {
return providerLicense;
}

public void setProviderLicense(String providerLicense) {
this.providerLicense = providerLicense;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,26 @@
import org.openmrs.ui.framework.annotation.MethodParam;
import org.openmrs.ui.framework.fragment.FragmentModel;
import org.openmrs.ui.framework.fragment.action.SuccessResult;
import org.openmrs.util.DateUtil;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
* Editable Provider details
*/
public class ProviderDetailsFragmentController {

private static final DateFormat DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy");
public void controller(@FragmentParam("person") Person person,
@FragmentParam(value = "provider", required = false) Provider provider, FragmentModel model) {
Location primaryFacility = null;
String providerLicense = "";
Date providerLicenseExpiryDate = null;


if (provider != null) {
List<ProviderAttribute> attributes = new ArrayList<ProviderAttribute>(provider.getActiveAttributes());
Expand All @@ -51,15 +55,23 @@ public void controller(@FragmentParam("person") Person person,
if (attribute.getAttributeType().getUuid().equals(CommonMetadata._ProviderAttributeType.PRIMARY_FACILITY)) {
primaryFacility = (Location) attribute.getValue();
}
if (attribute.getAttributeType().getUuid().equals(CommonMetadata._ProviderAttributeType.LICENSE_NUMBER)) {
providerLicense = attribute.getValue().toString();
}
if (attribute.getAttributeType().getUuid().equals(CommonMetadata._ProviderAttributeType.LICENSE_EXPIRY_DATE)) {
providerLicenseExpiryDate = (Date) attribute.getValue();
}
}
}
}

List<Location> facilities = Context.getLocationService().getAllLocations();

model.addAttribute("person", person);
model.addAttribute("provider", provider);
model.addAttribute("primaryFacility", primaryFacility);
model.addAttribute("providerLicense", providerLicense);
model.addAttribute("providerLicenseExpiryDate", providerLicenseExpiryDate);
model.addAttribute("form", newEditProviderDetailsForm(provider, person));
}

Expand All @@ -85,7 +97,27 @@ public class EditProviderDetailsForm extends ValidatingCommandObject {
private Person origPerson;

private String providerFacility;


private String providerLicense;

private Date providerLicenseExpiryDate;

public Date getProviderLicenseExpiryDate() {
return providerLicenseExpiryDate;
}

public void setProviderLicenseExpiryDate(Date providerLicenseExpiryDate) {
this.providerLicenseExpiryDate = providerLicenseExpiryDate;
}

public String getProviderLicense() {
return providerLicense;
}

public void setProviderLicense(String providerLicense) {
this.providerLicense = providerLicense;
}

public String getProviderFacility() {
return providerFacility;
}
Expand Down Expand Up @@ -127,6 +159,14 @@ public Provider getProviderToSave(Person person) {
if (attribute != null) {
ret.setAttribute(attribute);
}
ProviderAttribute licenseAttribute = getLicenseAttribute(providerLicense);
if (licenseAttribute != null) {
ret.setAttribute(licenseAttribute);
}
ProviderAttribute licenseExpiryDateAttribute = getLicenseExpiryDateAttribute(providerLicenseExpiryDate);
if (licenseExpiryDateAttribute != null) {
ret.setAttribute(licenseExpiryDateAttribute);
}
return ret;
}

Expand All @@ -140,7 +180,27 @@ ProviderAttribute getFacilityAttribute(String facility) {
primaryFacilityAttr.setValue(Context.getLocationService().getLocation(Integer.parseInt(facility)));
return primaryFacilityAttr;
}


ProviderAttribute getLicenseAttribute(String license) {
if (StringUtils.isEmpty(license)) {
return null;
}
ProviderAttribute providerLicenseAttr = new ProviderAttribute();
providerLicenseAttr.setAttributeType(Context.getService(ProviderService.class)
.getProviderAttributeTypeByUuid(CommonMetadata._ProviderAttributeType.LICENSE_NUMBER));
providerLicenseAttr.setValue(license);
return providerLicenseAttr;
}
ProviderAttribute getLicenseExpiryDateAttribute(Date providerLicenseExpiryDate) {
if (providerLicenseExpiryDate == null) {
return null;
}
ProviderAttribute providerLicenseAttr = new ProviderAttribute();
providerLicenseAttr.setAttributeType(Context.getService(ProviderService.class)
.getProviderAttributeTypeByUuid(CommonMetadata._ProviderAttributeType.LICENSE_EXPIRY_DATE));
providerLicenseAttr.setValue(providerLicenseExpiryDate);
return providerLicenseAttr;
}
/**
* @see org.springframework.validation.Validator#validate(java.lang.Object,
* org.springframework.validation.Errors)
Expand Down Expand Up @@ -175,4 +235,14 @@ public void setIdentifier(String identifier) {
}

}
private Date parseDate(final String dateValue) {
Date date = null;
try {
date = DATE_FORMAT.parse(dateValue);
} catch (ParseException e) {

System.out.println("Unable to parse date data from the payload!");
}
return date;
}
}
19 changes: 17 additions & 2 deletions omod/src/main/webapp/fragments/account/newAccount.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,22 @@
class: java.util.List,
fieldFragment: "field/org.openmrs.Location"
]
]
],
[
[
formFieldName: "providerLicense",
label: "Provider License",
class: java.lang.String
]
],[
[
formFieldName: "providerLicenseExpiryDate",
label: "License Expiry Date",
class: java.util.Date,
initialValue: new Date(),
showTime: false
]
]
]
%>

Expand Down Expand Up @@ -131,4 +146,4 @@
}
});
});
</script>
</script>
8 changes: 5 additions & 3 deletions omod/src/main/webapp/fragments/account/providerDetails.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<% if (primaryFacility) { %>
${ ui.includeFragment("kenyaui", "widget/dataPoint", [ label: "Provider Primary Facility", value: primaryFacility.getName() ]) }
<% } %>
${ ui.includeFragment("kenyaui", "widget/dataPoint", [ label: "Provider License Number", value: providerLicense ]) }
${ ui.includeFragment("kenyaui", "widget/dataPoint", [ label: "License Expiry Date", value: providerLicenseExpiryDate ]) }
</div>
<% } %>

Expand All @@ -25,9 +27,9 @@
action: "submit",
prefix: "provider",
commandObject: form,
properties: [ "identifier", "providerFacility" ],
properties: [ "identifier", "providerFacility", "providerLicense", "providerLicenseExpiryDate"],
fieldConfig: [
providerFacility: [ fieldFragment: "field/org.openmrs.Location" ]
providerFacility: [ fieldFragment: "field/org.openmrs.Location" ]
],
extraFields: [
[ hiddenInputName: "personId", value: person.id ],
Expand Down Expand Up @@ -63,4 +65,4 @@

<% } %>
</div>
</div>
</div>

0 comments on commit c66bff3

Please sign in to comment.