Search in sources :

Example 26 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project openmrs-module-fhir2 by openmrs.

the class MedicationReferenceTranslatorImplTest method toOpenmrsType_shouldThrowExceptionIfReferenceIsntForMedication.

@Test(expected = IllegalArgumentException.class)
public void toOpenmrsType_shouldThrowExceptionIfReferenceIsntForMedication() {
    Reference reference = new Reference().setReference("Unknown" + "/" + MEDICATION_UUID).setType("Unknown");
    medicationReferenceTranslator.toOpenmrsType(reference);
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Test(org.junit.Test)

Example 27 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project openmrs-module-fhir2 by openmrs.

the class VisitReferenceTranslatorImplTest method toOpenmrsType_shouldThrowExceptionIfReferenceIsNotForEncounter.

@Test(expected = IllegalArgumentException.class)
public void toOpenmrsType_shouldThrowExceptionIfReferenceIsNotForEncounter() {
    Reference reference = new Reference().setReference("Unknown" + "/" + VISIT_UUID).setType("Unknown");
    visitReferenceTranslator.toOpenmrsType(reference);
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Test(org.junit.Test)

Example 28 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project integration-adaptor-111 by nhsconnect.

the class RelatedPersonMapper method mapRelatedPerson.

public RelatedPerson mapRelatedPerson(POCDMT000002UK01Informant12 informant, Encounter encounter) {
    if (!informant.isSetRelatedEntity()) {
        return null;
    }
    POCDMT000002UK01RelatedEntity relatedEntity = informant.getRelatedEntity();
    RelatedPerson relatedPerson = new RelatedPerson();
    relatedPerson.setIdElement(resourceUtil.newRandomUuid());
    relatedPerson.setActive(true).setPatient(encounter.getSubject()).setGender(UNKNOWN);
    if (relatedEntity.isSetRelatedPerson()) {
        relatedPerson.setName(getHumanNameFromITK(relatedEntity.getRelatedPerson()));
    }
    if (relatedEntity.sizeOfTelecomArray() > 0) {
        relatedPerson.setTelecom(getTelecomFromITK(relatedEntity.getTelecomArray()));
    }
    if (relatedEntity.sizeOfAddrArray() > 0) {
        relatedPerson.setAddress(getAddressesFromITK(relatedEntity.getAddrArray()));
    }
    if (relatedEntity.isSetEffectiveTime()) {
        Period period = new Period();
        if (relatedEntity.getEffectiveTime().isSetLow()) {
            period.setStartElement(DateUtil.parse(relatedEntity.getEffectiveTime().getLow().getValue()));
        }
        if (relatedEntity.getEffectiveTime().isSetHigh()) {
            period.setEndElement(DateUtil.parse(relatedEntity.getEffectiveTime().getHigh().getValue()));
        }
        relatedPerson.setPeriod(period);
    }
    relatedPerson.setPeriod(getPeriod(relatedEntity));
    setRelationship(relatedEntity, relatedPerson);
    markEmergencyContact(relatedEntity.getTelecomArray(), relatedPerson);
    return relatedPerson;
}
Also used : POCDMT000002UK01RelatedEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RelatedEntity) Period(org.hl7.fhir.dstu3.model.Period) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson)

Example 29 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project org.hl7.fhir.core by hapifhir.

the class ExpressionAdvisor50 method handleExtension.

public void handleExtension(@Nonnull String path, @Nonnull org.hl7.fhir.r5.model.Extension src, @Nonnull org.hl7.fhir.dstu2.model.Extension tgt) {
    if (src.getValue() instanceof org.hl7.fhir.r5.model.Expression) {
        StringType type = new StringType();
        if (src.getValue() == null) {
            throw new NullPointerException("null cannot be cast to non-null type org.hl7.fhir.r5.model.Expression");
        } else {
            type.setValueAsString(((Expression) src.getValue()).getExpression());
            tgt.setValue(type);
            if (src.hasUrlElement()) {
                tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement()));
            }
        }
    } else {
        throw new FHIRException("Unknown extension type passed in to custom convertor method.");
    }
}
Also used : Expression(org.hl7.fhir.r5.model.Expression) StringType(org.hl7.fhir.dstu2.model.StringType) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 30 with UNKNOWN

