Search in sources :

Example 31 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project kindling by HL7.

the class SourceParser method genTypeProfile.

private void genTypeProfile(org.hl7.fhir.definitions.model.TypeDefn t) throws Exception {
    StructureDefinition profile;
    try {
        profile = new ProfileGenerator(definitions, context, page, genDate, version, null, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(t);
        t.setProfile(profile);
        DataTypeTableGenerator dtg = new DataTypeTableGenerator(dstDir, page, t.getName(), true, version);
        t.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
        t.getProfile().getText().getDiv().getChildNodes().add(dtg.generate(t, null, false));
        if (context.hasResource(StructureDefinition.class, t.getProfile().getUrl()))
            throw new Exception("Duplicate Profile " + t.getProfile().getUrl());
        context.cacheResource(t.getProfile());
    } catch (Exception e) {
        throw new Exception("Error generating profile for '" + t.getName() + "': " + e.getMessage(), e);
    }
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileGenerator(org.hl7.fhir.definitions.generators.specification.ProfileGenerator) DataTypeTableGenerator(org.hl7.fhir.definitions.generators.specification.DataTypeTableGenerator) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 32 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_status_test.

@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_status_test(String segment) {
    // Check TXA.19
    // TXA.19 value maps to status; OBR.25 is ignored
    String documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1||TEXT||||201801180346||<PHYSID1>||||||||PA||OB|||<PHYSID2>||\n" + "OBX|1|SN|||||||||X";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus status = report.getStatus();
    // TXA.19
    assertThat(status.toCode()).isEqualTo("superseded");
    assertThat(status.getSystem()).isEqualTo("http://hl7.org/fhir/document-reference-status");
    // Check OBR.25 as fallback
    // TXA.19 value is empty so OBR.25 is used
    documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS\n" + "OBR|1||||||20170825010500|||||||||||||002|||||X\n" + "TXA|1||TEXT||||201801180346||<PHYSID1>||||||||PA|||||<PHYSID2>\n" + "OBX|1|SN|||||||||X";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    status = report.getStatus();
    // OBR.25
    assertThat(status.toCode()).isEqualTo("entered-in-error");
    assertThat(status.getSystem()).isEqualTo("http://hl7.org/fhir/document-reference-status");
    // Check default value case
    // TXA.19 and OBR.25 values are empty so should fallback to "current"
    documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002\n" + "TXA|1||TEXT||||201801180346||<PHYSID1>||||||||PA\n" + "OBX|1|SN|||||||||X";
    report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    status = report.getStatus();
    // default value
    assertThat(status.toCode()).isEqualTo("current");
    assertThat(status.getSystem()).isEqualTo("http://hl7.org/fhir/document-reference-status");
}
Also used : DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7PatientFHIRConversionTest method patientNameTest.

@Test
void patientNameTest() {
    String patientHasMiddleName = "MSH|^~\\&|MyEMR|DE-000001| |CAIRLO|20160701123030-0700||VXU^V04^VXU_V04|CA0001|P|2.6|||ER|AL|||||Z22^CDCPHINVS|DE-000001\r" + // PID 5 fields (name) are extracted and tested
    "PID|1||PA123456^^^MYEMR^MR||JONES^GEORGE^Q^III^MR^^B||||||||||||||||||||\r";
    Patient patientObjUsualName = PatientUtils.createPatientFromHl7Segment(ftv, patientHasMiddleName);
    java.util.List<org.hl7.fhir.r4.model.HumanName> name = patientObjUsualName.getName();
    List<StringType> givenName = name.get(0).getGiven();
    List<StringType> suffixes = name.get(0).getSuffix();
    assertThat(suffixes).hasSize(1);
    List<StringType> prefixes = name.get(0).getPrefix();
    assertThat(prefixes).hasSize(1);
    String fullName = name.get(0).getText();
    assertThat(prefixes.get(0).toString()).hasToString("MR");
    assertThat(givenName.get(0).toString()).hasToString("GEORGE");
    assertThat(givenName.get(1).toString()).hasToString("Q");
    assertThat(suffixes.get(0).toString()).hasToString("III");
    assertThat(fullName).isEqualTo("MR GEORGE Q JONES III");
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) StringType(org.hl7.fhir.r4.model.StringType) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 34 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project cqf-ruler by DBCG.

the class CompositionSectionComponentBuilder method initializeDstu2_1.

@Override
protected void initializeDstu2_1(T theResource) {
    super.initializeDstu2_1(theResource);
    org.hl7.fhir.dstu2016may.model.Composition.SectionComponent section = (org.hl7.fhir.dstu2016may.model.Composition.SectionComponent) theResource;
    section.setTitle(myTitle).setId(getId());
    getEntries().forEach(entry -> section.addEntry(new Reference(entry)));
    if (myText != null) {
        Narrative narrative = new Narrative();
        narrative.setStatusAsString(myText.getStatus());
        narrative.setDivAsString(myText.getText());
        section.setText(narrative);
    }
// no focus
}
Also used : Narrative(org.hl7.fhir.dstu2016may.model.Narrative) Reference(org.hl7.fhir.dstu2016may.model.Reference)

Example 35 with org.hl7.fhir.r5.utils.validation.constants

use of org.hl7.fhir.r5.utils.validation.constants in project cqf-ruler by DBCG.

the class DetectedIssueBuilder method initializeR4.

@Override
protected void initializeR4(T theResource) {
    super.initializeR4(theResource);
    org.hl7.fhir.r4.model.DetectedIssue detectedIssue = (org.hl7.fhir.r4.model.DetectedIssue) theResource;
    List<org.hl7.fhir.r4.model.Identifier> identifier = new ArrayList<>();
    identifier.add(new org.hl7.fhir.r4.model.Identifier().setSystem(getIdentifier().getKey()).setValue(getIdentifier().getValue()));
    detectedIssue.setIdentifier(identifier).setPatient(new org.hl7.fhir.r4.model.Reference(myPatient)).setStatus(org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueStatus.valueOf(myStatus)).setCode(new CodeableConcept().addCoding(new Coding().setSystem(getCodeSetting().getSystem()).setCode(getCodeSetting().getCode()).setDisplay(getCodeSetting().getDisplay())));
    getEvidenceDetails().forEach(evidence -> detectedIssue.addEvidence(new DetectedIssueEvidenceComponent().addDetail(new org.hl7.fhir.r4.model.Reference(evidence))));
}
Also used : ArrayList(java.util.ArrayList) Identifier(org.hl7.fhir.dstu2016may.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) DetectedIssueEvidenceComponent(org.hl7.fhir.r4.model.DetectedIssue.DetectedIssueEvidenceComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Aggregations

Test (org.junit.jupiter.api.Test)427 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)334 Test (org.junit.Test)241 FHIRException (org.hl7.fhir.exceptions.FHIRException)104 ArrayList (java.util.ArrayList)101 IOException (java.io.IOException)78 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)70 Date (java.util.Date)65 List (java.util.List)64 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)61 FileOutputStream (java.io.FileOutputStream)59 CodeableReference (org.hl7.fhir.r5.model.CodeableReference)58 File (java.io.File)57 InputStream (java.io.InputStream)51 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)50 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)48 Bundle (org.hl7.fhir.dstu3.model.Bundle)48 MethodSource (org.junit.jupiter.params.provider.MethodSource)46 Arrays (java.util.Arrays)45 Collectors (java.util.stream.Collectors)45