Search in sources :

Example 1 with Coding

use of org.hl7.fhir.dstu2.model.Coding in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method setStaticPatientData.

private Patient setStaticPatientData(Patient patient) {
    patient.setLanguage(("en-GB"));
    patient.addExtension(createCodingExtension("CG", "Greek Cypriot", SystemURL.CS_CC_ETHNIC_CATEGORY, SystemURL.SD_CC_EXT_ETHNIC_CATEGORY));
    patient.addExtension(createCodingExtension("SomeSnomedCode", "Some Snomed Code", SystemURL.CS_CC_RELIGIOUS_AFFILI, SystemURL.SD_CC_EXT_RELIGIOUS_AFFILI));
    patient.addExtension(new Extension(SystemURL.SD_PATIENT_CADAVERIC_DON, new BooleanType(false)));
    patient.addExtension(createCodingExtension("H", "UK Resident", SystemURL.CS_CC_RESIDENTIAL_STATUS, SystemURL.SD_CC_EXT_RESIDENTIAL_STATUS));
    patient.addExtension(createCodingExtension("3", "To pay hotel fees only", SystemURL.CS_CC_TREATMENT_CAT, SystemURL.SD_CC_EXT_TREATMENT_CAT));
    Extension nhsCommExtension = new Extension();
    nhsCommExtension.setUrl(SystemURL.SD_CC_EXT_NHS_COMMUNICATION);
    nhsCommExtension.addExtension(createCodingExtension("en", "English", SystemURL.CS_CC_HUMAN_LANG, SystemURL.SD_CC_EXT_COMM_LANGUAGE));
    nhsCommExtension.addExtension(new Extension(SystemURL.SD_CC_COMM_PREFERRED, new BooleanType(false)));
    nhsCommExtension.addExtension(createCodingExtension("RWR", "Received written", SystemURL.CS_CC_LANG_ABILITY_MODE, SystemURL.SD_CC_MODE_OF_COMM));
    nhsCommExtension.addExtension(createCodingExtension("E", "Excellent", SystemURL.CS_CC_LANG_ABILITY_PROFI, SystemURL.SD_CC_COMM_PROFICIENCY));
    nhsCommExtension.addExtension(new Extension(SystemURL.SD_CC_INTERPRETER_REQUIRED, new BooleanType(false)));
    patient.addExtension(nhsCommExtension);
    Identifier localIdentifier = new Identifier();
    localIdentifier.setUse(IdentifierUse.USUAL);
    localIdentifier.setSystem(SystemURL.ID_LOCAL_PATIENT_IDENTIFIER);
    localIdentifier.setValue("123456");
    CodeableConcept liType = new CodeableConcept();
    Coding liTypeCoding = new Coding();
    liTypeCoding.setCode("EN");
    liTypeCoding.setDisplay("Employer number");
    liTypeCoding.setSystem(SystemURL.VS_IDENTIFIER_TYPE);
    liType.addCoding(liTypeCoding);
    localIdentifier.setType(liType);
    localIdentifier.setAssigner(new Reference("Organization/1"));
    patient.addIdentifier(localIdentifier);
    Calendar calendar = Calendar.getInstance();
    calendar.set(2017, 1, 1);
    DateTimeDt endDate = new DateTimeDt(calendar.getTime());
    calendar.set(2016, 1, 1);
    DateTimeDt startDate = new DateTimeDt(calendar.getTime());
    Period pastPeriod = new Period().setStart(calendar.getTime()).setEnd(calendar.getTime());
    patient.addName().setFamily("AnotherOfficialFamilyName").addGiven("AnotherOfficialGivenName").setUse(NameUse.OFFICIAL).setPeriod(pastPeriod);
    patient.addName().setFamily("AdditionalFamily").addGiven("AdditionalGiven").setUse(NameUse.TEMP);
    patient.addTelecom(staticElHelper.getValidTelecom());
    patient.addAddress(staticElHelper.getValidAddress());
    return patient;
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) Identifier(org.hl7.fhir.dstu3.model.Identifier) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) Coding(org.hl7.fhir.dstu3.model.Coding) Reference(org.hl7.fhir.dstu3.model.Reference) Calendar(java.util.Calendar) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) Period(org.hl7.fhir.dstu3.model.Period) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 2 with Coding

use of org.hl7.fhir.dstu2.model.Coding in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method createCoding.

