use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project cqf-ruler by DBCG.
the class ProcessMessageProvider method constructAndSaveCommunication.
private String constructAndSaveCommunication(String patientId) {
String communication = "{\"resourceType\" : \"Communication\",\"meta\" : {\"versionId\" : \"1\",\"profile\" : [\"http://hl7.org/fhir/us/medmorph/StructureDefinition/us-ph-communication\"]},\"extension\" : [{\"url\" : \"http://hl7.org/fhir/us/medmorph/StructureDefinition/ext-responseMessageStatus\",\"valueCodeableConcept\" : {\"coding\" : [{\"system\" :\"http://hl7.org/fhir/us/medmorph/CodeSystem/us-ph-response-message-processing-status\",\"code\" : \"RRVS1\"}]}}],\"identifier\" : [{\"system\" : \"http://example.pha.org/\",\"value\" : \"12345\"}],\"status\" : \"completed\",\"category\" : [{\"coding\" : [{\"system\" : \"http://hl7.org/fhir/us/medmorph/CodeSystem/us-ph-messageheader-message-types\",\"code\" : \"cancer-response-message\"}]}],\"reasonCode\" : [{\"coding\" : [{\"system\" : \"http://hl7.org/fhir/us/medmorph/CodeSystem/us-ph-messageheader-message-types\",\"code\" : \"cancer-report-message\"}]}]}";
Communication comm = (Communication) this.getFhirContext().newJsonParser().parseResource(communication);
String commId = getUUID();
comm.setId(commId);
Meta meta = comm.getMeta();
meta.setLastUpdated(new Date());
comm.setMeta(meta);
comm.setSubject(new Reference(patientId));
comm.setReceived(new Date());
this.getDaoRegistry().getResourceDao(Communication.class).create(comm);
return commId;
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project beneficiary-fhir-data by CMSgov.
the class AbstractR4ResourceProvider method findByPatient.
@Search
@Trace
public Bundle findByPatient(@RequiredParam(name = "mbi") @Description(shortDefinition = "The patient identifier to search for") ReferenceParam mbi, @OptionalParam(name = "type") @Description(shortDefinition = "A list of claim types to include") TokenAndListParam types, @OptionalParam(name = "isHashed") @Description(shortDefinition = "A boolean indicating whether or not the MBI is hashed") String hashed, @OptionalParam(name = "excludeSAMHSA") @Description(shortDefinition = "If true, exclude all SAMHSA-related resources") String samhsa, @OptionalParam(name = "_lastUpdated") @Description(shortDefinition = "Include resources last updated in the given range") DateRangeParam lastUpdated, @OptionalParam(name = "service-date") @Description(shortDefinition = "Include resources that completed in the given range") DateRangeParam serviceDate, RequestDetails requestDetails) {
if (mbi != null && !StringUtils.isBlank(mbi.getIdPart())) {
String mbiString = mbi.getIdPart();
Bundle bundleResource;
boolean isHashed = !Boolean.FALSE.toString().equalsIgnoreCase(hashed);
boolean excludeSamhsa = Boolean.TRUE.toString().equalsIgnoreCase(samhsa);
if (isHashed) {
TransformerUtilsV2.logMbiHashToMdc(mbiString);
}
if (types != null) {
bundleResource = createBundleFor(parseClaimTypes(types), mbiString, isHashed, excludeSamhsa, lastUpdated, serviceDate);
} else {
bundleResource = createBundleFor(getResourceTypes(), mbiString, isHashed, excludeSamhsa, lastUpdated, serviceDate);
}
return bundleResource;
} else {
throw new IllegalArgumentException("mbi can't be null/blank");
}
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project beneficiary-fhir-data by CMSgov.
the class R4ExplanationOfBenefitResourceProvider method findByPatient.
/**
* Adds support for the FHIR "search" operation for {@link ExplanationOfBenefit}s, allowing users
* to search by {@link ExplanationOfBenefit#getPatient()}.
*
* <p>The {@link Search} annotation indicates that this method supports the search operation.
* There may be many different methods annotated with this {@link Search} annotation, to support
* many different search criteria.
*
* @param patient a {@link ReferenceParam} for the {@link ExplanationOfBenefit#getPatient()} to
* try and find matches for {@link ExplanationOfBenefit}s
* @param type a list of {@link ClaimTypeV2} to include in the result. Defaults to all types.
* @param startIndex an {@link OptionalParam} for the startIndex (or offset) used to determine
* pagination
* @param excludeSamhsa an {@link OptionalParam} that, if <code>"true"</code>, will use {@link
* R4EobSamhsaMatcher} to filter out all SAMHSA-related claims from the results
* @param lastUpdated an {@link OptionalParam} that specifies a date range for the lastUpdated
* field.
* @param serviceDate an {@link OptionalParam} that specifies a date range for {@link
* ExplanationOfBenefit}s that completed
* @param requestDetails a {@link RequestDetails} containing the details of the request URL, used
* to parse out pagination values
* @return Returns a {@link Bundle} of {@link ExplanationOfBenefit}s, which may contain multiple
* matching resources, or may also be empty.
*/
@Search
@Trace
public Bundle findByPatient(@RequiredParam(name = ExplanationOfBenefit.SP_PATIENT) @Description(shortDefinition = "The patient identifier to search for") ReferenceParam patient, @OptionalParam(name = "type") @Description(shortDefinition = "A list of claim types to include") TokenAndListParam type, @OptionalParam(name = "startIndex") @Description(shortDefinition = "The offset used for result pagination") String startIndex, @OptionalParam(name = "excludeSAMHSA") @Description(shortDefinition = "If true, exclude all SAMHSA-related resources") String excludeSamhsa, @OptionalParam(name = "_lastUpdated") @Description(shortDefinition = "Include resources last updated in the given range") DateRangeParam lastUpdated, @OptionalParam(name = "service-date") @Description(shortDefinition = "Include resources that completed in the given range") DateRangeParam serviceDate, RequestDetails requestDetails) {
/*
* startIndex is an optional parameter here because it must be declared in the
* event it is passed in. However, it is not being used here because it is also
* contained within requestDetails and parsed out along with other parameters
* later.
*/
String beneficiaryId = patient.getIdPart();
Set<ClaimTypeV2> claimTypes = parseTypeParam(type);
OffsetLinkBuilder paging = new OffsetLinkBuilder(requestDetails, "/ExplanationOfBenefit?");
boolean includeTaxNumbers = returnIncludeTaxNumbers(requestDetails);
Operation operation = new Operation(Operation.Endpoint.V2_EOB);
operation.setOption("by", "patient");
operation.setOption("IncludeTaxNumbers", "" + includeTaxNumbers);
operation.setOption("types", (claimTypes.size() == ClaimTypeV2.values().length) ? "*" : claimTypes.stream().sorted(Comparator.comparing(ClaimTypeV2::name)).collect(Collectors.toList()).toString());
operation.setOption("pageSize", paging.isPagingRequested() ? "" + paging.getPageSize() : "*");
operation.setOption("_lastUpdated", Boolean.toString(lastUpdated != null && !lastUpdated.isEmpty()));
operation.setOption("service-date", Boolean.toString(serviceDate != null && !serviceDate.isEmpty()));
operation.publishOperationName();
List<IBaseResource> eobs = new ArrayList<IBaseResource>();
// Optimize when the lastUpdated parameter is specified and result set is empty
if (loadedFilterManager.isResultSetEmpty(beneficiaryId, lastUpdated)) {
return TransformerUtilsV2.createBundle(paging, eobs, loadedFilterManager.getTransactionTime());
}
/*
* The way our JPA/SQL schema is setup, we have to run a separate search for
* each claim type, then combine the results. It's not super efficient, but it's
* also not so inefficient that it's worth fixing.
*/
if (claimTypes.contains(ClaimTypeV2.CARRIER)) {
eobs.addAll(transformToEobs(ClaimTypeV2.CARRIER, findClaimTypeByPatient(ClaimTypeV2.CARRIER, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
}
if (claimTypes.contains(ClaimTypeV2.DME)) {
eobs.addAll(transformToEobs(ClaimTypeV2.DME, findClaimTypeByPatient(ClaimTypeV2.DME, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
}
if (claimTypes.contains(ClaimTypeV2.HHA)) {
eobs.addAll(transformToEobs(ClaimTypeV2.HHA, findClaimTypeByPatient(ClaimTypeV2.HHA, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
}
if (claimTypes.contains(ClaimTypeV2.HOSPICE)) {
eobs.addAll(transformToEobs(ClaimTypeV2.HOSPICE, findClaimTypeByPatient(ClaimTypeV2.HOSPICE, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
}
if (claimTypes.contains(ClaimTypeV2.INPATIENT)) {
eobs.addAll(transformToEobs(ClaimTypeV2.INPATIENT, findClaimTypeByPatient(ClaimTypeV2.INPATIENT, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
}
if (claimTypes.contains(ClaimTypeV2.OUTPATIENT)) {
eobs.addAll(transformToEobs(ClaimTypeV2.OUTPATIENT, findClaimTypeByPatient(ClaimTypeV2.OUTPATIENT, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
}
if (claimTypes.contains(ClaimTypeV2.PDE)) {
eobs.addAll(transformToEobs(ClaimTypeV2.PDE, findClaimTypeByPatient(ClaimTypeV2.PDE, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
}
if (claimTypes.contains(ClaimTypeV2.SNF)) {
eobs.addAll(transformToEobs(ClaimTypeV2.SNF, findClaimTypeByPatient(ClaimTypeV2.SNF, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
}
if (Boolean.parseBoolean(excludeSamhsa)) {
filterSamhsa(eobs);
}
eobs.sort(R4ExplanationOfBenefitResourceProvider::compareByClaimIdThenClaimType);
// Add bene_id to MDC logs
TransformerUtilsV2.logBeneIdToMdc(Arrays.asList(beneficiaryId));
return TransformerUtilsV2.createBundle(paging, eobs, loadedFilterManager.getTransactionTime());
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MedicationRequestFHIRConversionTest method test_medicationreq_status.
@Test
void test_medicationreq_status() {
// ORC.5 = A -> Expected medication status = (ACTIVE ORC.1 is present but ORC.5 takes precedence)
String hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX||A|E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.ACTIVE);
// ORC.5 = CM -> Expected medication status = COMPLETED (ORC.1 is present but ORC.5 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX||CM|E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.COMPLETED);
// ORC.5 = ER -> Expected medication status = ENTEREDINERROR (ORC.1 is present but ORC.5 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX||ER|E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.ENTEREDINERROR);
// ORC.1 = NW -> Expected medication status = ACTIVE (Missing ORC.5 so ORC.1 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.ACTIVE);
// ORC.1 = RP -> Expected medication status = UNKNOWN (Missing ORC.5 so ORC.1 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|RP|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.UNKNOWN);
// ORC.1 = DC -> Expected medication status = STOPPED (Missing ORC.5 so ORC.1 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|DC|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.STOPPED);
// Test that RDE_O11 messages don't create ServiceRequests
List<Resource> serviceRequestList = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
// Confirm that a serviceRequest was not created.
assertThat(serviceRequestList).isEmpty();
// ORC.1 = CA -> Expected medication status = CANCELLED (Missing ORC.5 so ORC.1 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I|6N^1234^A^GENHOS||||0100^ANDERSON,CARL|0148^ADDISON,JAMES||SUR|||||||0100^ANDERSON,CARL|S|V446911|A|||||||||||||||||||SF|K||||20180622230000\n" + "ORC|CA|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.CANCELLED);
// Test that RDE_O11 messages don't create ServiceRequests
serviceRequestList.clear();
serviceRequestList = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
// Confirm that a serviceRequest was not created.
assertThat(serviceRequestList).isEmpty();
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ImmunizationFHIRConversionTest method testImmunizationRXA20Priority.
// Suppress warnings about too many assertions in a test. Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@Test
void testImmunizationRXA20Priority() throws IOException {
// RXA.20 is "completed" this takes precedence over rxa.18 having a value and orc.5
// ORC.5 is here to prove RXA.20 is taking precedence
// ORC.9 is here to prove RXA.22 is taking precedence
String hl7VUXmessageRep = "MSH|^~\\&|EHR|12345^SiteName|MIIS|99990|20140701041038||VXU^V04^VXU_V04|MSG.Valid_01|P|2.6|||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "ORC|RE||197027||ER||||20130905041038|||MD67895^Pediatric^MARY^^^^MD^^RIA|||||\r" + // RXA.11 to Performer Organization
"RXA|||20130531||48^HIB PRP-T^CVX|0.5|ML^^ISO+||00^new immunization record^NIP001|^Sticker^Nurse|^^^RI2050||||33k2a|20131210|PMC^sanofi^MVX|00^Patient refusal^NIP002||PA|A|20120901041038\r" + "OBX|1|CWE|31044-1^Reaction^LN|1|VXC9^Persistent, inconsolable crying lasting > 3 hours within 48 hours of dose^CDCPHINVS||||||F|||20130531|||VXC40^per imm^CDCPHINVS\r";
List<Bundle.BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7VUXmessageRep);
List<Resource> immu = ResourceUtils.getResourceList(e, ResourceType.Immunization);
assertThat(immu).hasSize(1);
Immunization resource = ResourceUtils.getResourceImmunization(immu.get(0), ResourceUtils.context);
assertThat(resource).isNotNull();
// RXA.20 is "completed" this takes precedence over rxa.18 having a value and orc.5
assertThat(resource.getStatus().getDisplay()).isEqualTo("completed");
assertThat(resource.hasStatusReason()).isTrue();
// RXA.18
assertThat(resource.getStatusReason().getCodingFirstRep().getCode()).isEqualTo("00");
// RXA.18
assertThat(resource.getStatusReason().getCodingFirstRep().getSystem()).isEqualTo("urn:id:NIP002");
// RXA.18
assertThat(resource.getStatusReason().getCodingFirstRep().getDisplay()).isEqualTo("Patient refusal");
assertThat(resource.getStatusReason().getText()).isEqualTo("Patient refusal");
assertThat(resource.getIsSubpotent()).isTrue();
// RXA.5.1 + 5.3
assertThat(resource.getIdentifier().get(0).getValue()).isEqualTo("48-CVX");
assertThat(resource.getIdentifier().get(0).getSystem()).isEqualTo("urn:id:extID");
assertThat(resource.getVaccineCode().getCoding().get(0).getSystem()).isEqualTo(// RXA.5.3
"http://hl7.org/fhir/sid/cvx");
// RXA.5.1
assertThat(resource.getVaccineCode().getCoding().get(0).getCode()).isEqualTo("48");
// RXA.5.2
assertThat(resource.getVaccineCode().getText()).isEqualTo("HIB PRP-T");
// RXA.3
assertThat(resource.getOccurrence()).hasToString("DateTimeType[2013-05-31]");
// RXA.9.3
assertThat(resource.getReportOrigin().getCoding().get(0).getSystem()).isEqualTo("urn:id:NIP001");
// RXA.9.
assertThat(resource.getReportOrigin().getCoding().get(0).getCode()).isEqualTo("00");
// RXA.9.2
assertThat(resource.getReportOrigin().getCoding().get(0).getDisplay()).isEqualTo("new immunization record");
// RXA.9.2
assertThat(resource.getReportOrigin().getText()).isEqualTo("new immunization record");
// RXA.17
assertThat(resource.getManufacturer().isEmpty()).isFalse();
// RXA.22
assertThat(resource.hasRecorded()).isTrue();
// RXA.22
assertThat(resource.getRecordedElement().toString()).contains("2012-09-01");
String manufacturerRef = resource.getManufacturer().getReference();
// RXA.15
assertThat(resource.getLotNumber()).isEqualTo("33k2a");
// RXA.16
assertThat(resource.getExpirationDate()).isEqualTo("2013-12-10");
// dose Quantity with an unknown system
assertThat(resource.hasDoseQuantity()).isTrue();
assertThat(resource.getDoseQuantity().getValue()).hasToString("0.5");
assertThat(resource.getDoseQuantity().getUnit()).isEqualTo("ML");
assertThat(resource.getDoseQuantity().getCode()).isEqualTo("ML");
assertThat(resource.getDoseQuantity().getSystem()).isEqualTo("urn:id:ISO+");
String requesterRef1 = resource.getPerformer().get(0).getActor().getReference();
Practitioner practBundle1 = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRef1);
assertThat(resource.getPerformer()).hasSize(3);
DatatypeUtils.checkCommonCodingAssertions(resource.getPerformer().get(0).getFunction().getCoding().get(0), "OP", "Ordering Provider", "http://terminology.hl7.org/CodeSystem/v2-0443", // ORC.12
null);
assertThat(resource.getPerformer().get(0).getFunction().hasText()).isFalse();
// ORC.12
assertThat(resource.getPerformer().get(0).getActor().getReference()).isNotEmpty();
assertThat(practBundle1.getNameFirstRep().getText()).isEqualTo("MARY Pediatric");
assertThat(practBundle1.getNameFirstRep().getFamily()).isEqualTo("Pediatric");
assertThat(practBundle1.getNameFirstRep().getGiven().get(0)).hasToString("MARY");
assertThat(practBundle1.getIdentifierFirstRep().getValue()).isEqualTo("MD67895");
String requesterRef2 = resource.getPerformer().get(1).getActor().getReference();
Practitioner practBundle2 = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRef2);
DatatypeUtils.checkCommonCodingAssertions(resource.getPerformer().get(1).getFunction().getCoding().get(0), "AP", "Administering Provider", "http://terminology.hl7.org/CodeSystem/v2-0443", // RXA.10
null);
assertThat(resource.getPerformer().get(1).getFunction().hasText()).isFalse();
// RXA.10
assertThat(resource.getPerformer().get(1).getActor().isEmpty()).isFalse();
assertThat(practBundle2.getNameFirstRep().getText()).isEqualTo("Nurse Sticker");
assertThat(practBundle2.getNameFirstRep().getFamily()).isEqualTo("Sticker");
assertThat(practBundle2.getNameFirstRep().getGiven().get(0)).hasToString("Nurse");
String requesterRef3 = resource.getPerformer().get(2).getActor().getReference();
DatatypeUtils.checkCommonCodingAssertions(resource.getPerformer().get(2).getFunction().getCoding().get(0), "AP", "Administering Provider", "http://terminology.hl7.org/CodeSystem/v2-0443", // RXA.11
null);
assertThat(resource.getPerformer().get(1).getFunction().hasText()).isFalse();
// Immunization.Reaction Date (OBX.14) and Detail (OBX.5 if OBX 3 is 31044-1)
// OBX.14
assertThat(resource.getReactionFirstRep().getDateElement().toString()).contains("2013-05-31");
// OBX.5
assertThat(resource.getReactionFirstRep().getDetail().hasReference()).isTrue();
// Looking for one Observation that matches the Reaction.Detail reference
String reactionDetail = resource.getReactionFirstRep().getDetail().getReference();
List<Resource> observations = ResourceUtils.getResourceList(e, ResourceType.Observation);
assertThat(observations).hasSize(1);
Observation obs = ResourceUtils.getResourceObservation(observations.get(0), ResourceUtils.context);
assertThat(obs.getId()).isEqualTo(reactionDetail);
assertThat(obs.getCode().getCodingFirstRep().getDisplay()).isEqualTo("Persistent, inconsolable crying lasting > 3 hours within 48 hours of dose");
assertThat(obs.getCode().getCodingFirstRep().getCode()).isEqualTo("VXC9");
assertThat(obs.getCode().getCodingFirstRep().getSystem()).isEqualTo("urn:id:CDCPHINVS");
assertThat(obs.getCode().getText()).isEqualTo("Persistent, inconsolable crying lasting > 3 hours within 48 hours of dose");
assertThat(obs.getIdentifierFirstRep().getValue()).isEqualTo("197027-VXC9-CDCPHINVS");
assertThat(obs.getIdentifierFirstRep().getSystem()).isEqualTo("urn:id:extID");
// Looking for two Organizations: one for the manufacturer reference and one for the Immunization.performer
List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
assertThat(organizations).hasSize(2);
Organization org = ResourceUtils.getResourceOrganization(organizations.get(0), ResourceUtils.context);
assertThat(org.getName()).isEqualTo("RI2050");
assertThat(org.getId()).isEqualTo(requesterRef3);
assertThat(org.hasContact()).isFalse();
org = ResourceUtils.getResourceOrganization(organizations.get(1), ResourceUtils.context);
assertThat(org.getName()).isEqualTo("sanofi");
assertThat(org.getId()).isEqualTo(manufacturerRef);
assertThat(org.hasContact()).isFalse();
// Test that a ServiceRequest is not created for VXU_V04
List<Resource> serviceRequestList = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
// Confirm that a serviceRequest was not created.
assertThat(serviceRequestList).isEmpty();
// Check for expected resources: Organizations (2), Immunization, Patient, Observation, Practitioner (2)
assertThat(e).hasSize(7);
}
Aggregations