org.hl7.fhir.dstu3.model.Practitioner Java Examples

The following examples show how to use org.hl7.fhir.dstu3.model.Practitioner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArgonautConverter.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void makeDocumentReference(CDAUtilities cda, Convert convert, Element doc, Context context) throws Exception {
	scanSection("document", doc);
	DocumentReference ref = new DocumentReference();
	ref.setId(context.baseId+"-document");
	ref.setMasterIdentifier(convert.makeIdentifierFromII(cda.getChild(doc, "id")));
	ref.setSubject(context.subjectRef);
	ref.setType(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(doc, "code")), null));
	ref.addAuthor(context.authorRef);
	ref.setCreatedElement(convert.makeDateTimeFromTS(cda.getChild(doc, "effectiveTime")));
	ref.setIndexedElement(InstantType.now());
	ref.setStatus(DocumentReferenceStatus.CURRENT);
	ref.addSecurityLabel(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(doc, "confidentialityCode")), null));
	DocumentReferenceContentComponent cnt = ref.addContent();
	cnt.getAttachment().setContentType("application/hl7-v3+xml").setUrl("Binary/"+context.baseId).setLanguage(convertLanguage(cda.getChild(doc, "language")));
	//		for (Element ti : cda.getChildren(doc, "templateId"))
	//			cnt.addFormat().setSystem("urn:oid:1.3.6.1.4.1.19376.1.2.3").setCode(value)("urn:oid:"+ti.getAttribute("root"));
	ref.setContext(new DocumentReferenceContextComponent());
	ref.getContext().setPeriod(convert.makePeriodFromIVL(cda.getChild(cda.getChild(doc, "serviceEvent"), "effectiveTime")));
	for (CodeableConcept cc : context.encounter.getType())
		ref.getContext().addEvent(cc);
	ref.setDescription(cda.getChild(doc, "title").getTextContent());
	ref.setCustodian(new Reference().setReference("Organization/"+processOrganization(cda.getDescendent(doc, "custodian/assignedCustodian/representedCustodianOrganization"), cda, convert, context).getId()));
	Practitioner p = processPerformer(cda, convert, context, cda.getChild(doc, "legalAuthenticator"), "assignedEntity", "assignedPerson");
	ref.setAuthenticator(new Reference().setReference("Practitioner/"+p.getId()).setDisplay(p.getUserString("display")));
	saveResource(ref);
}
 