private CodeableConcept createCoding(String code, String display, String vsSystem) {
    Coding coding = new Coding();
    coding.setCode(code);
    coding.setDisplay(display);
    coding.setSystem(vsSystem);
    CodeableConcept concept = new CodeableConcept();
    concept.addCoding(coding);
    return concept;
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 3 with Coding

use of org.hl7.fhir.dstu2.model.Coding in project gpconnect-demonstrator by nhsconnect.

the class PractitionerResourceProvider method practitionerDetailsToPractitionerResourceConverter.

private Practitioner practitionerDetailsToPractitionerResourceConverter(PractitionerDetails practitionerDetails) {
    Identifier identifier = new Identifier().setSystem(SystemURL.ID_SDS_USER_ID).setValue(practitionerDetails.getUserId());
    Practitioner practitioner = new Practitioner().addIdentifier(identifier);
    practitionerDetails.getRoleIds().stream().distinct().map(roleId -> new Identifier().setSystem(SystemURL.ID_SDS_ROLE_PROFILE_ID).setValue(roleId)).forEach(practitioner::addIdentifier);
    String resourceId = String.valueOf(practitionerDetails.getId());
    String versionId = String.valueOf(practitionerDetails.getLastUpdated().getTime());
    String resourceType = practitioner.getResourceType().toString();
    IdType id = new IdType(resourceType, resourceId, versionId);
    practitioner.setId(id);
    practitioner.getMeta().setVersionId(versionId);
    practitioner.getMeta().setLastUpdated(practitionerDetails.getLastUpdated());
    practitioner.getMeta().addProfile(SystemURL.SD_GPC_PRACTITIONER);
    HumanName name = new HumanName().setFamily(practitionerDetails.getNameFamily()).addGiven(practitionerDetails.getNameGiven()).addPrefix(practitionerDetails.getNamePrefix()).setUse(NameUse.USUAL);
    practitioner.addName(name);
    switch(practitionerDetails.getGender().toLowerCase(Locale.UK)) {
        case "male":
            practitioner.setGender(AdministrativeGender.MALE);
            break;
        case "female":
            practitioner.setGender(AdministrativeGender.FEMALE);
            break;
        case "other":
            practitioner.setGender(AdministrativeGender.OTHER);
            break;
        default:
            practitioner.setGender(AdministrativeGender.UNKNOWN);
            break;
    }
    Coding roleCoding = new Coding(SystemURL.VS_SDS_JOB_ROLE_NAME, practitionerDetails.getRoleCode(), practitionerDetails.getRoleDisplay());
    for (int i = 0; i < practitionerDetails.getComCode().size(); i++) {
        Coding comCoding = new Coding(SystemURL.VS_HUMAN_LANGUAGE, practitionerDetails.getComCode().get(i), null).setDisplay(practitionerDetails.getComDisplay().get(i));
        practitioner.addCommunication().addCoding(comCoding);
    }
    return practitioner;
}
Also used : Practitioner(org.hl7.fhir.dstu3.model.Practitioner) IdParam(ca.uhn.fhir.rest.annotation.IdParam) Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) IdType(org.hl7.fhir.dstu3.model.IdType) Autowired(org.springframework.beans.factory.annotation.Autowired) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) Extension(org.hl7.fhir.dstu3.model.Extension) RequiredParam(ca.uhn.fhir.rest.annotation.RequiredParam) Locale(java.util.Locale) Search(ca.uhn.fhir.rest.annotation.Search) IResourceProvider(ca.uhn.fhir.rest.server.IResourceProvider) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Location(org.hl7.fhir.dstu3.model.Location) Read(ca.uhn.fhir.rest.annotation.Read) Practitioner(org.hl7.fhir.dstu3.model.Practitioner) Sort(ca.uhn.fhir.rest.annotation.Sort) Count(ca.uhn.fhir.rest.annotation.Count) Collectors(java.util.stream.Collectors) SystemURL(uk.gov.hscic.SystemURL) IssueType(org.hl7.fhir.dstu3.model.OperationOutcome.IssueType) TokenParam(ca.uhn.fhir.rest.param.TokenParam) PractitionerDetails(uk.gov.hscic.model.practitioner.PractitionerDetails) AdministrativeGender(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender) OperationOutcomeFactory(uk.gov.hscic.OperationOutcomeFactory) List(java.util.List) Component(org.springframework.stereotype.Component) SortSpec(ca.uhn.fhir.rest.api.SortSpec) IdentifierValidator(uk.gov.hscic.common.validators.IdentifierValidator) SystemCode(uk.gov.hscic.SystemCode) Collections(java.util.Collections) HumanName(org.hl7.fhir.dstu3.model.HumanName) NameUse(org.hl7.fhir.dstu3.model.HumanName.NameUse) HumanName(org.hl7.fhir.dstu3.model.HumanName) Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) IdType(org.hl7.fhir.dstu3.model.IdType)

Example 4 with Coding

use of org.hl7.fhir.dstu2.model.Coding in project loinc2hpo by monarch-initiative.

the class ObservationAnalysisFromInterpretation method getHPOforObservation.

