Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated code for patient resource #2

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading