diff --git a/api/src/main/java/org/bahmni/module/hip/Config.java b/api/src/main/java/org/bahmni/module/hip/Config.java index df97053f..b03cf59b 100644 --- a/api/src/main/java/org/bahmni/module/hip/Config.java +++ b/api/src/main/java/org/bahmni/module/hip/Config.java @@ -11,6 +11,7 @@ public enum Config { //identifier type ABHA_ADDRESS("ABHA Address"), + ABHA_NUMBER("ABHA Number"), //encounterType CONSULTATION("Consultation"), diff --git a/api/src/main/resources/liquibase.xml b/api/src/main/resources/liquibase.xml index cc244a0b..489dd0fd 100644 --- a/api/src/main/resources/liquibase.xml +++ b/api/src/main/resources/liquibase.xml @@ -18,24 +18,24 @@ - + - select count(*) from patient_identifier_type where name='ABHA' + select count(*) from patient_identifier_type where name='ABHA Number' - Removing ABHA identifier from global property + Adding ABHA Number Identifier type - 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'; - + - select count(*) from patient_identifier_type where name='ABHA' + select count(*) from patient_identifier_type where name='ABHA Number' + select count(*) from global_property where property = 'bahmni.extraPatientIdentifierTypes' and property_value LIKE CONCAT('%', (Select uuid from patient_identifier_type where name = 'ABHA Number')) - Removing ABHA Identifier type + Updating global property for ABHA Number - 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'; @@ -110,6 +110,15 @@ insert into privilege(privilege,description,uuid) values('app:abdm','privilege to view abdm services',uuid()); + + + select count(*) from privilege where privilege='app:abdm' + + Adding new privilage for ABDM services + + insert into privilege(privilege,description,uuid) values('app:abdm','privilege to view abdm services',uuid()); + + select count(*) from role where role='ABDM' diff --git a/omod/src/main/java/org/bahmni/module/hip/web/service/ExistingPatientService.java b/omod/src/main/java/org/bahmni/module/hip/web/service/ExistingPatientService.java index 0165026e..74337b5a 100644 --- a/omod/src/main/java/org/bahmni/module/hip/web/service/ExistingPatientService.java +++ b/omod/src/main/java/org/bahmni/module/hip/web/service/ExistingPatientService.java @@ -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 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); @@ -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) { }