@Override
public HpoTermId4LoincTest getHPOforObservation() throws UnsupportedCodingSystemException, AmbiguousResultsFoundException, AnnotationNotFoundException, UnrecognizedCodeException {
    // here we use a map to store the results: since there could be more than one interpretation coding system,
    // we try them all and store the results in a map <external code, result in internal code>
    Map<Code, Code> results = new HashMap<>();
    // get the annotation class for this loinc code
    UniversalLoinc2HPOAnnotation annotationForLoinc = annotationMap.get(this.loincId);
    if (annotationForLoinc == null)
        throw new AnnotationNotFoundException();
    // all interpretation codes in different coding systems. Expect one in most cases.
    Set<Code> interpretationCodes = getInterpretationCodes();
    interpretationCodes.stream().filter(p -> CodeSystemConvertor.getCodeContainer().getCodeSystemMap().containsKey(p.getSystem())).forEach(p -> {
        Code internalCode = null;
        try {
            internalCode = CodeSystemConvertor.convertToInternalCode(p);
            results.put(p, internalCode);
        } catch (InternalCodeNotFoundException e) {
            e.printStackTrace();
        }
    });
    List<Code> distinct = results.values().stream().distinct().collect(Collectors.toList());
    if (distinct.size() == 1) {
        HpoTermId4LoincTest hpoTermId4LoincTest = annotationForLoinc.loincInterpretationToHPO(distinct.get(0));
        if (hpoTermId4LoincTest == null)
            throw new UnrecognizedCodeException();
        return hpoTermId4LoincTest;
    } else {
        throw new AmbiguousResultsFoundException();
    }
}
Also used : java.util(java.util) HpoTermId4LoincTest(org.monarchinitiative.loinc2hpo.loinc.HpoTermId4LoincTest) LoincId(org.monarchinitiative.loinc2hpo.loinc.LoincId) UniversalLoinc2HPOAnnotation(org.monarchinitiative.loinc2hpo.loinc.UniversalLoinc2HPOAnnotation) CodeSystemConvertor(org.monarchinitiative.loinc2hpo.codesystems.CodeSystemConvertor) Loinc2HPOAnnotation(org.monarchinitiative.loinc2hpo.loinc.Loinc2HPOAnnotation) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) Code(org.monarchinitiative.loinc2hpo.codesystems.Code) org.monarchinitiative.loinc2hpo.exception(org.monarchinitiative.loinc2hpo.exception) Collectors(java.util.stream.Collectors) UniversalLoinc2HPOAnnotation(org.monarchinitiative.loinc2hpo.loinc.UniversalLoinc2HPOAnnotation) HpoTermId4LoincTest(org.monarchinitiative.loinc2hpo.loinc.HpoTermId4LoincTest) Code(org.monarchinitiative.loinc2hpo.codesystems.Code)

Example 5 with Coding

use of org.hl7.fhir.dstu2.model.Coding in project loinc2hpo by monarch-initiative.

the class CodeSystemInternal method init.

@Override
protected void init() {
    final Coding BELOWNORMAL = new Coding(INTERNALSYSTEM, "L", "below normal range");
    final Coding NORMAL = new Coding(INTERNALSYSTEM, "N", "within normal range");
    final Coding ABOVENORMAL = new Coding(INTERNALSYSTEM, "H", "above normal range");
    final Coding ABSENCE = new Coding(INTERNALSYSTEM, "NP", "not present");
    final Coding PRESENCE = new Coding(INTERNALSYSTEM, "P", "present");
    final Coding UNKNOWN = new Coding(INTERNALSYSTEM, "unknown", "unknown");
    codes.put(BELOWNORMAL.getCode(), BELOWNORMAL);
    codes.put(NORMAL.getCode(), NORMAL);
    codes.put(ABOVENORMAL.getCode(), ABOVENORMAL);
    codes.put(ABSENCE.getCode(), ABSENCE);
    codes.put(PRESENCE.getCode(), PRESENCE);
    codes.put(UNKNOWN.getCode(), UNKNOWN);
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding)

Aggregations

Coding (org.hl7.fhir.r4.model.Coding)626 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)369 Test (org.junit.jupiter.api.Test)344 Test (org.junit.Test)175 ArrayList (java.util.ArrayList)132 Money (org.hl7.fhir.r4.model.Money)117 Coding (org.hl7.fhir.dstu3.model.Coding)114 Extension (org.hl7.fhir.r4.model.Extension)76 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)73 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)68 Date (java.util.Date)66 AdjudicationComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.AdjudicationComponent)65 FHIRException (org.hl7.fhir.exceptions.FHIRException)63 SupportingInformationComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent)62 Reference (org.hl7.fhir.r4.model.Reference)62 Bundle (org.hl7.fhir.r4.model.Bundle)58 BenefitComponent (org.hl7.fhir.r4.model.ExplanationOfBenefit.BenefitComponent)57 Coding (org.hl7.fhir.r5.model.Coding)54 Observation (org.hl7.fhir.r4.model.Observation)49 DecimalType (org.hl7.fhir.r4.model.DecimalType)46