@History() public List<Patient> getPatientHistory( @IdParam IdType theId, @Since InstantType theSince, @At DateRangeParam theAt ) { List<Patient> retVal = new ArrayList<Patient>(); Patient patient = new Patient(); patient.addName().setFamily("Smith"); // Set the ID and version patient.setId(theId.withVersion("1")); // ...populate the rest... return retVal; } //END SNIPPET: history
@SuppressWarnings("unused") public static void creatingContextHl7org() { // START SNIPPET: creatingContextHl7org // Create a context for DSTU3 FhirContext ctx = FhirContext.forDstu3(); // Working with RI structures is similar to how it works with the HAPI structures org.hl7.fhir.dstu3.model.Patient patient = new org.hl7.fhir.dstu3.model.Patient(); patient.addName().addGiven("John").setFamily("Smith"); patient.getBirthDateElement().setValueAsString("1998-02-22"); // Parsing and encoding works the same way too String encoded = ctx.newJsonParser().encodeResourceToString(patient); // END SNIPPET: creatingContextHl7org }
patient.addName().setFamily("Smith").addGiven("Tester").addGiven("Q");
p.addName().setFamily("Smith").addGiven("John").addGiven("Q"); p.addIdentifier().setSystem("urn:foo:identifiers").setValue("12345"); p.addTelecom().setSystem(ContactPointSystem.PHONE).setValue("416 123-4567");
@Read() public Patient getResourceById(@IdParam IdType theId) { Patient retVal = new Patient(); // ...populate... retVal.addIdentifier().setSystem("urn:mrns").setValue("12345"); retVal.addName().setFamily("Smith").addGiven("Tester").addGiven("Q"); // ...etc... // if you know the version ID of the resource, you should set it and HAPI will // include it in a Content-Location header retVal.setId(new IdType("Patient", "123", "2")); return retVal; } //END SNIPPET: read
public void clientRead() { //START SNIPPET: clientReadTags IPatientClient client = FhirContext.forDstu2().newRestfulClient(IPatientClient.class, "http://foo/fhir"); Patient patient = client.readPatient(new IdType("1234")); // Access the tag list List<Coding> tagList = patient.getMeta().getTag(); for (Coding next : tagList) { // ..process the tags somehow.. } //END SNIPPET: clientReadTags //START SNIPPET: clientCreateTags Patient newPatient = new Patient(); // Populate the resource object newPatient.addIdentifier().setUse(IdentifierUse.OFFICIAL).setValue("123"); newPatient.addName().setFamily("Jones").addGiven("Frank"); // Populate some tags newPatient.getMeta().addTag("http://animals", "Dog", "Canine Patient"); // TODO: more realistic example newPatient.getMeta().addTag("http://personality", "Friendly", "Friendly"); // TODO: more realistic example // ...invoke the create method on the client... //END SNIPPET: clientCreateTags }
/** * @return The first repetition of repeating field {@link #name}, creating it if it does not already exist */ public HumanName getNameFirstRep() { if (getName().isEmpty()) { addName(); } return getName().get(0); }
HumanName name = patient.addName(); name.setFamily("Shmoe");
tgt.setActive(src.getActive()); for (org.hl7.fhir.instance.model.HumanName t : src.getName()) tgt.addName(convertHumanName(t)); for (org.hl7.fhir.instance.model.ContactPoint t : src.getTelecom()) tgt.addTelecom(convertContactPoint(t));
public static void main(String[] theArgs) { // Create a resource instance Patient pat = new Patient(); // Add a "name" element HumanName name = pat.addName(); name.setFamily("Simpson").addGiven("Homer").addGiven("J"); // Add an "identifier" element Identifier identifier = pat.addIdentifier(); identifier.setSystem("http://acme.org/MRNs").setValue("7000135"); // Model is designed to be chained pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("12345"); } }
/** * @param jCas ye olde ... */ public FhirNoteSpecs( final JCas jCas ) { _noteSpecs = new NoteSpecs( jCas ); final String noteDateText = _noteSpecs.getNoteTime(); _clinicalNoteId = FhirElementFactory.createId( jCas, ID_NAME_CLINICAL_NOTE, noteDateText ); final Date noteDate = _noteSpecs.getNoteDate(); final long noteDateMillis = noteDate.getTime(); _period = FhirElementFactory.createPeriod( noteDateMillis, noteDateMillis + 1000 ); final Patient mainPatient = new Patient(); final String patientName = _noteSpecs.getPatientName(); mainPatient.addName( createHumanName( patientName ) ); mainPatient.setId( FhirElementFactory.createId( jCas, patientName, patientName.hashCode() ) ); _mainPatientRef = new Reference( mainPatient ); _subjectRefs = createSubjects( jCas ); final SourceData sourceData = SourceMetadataUtil.getSourceData( jCas ); final Encounter encounter = createEncounter( jCas, sourceData, noteDateText ); _encounterReference = new Reference( encounter ); }
public static void main(String[] theArgs) { // Create a resource instance Patient pat = new Patient(); // Add a "name" element HumanName name = pat.addName(); name.setFamily("Simpson").addGiven("Homer").addGiven("J"); // Add an "identifier" element Identifier identifier = pat.addIdentifier(); identifier.setSystem("http://acme.org/MRNs").setValue("7000135"); // Model is designed to be chained pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("12345"); } }
public static void main(String[] args) { // Create an encounter with an invalid status and no class Patient pat = new Patient(); pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("Jay"); pat.addAddress().addLine("342 Evergreen Terrace").addLine("Springfield"); pat.addIdentifier().setSystem("http://acme.org/mrns").setValue("12345"); // Create a new context and enable the narrative generator FhirContext ctx = FhirContext.forDstu2(); ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator()); String res = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(pat); System.out.println(res); }
public static void main(String[] theArgs) { Patient pat = new Patient(); pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J"); pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135"); // Enumerated types are provided for many coded elements ContactPoint contact = pat.addTelecom(); contact.setUse(ContactPoint.ContactPointUse.HOME); contact.setSystem(ContactPoint.ContactPointSystem.PHONE); contact.setValue("1 (416) 340-4800"); pat.setGender(Enumerations.AdministrativeGender.MALE); } }
public static void main(String[] theArgs) { Patient pat = new Patient(); pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J"); pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135"); // Enumerated types are provided for many coded elements ContactPoint contact = pat.addTelecom(); contact.setUse(ContactPoint.ContactPointUse.HOME); contact.setSystem(ContactPoint.ContactPointSystem.PHONE); contact.setValue("1 (416) 340-4800"); pat.setGender(Enumerations.AdministrativeGender.MALE); } }
public static void main(String[] theArgs) { Patient pat = new Patient(); pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J"); pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135"); pat.setGender(AdministrativeGender.MALE); // Create a context FhirContext ctx = FhirContext.forDstu3(); // Create a client String serverBaseUrl = "http://fhirtest.uhn.ca/baseDstu3"; IGenericClient client = ctx.newRestfulGenericClient(serverBaseUrl); // Use the client to store a new resource instance MethodOutcome outcome = client .create() .resource(pat) .execute(); // Print the ID of the newly created resource System.out.println(outcome.getId()); } }
public static void main(String[] theArgs) { // Create a Patient Patient pat = new Patient(); pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J"); pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135"); pat.addTelecom().setUse(ContactPointUse.HOME).setSystem(ContactPointSystem.PHONE).setValue("1 (416) 340-4800"); pat.setGender(AdministrativeGender.MALE); // Create a context FhirContext ctx = FhirContext.forDstu3(); // Create a JSON parser IParser parser = ctx.newJsonParser(); parser.setPrettyPrint(true); String encode = parser.encodeResourceToString(pat); System.out.println(encode); } }
public static void step3_create_patient() { // Create a patient Patient newPatient = new Patient(); // Populate the patient with fake information newPatient .addName() .setFamily("DevDays2015") .addGiven("John") .addGiven("Q"); newPatient .addIdentifier() .setSystem("http://acme.org/mrn") .setValue("1234567"); newPatient.setGender(Enumerations.AdministrativeGender.MALE); newPatient.setBirthDateElement(new DateType("2015-11-18")); // Create a client FhirContext ctx = FhirContext.forDstu3(); IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3"); // Create the resource on the server MethodOutcome outcome = client .create() .resource(newPatient) .execute(); // Log the ID that the server assigned IIdType id = outcome.getId(); System.out.println("Created patient, got ID: " + id); }
public static void main(String[] theArgs) { Patient pat = new Patient(); pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J"); // Add an extension on the resource pat.addExtension() .setUrl("http://hl7.org/fhir/StructureDefinition/patient-importance") .setValue(new CodeableConcept().setText("Patient is a VIP")); // Add an extension on a primitive pat.getBirthDateElement().setValueAsString("1955-02-22"); pat.getBirthDateElement().addExtension() .setUrl("http://hl7.org/fhir/StructureDefinition/patient-birthTime") .setValue(new TimeType("23:30")); IParser parser = FhirContext.forDstu3().newJsonParser().setPrettyPrint(true); System.out.println(parser.encodeResourceToString(pat)); } }
@Override public Base makeProperty(int hash, String name) throws FHIRException { switch (hash) { case -1618432855: return addIdentifier(); case -1422950650: return getActiveElement(); case 3373707: return addName(); case -1429363305: return addTelecom(); case -1249512767: return getGenderElement(); case -1210031859: return getBirthDateElement(); case -1311442804: return getDeceased(); case 561497972: return getDeceased(); case -1147692044: return addAddress(); case 1756919302: return getMaritalStatus(); case -1764672111: return getMultipleBirth(); case -677369713: return getMultipleBirth(); case 106642994: return addPhoto(); case 951526432: return addContact(); case -1413116420: return getAnimal(); case -1035284522: return addCommunication(); case 1488292898: return addGeneralPractitioner(); case -2058947787: return getManagingOrganization(); case 3321850: return addLink(); default: return super.makeProperty(hash, name); } }