Search in sources :

Example 11 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class IEEE11073Convertor method generateLoincMdcMap.

private static ConceptMap generateLoincMdcMap(CodeSystem mdc, String dst, String src) throws IOException, FHIRException {
    ConceptMap cm = new ConceptMap();
    cm.setId("loinc-mdc");
    cm.setUrl("http:/???/fhir/ConceptMap/loinc-mdc");
    cm.setVersion("[todo]");
    cm.setName("LoincMdcCrossMap");
    cm.setTitle("Cross Map between LOINC and MDC");
    cm.setStatus(PublicationStatus.DRAFT);
    cm.setExperimental(true);
    cm.setDateElement(new DateTimeType());
    cm.setPublisher("HL7, Inc");
    ContactDetail cd = cm.addContact();
    cd.setName("LOINC + IEEE");
    ContactPoint cp = cd.addTelecom();
    cp.setSystem(ContactPointSystem.URL);
    cp.setValue("http://loinc.org");
    cm.setDescription("A Cross Map between the LOINC and MDC Code systems");
    cm.setPurpose("To implementers map between medical device codes and LOINC codes");
    cm.setCopyright("This content LOINC \u00ae is copyright \u00a9 1995 Regenstrief Institute, Inc. and the LOINC Committee, and available at no cost under the license at http://loinc.org/terms-of-use");
    cm.setSource(new UriType("http://loinc.org/vs"));
    cm.setTarget(new UriType(MDC_ALL_VALUES));
    ConceptMapGroupComponent g = cm.addGroup();
    g.setSource("urn:iso:std:iso:11073:10101");
    g.setTarget("http://loinc.org");
    CSVReader csv = new CSVReader(new FileInputStream(src));
    csv.readHeaders();
    while (csv.line()) {
        SourceElementComponent e = g.addElement();
        e.setCode(csv.cell("IEEE_CF_CODE10"));
        e.setDisplay(csv.cell("IEEE_DESCRIPTION"));
        TargetElementComponent t = e.addTarget();
        t.setEquivalence(ConceptMapEquivalence.EQUIVALENT);
        t.setCode(csv.cell("LOINC_NUM"));
        t.setDisplay(csv.cell("LOINC_LONG_COMMON_NAME"));
    }
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "conceptmap-" + cm.getId() + ".xml")), cm);
    System.out.println("Done");
    return cm;
}
Also used : XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) CSVReader(org.hl7.fhir.utilities.CSVReader) FileOutputStream(java.io.FileOutputStream) TargetElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent) ConceptMapGroupComponent(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent) FileInputStream(java.io.FileInputStream) SourceElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent)

Example 12 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class IEEE11073Convertor method generateMDC.

