Skip to content

Commit

Permalink
Merge branch 'master' into BAH-2765
Browse files Browse the repository at this point in the history
  • Loading branch information
SanoferSameera committed Feb 15, 2023
2 parents 28e750a + c774c3e commit 8d0b786
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
1 change: 1 addition & 0 deletions api/src/main/java/org/bahmni/module/hip/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum Config {

//identifier type
ABHA_ADDRESS("ABHA Address"),
ABHA_NUMBER("ABHA Number"),

//encounterType
CONSULTATION("Consultation"),
Expand Down
27 changes: 18 additions & 9 deletions api/src/main/resources/liquibase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@
</update>
</changeSet>

<changeSet id="Removing-ABHA-globalProperty-230620221617" author="Sameera, Kavitha">
<changeSet id="Adding-ABHA-Number-IdentifierType-190120231610" author="Sameera">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">select count(*) from patient_identifier_type where name='ABHA'</sqlCheck>
<sqlCheck expectedResult="0">select count(*) from patient_identifier_type where name='ABHA Number'</sqlCheck>
</preConditions>
<comment>Removing ABHA identifier from global property</comment>
<comment>Adding ABHA Number Identifier type</comment>
<sql>
update global_property set property_value=replace(property_value,concat((SELECT uuid from patient_identifier_type where name='ABHA'),","),"") where property = 'bahmni.extraPatientIdentifierTypes';
insert into patient_identifier_type( name, description,creator, uuid, uniqueness_behavior, location_behavior, date_created) Select 'ABHA Number','Health Id identifier type',creator,uuid(),'UNIQUE','NOT_USED',now() from users where username='admin';
</sql>
</changeSet>

<changeSet id="Removing-ABHA-IdentifierType" author="Sameera, Kavitha">
<changeSet id="updating-ABHA-Number-globalProperty-190120231612" author="Sameera">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">select count(*) from patient_identifier_type where name='ABHA'</sqlCheck>
<sqlCheck expectedResult="1">select count(*) from patient_identifier_type where name='ABHA Number'</sqlCheck>
<sqlCheck expectedResult="0">select count(*) from global_property where property = 'bahmni.extraPatientIdentifierTypes' and property_value LIKE CONCAT('%', (Select uuid from patient_identifier_type where name = 'ABHA Number'))</sqlCheck>
</preConditions>
<comment>Removing ABHA Identifier type</comment>
<comment>Updating global property for ABHA Number</comment>
<sql>
delete from patient_identifier where identifier_type=(select patient_identifier_type_id from patient_identifier_type where name='ABHA');
delete from patient_identifier_type where name='ABHA';
update global_property set property_value=(SELECT CONCAT(IF(ISNULL(property_value),'',CONCAT(property_value,',')),uuid) from patient_identifier_type where name = 'ABHA Number') where property = 'bahmni.extraPatientIdentifierTypes';
</sql>
</changeSet>

Expand Down Expand Up @@ -110,6 +110,15 @@
insert into privilege(privilege,description,uuid) values('app:abdm','privilege to view abdm services',uuid());
</sql>
</changeSet>
<changeSet id="Adding-Permission-for-abdm-services" author="swati">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">select count(*) from privilege where privilege='app:abdm'</sqlCheck>
</preConditions>
<comment>Adding new privilage for ABDM services</comment>
<sql>
insert into privilege(privilege,description,uuid) values('app:abdm','privilege to view abdm services',uuid());
</sql>
</changeSet>
<changeSet id="Adding-role-for-abdm-services" author="Sameera">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="0">select count(*) from role where role='ABDM'</sqlCheck>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,36 @@ public String getHealthId(Patient patient) {
public void perform(String healthId, String action) {
Patient patient = patientService.getPatientByUuid(getPatientWithHealthId(healthId));
PatientIdentifier patientIdentifierPhr = patient.getPatientIdentifier(Config.ABHA_ADDRESS.getValue());
PatientIdentifier patientIdentifierHealthId = patient.getPatientIdentifier(Config.ABHA_NUMBER.getValue());
if (action.equals(Status.DELETED.toString())) {
removeHealthId(patient,patientIdentifierPhr);
removeHealthId(patient,patientIdentifierPhr,patientIdentifierHealthId);
}
if (action.equals(Status.DEACTIVATED.toString())) {
voidHealthId(patientIdentifierPhr);
voidHealthId(patientIdentifierPhr,patientIdentifierHealthId);
}
if (action.equals(Status.REACTIVATED.toString())) {
unVoidHealthId(patient,healthId);
unVoidHealthId(patient);
}
}

private void voidHealthId(PatientIdentifier patientIdentifierPHR) {
private void voidHealthId(PatientIdentifier patientIdentifierPHR, PatientIdentifier patientIdentifierHealthId) {
try {
if (!patientIdentifierPHR.getVoided()) {
patientService.voidPatientIdentifier(patientIdentifierPHR, Status.DEACTIVATED.toString());
}
if (!patientIdentifierHealthId.getVoided()) {
patientService.voidPatientIdentifier(patientIdentifierHealthId, Status.DEACTIVATED.toString());
}
} catch (NullPointerException ignored) {
}
}

private void unVoidHealthId(Patient patient, String phrAddress) {
private void unVoidHealthId(Patient patient) {
Set<PatientIdentifier> patientIdentifiers = patient.getIdentifiers();
try {
for (PatientIdentifier patientIdentifier : patientIdentifiers) {
if (patientIdentifier.getIdentifierType().getName().equals(Config.ABHA_ADDRESS.getValue())) {
if (patientIdentifier.getIdentifierType().getName().equals(Config.ABHA_ADDRESS.getValue()) ||
patientIdentifier.getIdentifierType().getName().equals(Config.ABHA_NUMBER.getValue())) {
if(patientIdentifier.getVoided()){
patientIdentifier.setVoided(false);
patientService.savePatientIdentifier(patientIdentifier);
Expand All @@ -100,10 +105,12 @@ private void unVoidHealthId(Patient patient, String phrAddress) {
}
}

private void removeHealthId(Patient patient,PatientIdentifier patientIdentifierPHR) {
private void removeHealthId(Patient patient,PatientIdentifier patientIdentifierPHR,PatientIdentifier patientIdentifierHealthId) {
try {
if(patientIdentifierPHR != null)
patient.removeIdentifier(patientIdentifierPHR);
if (patientIdentifierHealthId != null)
patient.removeIdentifier(patientIdentifierHealthId);
patientService.savePatient(patient);
} catch (NullPointerException ignored) {
}
Expand Down

0 comments on commit 8d0b786

Please sign in to comment.