Example #2
Source File: PractitionerProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updatePractitioner(HttpServletRequest theRequest, @ResourceParam Practitioner practitioner, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);
    try {
    Practitioner newPractitioner = practitionerDao.create(ctx,practitioner, theId, theConditional);
    method.setId(newPractitioner.getIdElement());
    method.setResource(newPractitioner);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example #3
Source File: PractitionerProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome createPractitioner(HttpServletRequest theRequest, @ResourceParam Practitioner practitioner) {

	resourcePermissionProvider.checkPermission("create");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);
    try {
    Practitioner newPractitioner = practitionerDao.create(ctx,practitioner, null, null);
    method.setId(newPractitioner.getIdElement());
    method.setResource(newPractitioner);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #4
Source File: ArgonautConverter.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private Practitioner makeAuthor(CDAUtilities cda, Convert convert, Element doc, Context context, String id) throws Exception {
	Element a = cda.getChild(doc, "author");
	scanSection("Author", a);
	Practitioner author = processPerformer(cda, convert, context, a, "assignedAuthor", "assignedPerson");
	context.authorRef = new Reference().setDisplay(author.getUserString("display")).setReference("Practitioner/"+author.getId());
	return author;
}
 
Example #5
Source File: PractitionerProvider.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@Read
public Practitioner getPractitioner
        (@IdParam IdType internalId) {
	resourcePermissionProvider.checkPermission("read");
    Practitioner practitioner = practitionerDao.read(ctx, internalId);

    if ( practitioner == null) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(
                new ResourceNotFoundException("No Patient/" + internalId.getIdPart()),
                 OperationOutcome.IssueType.NOTFOUND);
    }

    return practitioner;
}
 
Example #6
Source File: PractitionerEntityToFHIRPractitionerTransformerTest.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@Test
public void testTransformer(){

    PractitionerEntity practitionerEntity = new PractitionerEntityBuilder()
            .addName("Dr", "Jenny", "Jones")
            .addAddress("Church Lane Surgery", "Holmfirth", null,
                    "Halifax", "West Yorkshire", "HX1 2TT")
            .build();

    Practitioner practitioner = transformer.transform(practitionerEntity);
    assertThat(practitioner, not(nullValue()));
    assertThat(practitioner.getId(), not(nullValue()));
    assertThat(practitioner.getId(), equalTo((new Long(PractitionerEntityBuilder.DEFAULT_ID)).toString()));
    assertThat(practitioner.getActive(), equalTo(true));

    List<HumanName> practitionerNames = practitioner.getName();
    assertThat(practitionerNames, not(nullValue()));
    assertThat(practitionerNames.size(), equalTo(1));
    //assertThat(practitionerNames.get(0).getUse(), equalTo(HumanName.NameUse.USUAL));
    HumanName name = practitionerNames.get(0);
    assertThat(name.getPrefixAsSingleString(), equalTo("Dr"));
    assertThat(name.getGivenAsSingleString(), equalTo("Jenny"));
    assertThat(name.getFamily(), equalTo("Jones"));

    assertThat(practitioner.getAddress(), not(nullValue()));
    List<Address> addresses = practitioner.getAddress();
    assertThat(addresses.size(), equalTo(1));
    Address address = addresses.get(0);
    assertThat(address.getLine().get(0).getValue(), equalTo("Church Lane Surgery"));
    assertThat(address.getLine().get(1).getValue(), equalTo("Holmfirth"));
    assertThat(address.getLine().size(), equalTo(2));
    assertThat(address.getDistrict(), equalTo("West Yorkshire"));
    assertThat(address.getCity(), equalTo("Halifax"));
    assertThat(address.getPostalCode(), equalTo("HX1 2TT"));
    assertThat(address.getUse(), equalTo(Address.AddressUse.WORK));

}
 
Example #7
Source File: FhirStu3.java    From synthea with Apache License 2.0 5 votes vote down vote up
/**
 * Find the Practitioner entry in this bundle, and return the associated "fullUrl"
 * attribute.
 * @param clinician A given clinician.
 * @param bundle The current bundle being generated.
 * @return Practitioner.fullUrl if found, otherwise null.
 */
private static String findPractitioner(Clinician clinician, Bundle bundle) {
  for (BundleEntryComponent entry : bundle.getEntry()) {
    if (entry.getResource().fhirType().equals("Practitioner")) {
      Practitioner doc = (Practitioner) entry.getResource();
      if (doc.getIdentifierFirstRep().getValue().equals("" + clinician.identifier)) {
        return entry.getFullUrl();
      }
    }
  }
  return null;
}
 
Example #8
Source File: FhirStu3.java    From synthea with Apache License 2.0 5 votes vote down vote up
/**
 * Map the clinician into a FHIR Practitioner resource, and add it to the given Bundle.
 * @param bundle The Bundle to add to
 * @param clinician The clinician
 * @return The added Entry
 */
protected static BundleEntryComponent practitioner(Bundle bundle, Clinician clinician) {
  Practitioner practitionerResource = new Practitioner();

  practitionerResource.addIdentifier().setSystem("http://hl7.org/fhir/sid/us-npi")
  .setValue("" + clinician.identifier);
  practitionerResource.setActive(true);
  practitionerResource.addName().setFamily(
      (String) clinician.attributes.get(Clinician.LAST_NAME))
    .addGiven((String) clinician.attributes.get(Clinician.FIRST_NAME))
    .addPrefix((String) clinician.attributes.get(Clinician.NAME_PREFIX));

  Address address = new Address()
      .addLine((String) clinician.attributes.get(Clinician.ADDRESS))
      .setCity((String) clinician.attributes.get(Clinician.CITY))
      .setPostalCode((String) clinician.attributes.get(Clinician.ZIP))
      .setState((String) clinician.attributes.get(Clinician.STATE));
  if (COUNTRY_CODE != null) {
    address.setCountry(COUNTRY_CODE);
  }
  practitionerResource.addAddress(address);

  if (clinician.attributes.get(Person.GENDER).equals("M")) {
    practitionerResource.setGender(AdministrativeGender.MALE);
  } else if (clinician.attributes.get(Person.GENDER).equals("F")) {
    practitionerResource.setGender(AdministrativeGender.FEMALE);
  }

  return newEntry(bundle, practitionerResource, clinician.getResourceID());
}
 
Example #9
Source File: PractitionerProvider.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public Class<Practitioner> getResourceType() {
    return Practitioner.class;
}
 
Example #10
Source File: PractitionerProvider.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Validate
public MethodOutcome testResource(@ResourceParam Practitioner resource,
                              @Validate.Mode ValidationModeEnum theMode,
                              @Validate.Profile String theProfile) {
    return resourceTestProvider.testResource(resource,theMode,theProfile);
}
 
Example #11
Source File: PractitionerEntityToFHIRPractitionerTransformer.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public Practitioner transform(final PractitionerEntity practitionerEntity) {
    final Practitioner practitioner = new Practitioner();

    Meta meta = new Meta().addProfile(CareConnectProfile.Practitioner_1);

    if (practitionerEntity.getUpdated() != null) {
        meta.setLastUpdated(practitionerEntity.getUpdated());
    }
    else {
        if (practitionerEntity.getCreated() != null) {
            meta.setLastUpdated(practitionerEntity.getCreated());
        }
    }
    practitioner.setMeta(meta);
    if (practitionerEntity.getActive() != null) {
        practitioner.setActive(practitionerEntity.getActive());
    }

    for(PractitionerIdentifier identifier :practitionerEntity.getIdentifiers())
    {
        Identifier ident = practitioner.addIdentifier();
        ident = daoutils.getIdentifier(identifier, ident);
    }

    practitioner.setId(practitionerEntity.getId().toString());

    if (practitionerEntity.getNames().size() > 0) {

        practitioner.addName()
                .setFamily(practitionerEntity.getNames().get(0).getFamilyName())
                .addGiven(practitionerEntity.getNames().get(0).getGivenName())
                .addPrefix(practitionerEntity.getNames().get(0).getPrefix());
    }
    for(int f=0;f<practitionerEntity.getTelecoms().size();f++)
    {
        practitioner.addTelecom()
                .setSystem(practitionerEntity.getTelecoms().get(f).getSystem())
                .setValue(practitionerEntity.getTelecoms().get(f).getValue())
                .setUse(practitionerEntity.getTelecoms().get(f).getTelecomUse());
    }


    for (PractitionerAddress practitionerAddress : practitionerEntity.getAddresses()){
        Address address = addressTransformer.transform(practitionerAddress);
        practitioner.addAddress(address);
    }

    if (practitionerEntity.getGender() !=null)
    {
        practitioner.setGender(daoutils.getGender(practitionerEntity.getGender()));
    }

    return practitioner;

}
 
Example #12
Source File: PractitionerBuilder.java    From cqf-ruler with Apache License 2.0 4 votes vote down vote up
public PractitionerBuilder() {
    super(new Practitioner());
}
 
Example #13
Source File: PractitionerRepository.java    From careconnect-reference-implementation with Apache License 2.0 votes vote down vote up
Practitioner read(FhirContext ctx, IdType theId); 
Example #14
Source File: PractitionerRepository.java    From careconnect-reference-implementation with Apache License 2.0 votes vote down vote up
Practitioner create(FhirContext ctx, Practitioner practitioner, @IdParam IdType theId, @ConditionalUrlParam String theConditional) throws OperationOutcomeException;