public static CodeSystem generateMDC(String src, String dst, UcumService ucum) throws IOException, FHIRException {
    CSVReader csv = new CSVReader(new FileInputStream(src));
    csv.readHeaders();
    CodeSystem cs = new CodeSystem();
    Map<String, String> ucumIssues = new HashMap<String, String>();
    int errorCount = 0;
    cs.setId("MDC");
    cs.setUrl("urn:iso:std:iso:11073:10101");
    cs.setVersion("[todo]");
    cs.setName("11073:10101 codes for the FHIR community");
    cs.setStatus(PublicationStatus.ACTIVE);
    cs.setExperimental(false);
    cs.setDateElement(new DateTimeType());
    cs.setPublisher("HL7 (FHIR Project)");
    ContactDetail cd = cs.addContact();
    ContactPoint cp = cd.addTelecom();
    cp.setSystem(ContactPointSystem.URL);
    cp.setValue("http://ieee?");
    cs.setDescription("1073 Codes for the FHIR community (generated from the Rosetta data");
    Identifier i = new Identifier();
    cs.setIdentifier(i);
    i.setSystem("urn:ietf:rfc:3986");
    i.setValue("urn:oid:2.16.840.1.113883.6.24");
    cs.setCaseSensitive(false);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    cs.addProperty().setCode("ucum").setDescription("UCUM units associated with Concept").setType(PropertyType.STRING);
    cs.addProperty().setCode("unit").setDescription("MDC units associated with Concept").setType(PropertyType.STRING);
    cs.addProperty().setCode("refid").setDescription("MDC Reference Id for Concept").setType(PropertyType.CODE);
    Set<String> codes = new HashSet<String>();
    while (csv.line()) {
        if (csv.has("CF_CODE10")) {
            String code = csv.cell("CF_CODE10");
            if (codes.contains(code))
                System.out.println("Duplicate Code " + code);
            else {
                codes.add(code);
                ConceptDefinitionComponent c = cs.addConcept();
                c.setCode(code);
                c.setDisplay(csv.cell("Common Term"));
                c.setDefinition(csv.cell("Term Description"));
                String vd = csv.cell("Vendor_Description");
                if (!c.hasDefinition())
                    c.setDefinition(vd);
                if (!c.hasDisplay())
                    c.setDisplay(vd);
                String refid = csv.cell("REFID");
                c.addProperty().setCode("refid").setValue(new CodeType().setValue(refid));
                if (csv.has("Synonym"))
                    c.addDesignation().setValue(csv.cell("Synonym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("synonym"));
                if (csv.has("Acronym"))
                    c.addDesignation().setValue(csv.cell("Acronym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setDisplay("acronym"));
                if (csv.has("Systematic Name")) {
                    String sysName = csv.cell("Systematic Name");
                    if (!c.hasDefinition())
                        c.setDefinition(sysName);
                    c.addDesignation().setValue(sysName).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("structured-name"));
                }
                if (csv.has("UOM_MDC"))
                    c.addProperty().setCode("unit").setValue(new StringType().setValue(csv.cell("UOM_MDC")));
                if (csv.has("UOM_UCUM")) {
                    CommaSeparatedStringBuilder ul = new CommaSeparatedStringBuilder();
                    for (String u : csv.cell("UOM_UCUM").split(" ")) {
                        String msg = ucum.validate(u);
                        if (msg != null) {
                            errorCount++;
                            ucumIssues.put(u, msg);
                        } else
                            ul.append(u);
                    }
                    if (ul.length() > 0)
                        c.addProperty().setCode("ucum").setValue(new StringType().setValue(ul.toString()));
                }
            }
        }
    }
    csv.close();
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "codesystem-" + cs.getId() + ".xml")), cs);
    System.out.println(errorCount + "UCUM errors");
    for (String u : sorted(ucumIssues.keySet())) System.out.println("Invalid UCUM code: " + u + " because " + ucumIssues.get(u));
    return cs;
}
Also used : XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) CSVReader(org.hl7.fhir.utilities.CSVReader) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) FileInputStream(java.io.FileInputStream) ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent) FileOutputStream(java.io.FileOutputStream)

Example 13 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeContactDetail.

protected void composeContactDetail(Complex parent, String parentType, String name, ContactDetail element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeElement(t, "ContactDetail", name, element, index);
    if (element.hasNameElement())
        composeString(t, "ContactDetail", "name", element.getNameElement(), -1);
    for (int i = 0; i < element.getTelecom().size(); i++) composeContactPoint(t, "ContactDetail", "telecom", element.getTelecom().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 14 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class Questionnaire10_30 method convertQuestionnaire.

public static org.hl7.fhir.dstu2.model.Questionnaire convertQuestionnaire(org.hl7.fhir.dstu3.model.Questionnaire src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.dstu2.model.Questionnaire tgt = new org.hl7.fhir.dstu2.model.Questionnaire();
    ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt);
    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(Identifier10_30.convertIdentifier(t));
    if (src.hasVersionElement())
        tgt.setVersionElement(String10_30.convertString(src.getVersionElement()));
    if (src.hasStatus())
        tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement()));
    if (src.hasDate())
        tgt.setDateElement(DateTime10_30.convertDateTime(src.getDateElement()));
    if (src.hasPublisherElement())
        tgt.setPublisherElement(String10_30.convertString(src.getPublisherElement()));
    for (ContactDetail t : src.getContact()) for (org.hl7.fhir.dstu3.model.ContactPoint t1 : t.getTelecom()) tgt.addTelecom(ContactPoint10_30.convertContactPoint(t1));
    org.hl7.fhir.dstu2.model.Questionnaire.GroupComponent root = tgt.getGroup();
    root.setTitle(src.getTitle());
    for (org.hl7.fhir.dstu3.model.Coding t : src.getCode()) {
        root.addConcept(Coding10_30.convertCoding(t));
    }
    for (org.hl7.fhir.dstu3.model.CodeType t : src.getSubjectType()) tgt.addSubjectType(t.getValue());
    for (org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent t : src.getItem()) if (t.getType() == org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemType.GROUP)
        root.addGroup(convertQuestionnaireGroupComponent(t));
    else
        root.addQuestion(convertQuestionnaireQuestionComponent(t));
    return tgt;
}
Also used : ContactDetail(org.hl7.fhir.dstu3.model.ContactDetail)