use of org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN in project org.hl7.fhir.core by hapifhir.

the class ADLImporter method execute.

private void execute() throws Exception {
    // load config
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    adlConfig = builder.parse(new FileInputStream(config)).getDocumentElement();
    // load ADL
    builder = factory.newDocumentBuilder();
    adl = builder.parse(new FileInputStream(source)).getDocumentElement();
    check("root", adl.getNamespaceURI(), "http://schemas.openehr.org/v1", "Wrong namespace for ADL XML");
    check("root", adl.getNodeName(), "archetype", "Wrong XML for ADL XML");
    check("root", XMLUtil.getNamedChild(adl, "adl_version").getTextContent(), "1.4", "unsupported ADL version");
    String id = XMLUtil.getFirstChild(XMLUtil.getNamedChild(adl, "archetype_id")).getTextContent().split("\\.")[1];
    // create structure definition
    StructureDefinition sd = new StructureDefinition();
    sd.setId(id);
    // populate metadata
    Element description = XMLUtil.getNamedChild(adl, "description");
    Element details = XMLUtil.getNamedChild(description, "details");
    sd.setDescription(XMLUtil.getNamedChild(details, "purpose").getTextContent());
    sd.setCopyright(XMLUtil.getNamedChild(details, "copyright").getTextContent());
    sd.setPurpose("Use:\r\n" + XMLUtil.getNamedChild(details, "use").getTextContent() + "\r\n\r\nMisuse:\r\n" + XMLUtil.getNamedChild(details, "misuse").getTextContent());
    List<Element> set = new ArrayList<Element>();
    XMLUtil.getNamedChildren(details, "keywords", set);
    for (Element e : set) sd.addKeyword().setDisplay(e.getTextContent());
    String status = XMLUtil.getNamedChild(description, "lifecycle_state").getTextContent();
    if ("CommitteeDraft".equals(status) || "AuthorDraft".equals(status))
        sd.setStatus(PublicationStatus.DRAFT);
    else
        throw new Exception("Unknown life cycle state " + XMLUtil.getNamedChild(description, "lifecycle_state").getTextContent());
    // load texts from ontology
    Element ontology = XMLUtil.getNamedChild(adl, "ontology");
    Element term_definitions = XMLUtil.getNamedChild(ontology, "term_definitions");
    set.clear();
    XMLUtil.getNamedChildren(term_definitions, "items", set);
    for (Element item : set) {
        processTextItem(item);
    }
    // load data and protocol
    Element definition = XMLUtil.getNamedChild(adl, "definition");
    NodeTreeEntry root = new NodeTreeEntry();
    root.setTypeName(XMLUtil.getNamedChild(definition, "rm_type_name").getTextContent());
    root.setAtCode(XMLUtil.getNamedChild(definition, "node_id").getTextContent());
    root.setName(generateToken(root.getAtCode(), true));
    sd.setName(root.getName());
    root.setCardinality(readCardinality("root", XMLUtil.getNamedChild(definition, "occurrences")));
    set.clear();
    XMLUtil.getNamedChildren(definition, "attributes", set);
    for (Element item : set) {
        // we're actually skipping this level - we don't care about data protocol etc.
        // XMLUtil.getNamedChild(XMLUtil.getNamedChild(item, "children"), "attributes");
        Element attributes = item;
        loadChildren(root.getAtCode(), root, attributes);
    }
    dumpChildren("", root);
    genElements(sd, root.getName(), root);
    // save
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(dest), sd);
    System.out.println("done. saved as " + dest);
}
Also used : XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) StructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Element(org.w3c.dom.Element) FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList) FileInputStream(java.io.FileInputStream)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)51 ArrayList (java.util.ArrayList)41 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)36 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)27 Test (org.junit.jupiter.api.Test)23 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)20 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)18 Reference (org.hl7.fhir.r4.model.Reference)17 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)17 HashMap (java.util.HashMap)15 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)15 Coding (org.hl7.fhir.r4.model.Coding)14 Identifier (org.hl7.fhir.r4.model.Identifier)14 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)13 Patient (org.hl7.fhir.r4.model.Patient)13 IOException (java.io.IOException)12 Header (org.apache.http.Header)11 Test (org.junit.Test)11 File (java.io.File)10 URISyntaxException (java.net.URISyntaxException)10