use of org.hl7.fhir.r4b.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7IdentifierFHIRConversionTest method serviceRequestIdentifierTest2.
@Test
void serviceRequestIdentifierTest2() {
// Test 3:
// - Visit number with PV1-19
// - filler from OBR
// - placer from ORC
String serviceRequest = "MSH|^~\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|200603081747|security|PPR^PC1^PPR_PC1|1|P^I|2.6||||||ASCII||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1||I|6N^1234^A^GENERAL HOSPITAL2|||||||SUR||||||||S|8846511|A|||||||||||||||||||SF|K||||20170215080000\n" + "PRB|AD|200603150625|aortic stenosis|53692||2||200603150625\n" + "ORC||PON001||||E|^Q6H^D10^^^R\n" + "OBR|1||CD150920001336|||20150930000000|20150930164100|||||||||25055^MARCUSON^PATRICIA^L|||||||||F|||5755^DUNN^CHAD^B~25055^MARCUSON^PATRICIA^L|||WEAKNESS|DAS, SURJYA P||SHIELDS, SHARON A|||||||||";
ServiceRequest serviceReq = ResourceUtils.getServiceRequest(ftv, serviceRequest);
// Expect 3 identifiers
assertThat(serviceReq.hasIdentifier()).isTrue();
assertThat(serviceReq.getIdentifier()).hasSize(3);
List<Identifier> identifiers = serviceReq.getIdentifier();
// Match the id's to position; we can't depend on an order.
int posVN = getIdentifierPositionByValue("8846511", identifiers);
assertThat(posVN).isNotSameAs(-1);
int posFILLER = getIdentifierPositionByValue("CD150920001336", identifiers);
assertThat(posFILLER).isNotSameAs(-1);
int posPLACER = getIdentifierPositionByValue("PON001", identifiers);
assertThat(posPLACER).isNotSameAs(-1);
// Identifier 1: visit number
Identifier identifier = serviceReq.getIdentifier().get(posVN);
String value = identifier.getValue();
String system = identifier.getSystem();
// PV1.19
assertThat(value).isEqualTo("8846511");
assertThat(system).isNull();
CodeableConcept type = identifier.getType();
DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// Identifier 2: filler
identifier = serviceReq.getIdentifier().get(posFILLER);
value = identifier.getValue();
system = identifier.getSystem();
// OBR.3.1
assertThat(value).isEqualTo("CD150920001336");
assertThat(system).isNull();
type = identifier.getType();
DatatypeUtils.checkCommonCodeableConceptAssertions(type, "FILL", "Filler Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// Identifier 3: placer
identifier = serviceReq.getIdentifier().get(posPLACER);
value = identifier.getValue();
system = identifier.getSystem();
// ORC.2.1
assertThat(value).isEqualTo("PON001");
assertThat(system).isNull();
type = identifier.getType();
DatatypeUtils.checkCommonCodeableConceptAssertions(type, "PLAC", "Placer Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
}
use of org.hl7.fhir.r4b.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7IdentifierFHIRConversionTest method encounterIdentifierTest.
@Test
void encounterIdentifierTest() {
// Test: Visit number from PV1-19
String encounterMsg = "MSH|^~\\&|MYEHR2.5|RI88140101|KIDSNET_IFL|RIHEALTH|20130531||VXU^V04^VXU_V04|20130531RI881401010105|P|2.6|||AL|NE|764|ASCII||||||^4086::132:2A57:3C28^IPv6\r" + "EVN|A01|20130617154644||01\r" + "PID|||12345^^^^MR||smith^john|||||||||||||112233\r" + "PV1||I||||||||SUR||||||||S||A\r";
Encounter encounter = ResourceUtils.getEncounter(ftv, encounterMsg);
// Expect a single identifier
assertThat(encounter.hasIdentifier()).isTrue();
assertThat(encounter.getIdentifier()).hasSize(1);
// Identifier 1: Visit number
Identifier identifier = encounter.getIdentifier().get(0);
String value = identifier.getValue();
String system = identifier.getSystem();
// PID.18
assertThat(value).isEqualTo("112233");
assertThat(system).isNull();
CodeableConcept type = identifier.getType();
Coding coding = type.getCoding().get(0);
assertThat(type.getText()).isNull();
assertThat(coding.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0203");
assertThat(coding.getCode()).isEqualTo("VN");
assertThat(coding.getDisplay()).isEqualTo("Visit number");
}
use of org.hl7.fhir.r4b.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7IdentifierFHIRConversionTest method procedureIdentifierTest.
@Test
void procedureIdentifierTest() {
// with PR1 and PID segments used to create identifiers
String procedureMsg = "MSH|^~\\&|HL7Soup|Instance1|MCM||200911021022|Security|ADT^A01^ADT_A01|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM|CDP|^4086::132:2A57:3C28^IPV6|^4086::132:2A57:3C25^IPV6|\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|78654^^^ACME||||N\n" + "ROL|5897|UP|AD||20210322133821|20210322133822|10||Hospital|ST||||USA\n" + "PR1|1|ICD10|B45678|Fix break|20210322155008|A|75||V46|80|||32|1|D22|G45|1|G|P98|X|0|0\n";
Procedure procedure = ResourceUtils.getProcedure(ftv, procedureMsg);
// Expect 2 identifiers
assertThat(procedure.hasIdentifier()).isTrue();
assertThat(procedure.getIdentifier()).hasSize(2);
List<Identifier> identifiers = procedure.getIdentifier();
// Match the three id's to position; we can't depend on an order.
int posExtId = getIdentifierPositionByValue("P98", identifiers);
assertThat(posExtId).isNotSameAs(-1);
int posACME = getIdentifierPositionByValue("78654", identifiers);
assertThat(posACME).isNotSameAs(-1);
// Identifier 1: PR1.19
Identifier identifier = procedure.getIdentifier().get(posExtId);
String value = identifier.getValue();
String system = identifier.getSystem();
// PR1.19.1
assertThat(value).isEqualTo("P98");
assertThat(system).isEqualTo("urn:id:extID");
// Identifier 2: Visit number from PID-18
identifier = procedure.getIdentifier().get(posACME);
value = identifier.getValue();
system = identifier.getSystem();
// PID.18.1
assertThat(value).isEqualTo("78654");
// PID.18.4
assertThat(system).isEqualTo("urn:id:ACME");
CodeableConcept type = identifier.getType();
DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// Test: MSH.7 and PV1.19
String procedureMSH = "MSH|^~\\&||Instance1|MCM||200911021022|Security|ADT^A01^ADT_A01|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM|CDP|^4086::132:2A57:3C28^IPV6|^4086::132:2A57:3C25^IPV6|\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1||I|6N^1234^A^GENERAL HOSPITAL2|||||||SUR||||||||S|8846511|A|||||||||||||||||||SF|K||||20170215080000\n" + "ROL|5897|UP|AD||20210322133821|20210322133822|10||Hospital|ST||||USA\n" + "PR1|1|ICD10|B45678|Fix break|20210322155008|A|75||V46|80|||32|1|D22|G45|1|G||X|0|0\n";
procedure = ResourceUtils.getProcedure(ftv, procedureMSH);
// Expect 2 identifiers
assertThat(procedure.hasIdentifier()).isTrue();
assertThat(procedure.getIdentifier()).hasSize(2);
identifiers = procedure.getIdentifier();
// Match the three id's to position; we can't depend on an order.
posExtId = getIdentifierPositionByValue("200911021022", identifiers);
assertThat(posExtId).isNotSameAs(-1);
int posVN = getIdentifierPositionByValue("8846511", identifiers);
assertThat(posVN).isNotSameAs(-1);
// Identifier 1: PR1
identifier = procedure.getIdentifier().get(posExtId);
value = identifier.getValue();
system = identifier.getSystem();
// MSH.7
assertThat(value).isEqualTo("200911021022");
assertThat(system).isEqualTo("urn:id:extID");
// Identifier 2: Visit number from PV1-19
identifier = procedure.getIdentifier().get(posVN);
String valueOBR = identifier.getValue();
system = identifier.getSystem();
// PV1.19.1
assertThat(valueOBR).isEqualTo("8846511");
// No System PV1.19.2 DNE
assertThat(system).isNull();
type = identifier.getType();
DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
}
use of org.hl7.fhir.r4b.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7IdentifierFHIRConversionTest method serviceRequestIdentifierTest5.
// NOTE: ORU_RO1 records do not create the ServiceRequest directly. They create a DiagnosticReport and it creates the ServiceRequest.
// This test makes sure the specification for ORU_RO1.DiagnosticReport is specifying PID and PV1 correctly in AdditionalSegments.
@Test
void serviceRequestIdentifierTest5() {
// Test 3:
// - MSH.7 as the visit number
// - filler from ORC
// - placer from ORC
String serviceRequest = "MSH|^~\\&|||||20180924152907|34001|ORU^R01^ORU_R01|213|T|2.6|||||||||||\n" + // PID.18 is empty so MSH.7 with be used as backup identifier visit number
"PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // PV1.19 is empty so MSH.7 with be used as backup identifier visit number
"PV1|1|E|||||||||||||||||||||||||||||||||||||||||||\n" + // 1. ORC.3 is used as Filler because it has priority over OBR.3
"ORC|RE|222298|222299|ML18267-C00001^Beaker||||||||||||||||||||||||||||\n" + // 11. OBR.3 ignored as Filler
"OBR|1|||83036E^HEMOGLOBIN A1C^PACSEAP^^^^^^HEMOGLOBIN A1C|||||||||||||||||||||||||||||||||||||||||||\n";
ServiceRequest serviceReq = ResourceUtils.getServiceRequest(ftv, serviceRequest);
// Expect 3 identifiers
assertThat(serviceReq.hasIdentifier()).isTrue();
assertThat(serviceReq.getIdentifier()).hasSize(3);
// Expect 3 identifiers
assertThat(serviceReq.hasIdentifier()).isTrue();
assertThat(serviceReq.getIdentifier()).hasSize(3);
List<Identifier> identifiers = serviceReq.getIdentifier();
// Match the three id's to position; we can't depend on an order.
int posVN = getIdentifierPositionByValue("20180924152907", identifiers);
assertThat(posVN).isNotSameAs(-1);
int posFILLER = getIdentifierPositionByValue("222299", identifiers);
assertThat(posFILLER).isNotSameAs(-1);
int posPLACER = getIdentifierPositionByValue("222298", identifiers);
assertThat(posPLACER).isNotSameAs(-1);
// Identifier 1: visit number should be set by MSH.7
Identifier identifier = serviceReq.getIdentifier().get(posVN);
String value = identifier.getValue();
String system = identifier.getSystem();
// MSH.7
assertThat(value).isEqualTo("20180924152907");
assertThat(system).isNull();
CodeableConcept type = identifier.getType();
DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// Identifier 2: filler
identifier = serviceReq.getIdentifier().get(posFILLER);
value = identifier.getValue();
system = identifier.getSystem();
// ORC.3
assertThat(value).isEqualTo("222299");
assertThat(system).isNull();
type = identifier.getType();
DatatypeUtils.checkCommonCodeableConceptAssertions(type, "FILL", "Filler Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// Identifier 3: placer
identifier = serviceReq.getIdentifier().get(posPLACER);
value = identifier.getValue();
system = identifier.getSystem();
// ORC.2
assertThat(value).isEqualTo("222298");
assertThat(system).isNull();
type = identifier.getType();
DatatypeUtils.checkCommonCodeableConceptAssertions(type, "PLAC", "Placer Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
}
use of org.hl7.fhir.r4b.model.Identifier in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MedicationRequestFHIRConversionTest method testMedicationRequestCategoryRequesterAndDispenseRequest.
@Test
void testMedicationRequestCategoryRequesterAndDispenseRequest() {
String hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // ORC.29 to category
"ORC|NW|||||||||||3122^PROVIDER^ORDERING^^^DR|||20190606193536||||||||||||||I\n" + // RXE.13 empty so ORC.12 takes priority
"RXE|^Q24H&0600^^20210330144208^^ROU|DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|3||mL|47||||||||||||||||||||||||||||||||||\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);
// requester comes from ORC.12 which is the back up value for RXE.13
String requesterRef = medicationRequest.getRequester().getReference();
Practitioner practBundle = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRef);
Identifier practitionerIdentifier = practBundle.getIdentifierFirstRep();
HumanName practName = practBundle.getNameFirstRep();
// ORC.12.1
assertThat(practitionerIdentifier.getValue()).isEqualTo("3122");
// ORC.12.9
assertThat(practitionerIdentifier.getSystem()).isNull();
// ORC.12.2
assertThat(practName.getFamily()).isEqualTo("PROVIDER");
// ORC.12.3
assertThat(practName.getGivenAsSingleString()).isEqualTo("ORDERING");
// ORC.12.6
assertThat(practName.getPrefixAsSingleString()).isEqualTo("DR");
// ORC.12.5
assertThat(practName.getSuffix()).isEmpty();
// ORC.12
assertThat(practName.getText()).isEqualTo("DR ORDERING PROVIDER");
// category comes from ORC.29
assertThat(medicationRequest.getCategory()).hasSize(1);
DatatypeUtils.checkCommonCodeableConceptAssertions(medicationRequest.getCategory().get(0), "inpatient", "Inpatient", "http://terminology.hl7.org/CodeSystem/medicationrequest-category", null);
// DispenseRequest.start comes from ORC.15
assertThat(medicationRequest.getDispenseRequest().hasValidityPeriod()).isTrue();
assertThat(medicationRequest.getDispenseRequest().getValidityPeriod().getStartElement().toString()).containsPattern("2019-06-06");
}
Aggregations