Example 15 with ContactDetail

use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.

the class Questionnaire14_40 method convertQuestionnaire.

public static org.hl7.fhir.dstu2016may.model.Questionnaire convertQuestionnaire(org.hl7.fhir.r4.model.Questionnaire src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.dstu2016may.model.Questionnaire tgt = new org.hl7.fhir.dstu2016may.model.Questionnaire();
    ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyDomainResource(src, tgt);
    if (src.hasUrl())
        tgt.setUrlElement(Uri14_40.convertUri(src.getUrlElement()));
    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(Identifier14_40.convertIdentifier(t));
    if (src.hasVersion())
        tgt.setVersionElement(String14_40.convertString(src.getVersionElement()));
    if (src.hasStatus())
        tgt.setStatusElement(convertQuestionnaireStatus(src.getStatusElement()));
    if (src.hasDate())
        tgt.setDateElement(DateTime14_40.convertDateTime(src.getDateElement()));
    if (src.hasPublisher())
        tgt.setPublisherElement(String14_40.convertString(src.getPublisherElement()));
    for (ContactDetail t : src.getContact()) for (org.hl7.fhir.r4.model.ContactPoint t1 : t.getTelecom()) tgt.addTelecom(ContactPoint14_40.convertContactPoint(t1));
    for (UsageContext t : src.getUseContext()) tgt.addUseContext(CodeableConcept14_40.convertCodeableConcept(t.getValueCodeableConcept()));
    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) tgt.addUseContext(CodeableConcept14_40.convertCodeableConcept(t));
    if (src.hasTitle())
        tgt.setTitleElement(String14_40.convertString(src.getTitleElement()));
    for (org.hl7.fhir.r4.model.Coding t : src.getCode()) tgt.addConcept(Coding14_40.convertCoding(t));
    for (org.hl7.fhir.r4.model.CodeType t : src.getSubjectType()) tgt.addSubjectType(t.getValue());
    for (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent t : src.getItem()) tgt.addItem(convertQuestionnaireItemComponent(t));
    return tgt;
}
Also used : ContactDetail(org.hl7.fhir.r4.model.ContactDetail) UsageContext(org.hl7.fhir.r4.model.UsageContext)

Aggregations

ContactDetail (org.hl7.fhir.dstu3.model.ContactDetail)15 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)15 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)9 ContactDetail (org.hl7.fhir.r4b.model.ContactDetail)7 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)7 CodeType (org.hl7.fhir.r5.model.CodeType)6 NotImplementedException (org.apache.commons.lang3.NotImplementedException)5 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)5 HashSet (java.util.HashSet)4 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)4 ContactPoint (org.hl7.fhir.r4b.model.ContactPoint)4 Gson (com.google.gson.Gson)3 GsonBuilder (com.google.gson.GsonBuilder)3 JsonArray (com.google.gson.JsonArray)3 JsonObject (com.google.gson.JsonObject)3 FileOutputStream (java.io.FileOutputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 HashMap (java.util.HashMap)3 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)3 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)3