def read_condition(data: dict) -> Condition: result = Condition(data, False) if 'subject' in data: result.subject = FHIRReference(data['subject'], False) if 'encounter' in data: result.encounter = FHIRReference(data['encounter'], False) return result
def create_patient_reference(patient): rslt_rf = FHIRReference() rslt_rf.display = patient.name[0].text # validate that we can cast as json and return assert rslt_rf.as_json() return rslt_rf
def _reference_to(resource): """ Used to create a FHIR reference object based on a FHIRClient.models object :param resource: FHIRClient.models class object (i.e. Patient()) :returns: FHIRReference object """ reference = FHIRReference() reference.reference = '{}/{}'.format(resource.resource_type, resource.id) return reference
def get_fhir_subject_ref( self, req: "CamcopsRequest", recipient: "ExportRecipient" ) -> Dict: """ Returns a FHIRReference (in JSON dict format) used to refer to this patient as a "subject" of some other entry (like a questionnaire). """ return FHIRReference( jsondict={ Fc.TYPE: Fc.RESOURCE_TYPE_PATIENT, Fc.IDENTIFIER: self.get_fhir_identifier( req, recipient ).as_json(), } ).as_json()
def _composition(patient, date, text, resources=[]): # Build it composition = Composition() composition.id = uuid.uuid4().urn composition.status = 'final' composition.subject = FHIR._reference_to(patient) composition.date = FHIRDate(date) composition.title = 'Signature' composition.author = [ FHIRReference({'reference': 'Device/hms-dbmi-ppm-consent'}) ] # Composition type coding = Coding() coding.system = 'http://loinc.org' coding.code = '83930-8' coding.display = 'Research Consent' # Convoluted code property code = CodeableConcept() code.coding = [coding] # Combine composition.type = code # Add sections composition.section = [] # Add text narrative = Narrative() narrative.div = text narrative.status = 'additional' text_section = CompositionSection() text_section.text = narrative composition.section.append(text_section) # Add related section resources for resource in resources: # Add consent consent_section = CompositionSection() consent_section.entry = [FHIR._reference_to(resource)] composition.section.append(consent_section) return composition
def _related_contract(patient, date, patient_name, related_person, related_person_name, related_person_signature, questionnaire_response): # Build it contract = Contract() contract.status = 'executed' contract.issued = FHIRDate(date) contract.id = uuid.uuid4().urn # Signer contract_signer = ContractSigner() contract_signer.type = FHIR._coding( 'http://hl7.org/fhir/ValueSet/contract-signer-type', 'CONSENTER', 'Consenter') contract_signer.party = FHIR._reference_to(related_person) # Signature signature = Signature() signature.type = [ FHIR._coding('http://hl7.org/fhir/ValueSet/signature-type', '1.2.840.10065.1.12.1.7', 'Consent Signature') ] signature.when = FHIRDate(date) signature.contentType = 'text/plain' signature.blob = FHIR._blob(related_person_signature) signature.whoReference = FHIR._reference_to(related_person) signature.whoReference.display = related_person_name # Refer to the patient patient_reference = FHIRReference({ 'reference': '{}/{}'.format(patient.resource_type, patient.id), 'display': patient_name }) signature.onBehalfOfReference = patient_reference # Add references contract_signer.signature = [signature] contract.signer = [contract_signer] contract.bindingReference = FHIR._reference_to(questionnaire_response) return contract
def read_encounter(data: dict) -> encounter.Encounter: result = encounter.Encounter(data, False) if 'subject' in data: result.subject = FHIRReference(data['subject'], False) return result