Skip to content

Commit

Permalink
Updated code as per opencrvs
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishch22 committed Jan 8, 2024
1 parent 8bac344 commit 8ff1ee9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ public static class Focus {
public String reference;
}
public static class Identifier{
public String type;
public static class Type {
public static class Coding {
public String system;
public String code;
}
public List<Coding> coding;
}
public Type type;
public String system;
public String value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.mosip.opencrvs.constant.LoggingConstants;
import io.mosip.opencrvs.dto.BaseEventRequest;
import io.mosip.opencrvs.dto.DecryptedEventDto;
import io.mosip.opencrvs.dto.DecryptedEventDto.Event.Context.Entry.Resource.Identifier.Type.Coding;
import io.mosip.opencrvs.error.ErrorCode;
import io.mosip.opencrvs.util.LogUtil;
import io.mosip.opencrvs.util.OpencrvsCryptoUtil;
Expand Down Expand Up @@ -124,8 +125,10 @@ public String getUINFromDecryptedEvent(DecryptedEventDto decryptedEventDto) thro
throw ErrorCode.MISSING_UIN_IN_DEATH_EVENT.throwChecked();
}
for(DecryptedEventDto.Event.Context.Entry.Resource.Identifier identifier: patient.identifier){
if("NATIONAL_ID".equals(identifier.type)){
return identifier.value;
for(Coding coding : identifier.type.coding) {
if("NATIONAL_ID".equals(coding.code)){
return identifier.value;
}
}
}
throw ErrorCode.MISSING_UIN_IN_DEATH_EVENT.throwChecked();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.mosip.kernel.core.util.StringUtils;
import io.mosip.opencrvs.constant.LoggingConstants;
import io.mosip.opencrvs.dto.DecryptedEventDto;
import io.mosip.opencrvs.dto.DecryptedEventDto.Event.Context.Entry.Resource.Identifier.Type.Coding;
import io.mosip.opencrvs.dto.ReceiveDto;
import io.mosip.opencrvs.error.ErrorCode;
import org.json.JSONObject;
Expand Down Expand Up @@ -127,8 +128,10 @@ public ReceiveDto buildIdJson(DecryptedEventDto opencrvsRequestBody){

public String getOpencrvsBRNFromPatientBody(DecryptedEventDto.Event.Context.Entry.Resource patient){
for(DecryptedEventDto.Event.Context.Entry.Resource.Identifier identifier : patient.identifier){
if("BIRTH_REGISTRATION_NUMBER".equals(identifier.type)){
return identifier.value;
for(Coding coding : identifier.type.coding) {
if("BIRTH_REGISTRATION_NUMBER".equals(coding.code)){
return identifier.value;
}
}
}
return null;
Expand Down Expand Up @@ -220,8 +223,10 @@ public String getRidFromBody(DecryptedEventDto decryptedEvent){
for(DecryptedEventDto.Event.Context.Entry entry: contextEntries) {
if ("Patient".equals(entry.resource.resourceType)) {
for(DecryptedEventDto.Event.Context.Entry.Resource.Identifier identifier : entry.resource.identifier){
if("MOSIP_AID".equals(identifier.type)){
return identifier.value;
for(Coding coding : identifier.type.coding) {
if("MOSIP_AID".equals(coding.code)){
return identifier.value;
}
}
}
break;
Expand Down

0 comments on commit 8ff1ee9

Please sign in to comment.