Skip to content

Commit

Permalink
Updated code for patient resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishch22 committed Jan 8, 2024
1 parent 8ff1ee9 commit 7b6f975
Showing 1 changed file with 13 additions and 1 deletion.
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;
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;
Expand Down Expand Up @@ -71,7 +72,7 @@ public ReceiveDto buildIdJson(DecryptedEventDto opencrvsRequestBody){
task = entry.resource;
} else if(child==null && "Patient".equals(entry.resource.resourceType)){
child = entry.resource;
} else if(child!=null && "Patient".equals(entry.resource.resourceType)){
} else if(child!=null && "Patient".equals(entry.resource.resourceType)&&isPatientMother(entry.resource.identifier)){
mother = entry.resource;
}
if (child!=null && mother!=null && task!=null) break;
Expand Down Expand Up @@ -125,6 +126,17 @@ public ReceiveDto buildIdJson(DecryptedEventDto opencrvsRequestBody){

return returner;
}

public boolean isPatientMother(List<Identifier> identifier) {
for(Identifier ident : identifier) {
for(Coding coding : ident.type.coding) {
if("NATIONAL_ID".equals(coding.code)){
return true;
}
}
}
return false;
}

public String getOpencrvsBRNFromPatientBody(DecryptedEventDto.Event.Context.Entry.Resource patient){
for(DecryptedEventDto.Event.Context.Entry.Resource.Identifier identifier : patient.identifier){
Expand Down

0 comments on commit 7b6f975

Please sign in to comment.