From dc28a95083a86bca79903a9fa971f3544ede2fbd Mon Sep 17 00:00:00 2001 From: Md Nazrul Islam Date: Fri, 23 Dec 2022 23:44:16 +0100 Subject: [PATCH] :sprakles: Issue #90 logging level downgraded from warning to debug. --- HISTORY.rst | 4 +- fhir/resources/account.py | 374 - fhir/resources/activitydefinition.py | 1239 ---- fhir/resources/address.py | 193 - fhir/resources/adverseevent.py | 526 -- fhir/resources/age.py | 30 - fhir/resources/allergyintolerance.py | 552 -- fhir/resources/annotation.py | 192 - fhir/resources/appointment.py | 624 -- fhir/resources/appointmentresponse.py | 234 - fhir/resources/attachment.py | 151 - fhir/resources/auditevent.py | 903 --- fhir/resources/backboneelement.py | 57 - fhir/resources/basic.py | 116 - fhir/resources/binary.py | 158 - fhir/resources/biologicallyderivedproduct.py | 618 -- fhir/resources/bodystructure.py | 142 - fhir/resources/bundle.py | 839 --- fhir/resources/capabilitystatement.py | 2469 ------ fhir/resources/careplan.py | 1090 --- fhir/resources/careteam.py | 303 - fhir/resources/catalogentry.py | 389 - fhir/resources/chargeitem.py | 633 -- fhir/resources/chargeitemdefinition.py | 775 -- fhir/resources/claim.py | 2779 ------- fhir/resources/claimresponse.py | 2128 ------ fhir/resources/clinicalimpression.py | 557 -- fhir/resources/codeableconcept.py | 59 - fhir/resources/codesystem.py | 1409 ---- fhir/resources/coding.py | 117 - fhir/resources/communication.py | 594 -- fhir/resources/communicationrequest.py | 627 -- fhir/resources/compartmentdefinition.py | 477 -- fhir/resources/composition.py | 884 --- fhir/resources/conceptmap.py | 1174 --- fhir/resources/condition.py | 587 -- fhir/resources/consent.py | 876 --- fhir/resources/contactdetail.py | 57 - fhir/resources/contactpoint.py | 105 - fhir/resources/contract.py | 3060 -------- fhir/resources/contributor.py | 139 - fhir/resources/core/fhirabstractmodel.py | 2 +- fhir/resources/core/patch/__init__.py | 0 fhir/resources/core/patch/patch_r4b_test.py | 0 fhir/resources/count.py | 33 - fhir/resources/coverage.py | 613 -- fhir/resources/coverageeligibilityrequest.py | 825 -- fhir/resources/coverageeligibilityresponse.py | 879 --- fhir/resources/datarequirement.py | 674 -- fhir/resources/detectedissue.py | 440 -- fhir/resources/device.py | 866 --- fhir/resources/devicedefinition.py | 896 --- fhir/resources/devicemetric.py | 352 - fhir/resources/devicerequest.py | 730 -- fhir/resources/deviceusestatement.py | 368 - fhir/resources/diagnosticreport.py | 495 -- fhir/resources/distance.py | 30 - fhir/resources/documentmanifest.py | 339 - fhir/resources/documentreference.py | 618 -- fhir/resources/domainresource.py | 110 - fhir/resources/dosage.py | 399 - fhir/resources/duration.py | 30 - fhir/resources/effectevidencesynthesis.py | 1017 --- fhir/resources/element.py | 63 - fhir/resources/elementdefinition.py | 6606 ----------------- fhir/resources/encounter.py | 909 --- fhir/resources/endpoint.py | 271 - fhir/resources/enrollmentrequest.py | 133 - fhir/resources/enrollmentresponse.py | 153 - fhir/resources/episodeofcare.py | 462 -- fhir/resources/eventdefinition.py | 599 -- fhir/resources/evidence.py | 545 -- fhir/resources/evidencevariable.py | 868 --- fhir/resources/examplescenario.py | 1429 ---- fhir/resources/explanationofbenefit.py | 4184 ----------- fhir/resources/expression.py | 174 - fhir/resources/extension.py | 941 --- fhir/resources/familymemberhistory.py | 770 -- fhir/resources/fhirprimitiveextension.py | 61 - fhir/resources/fhirresourcemodel.py | 25 - fhir/resources/fhirtypes.py | 4073 ---------- fhir/resources/fhirtypesvalidators.py | 5559 -------------- fhir/resources/flag.py | 230 - fhir/resources/goal.py | 675 -- fhir/resources/graphdefinition.py | 773 -- fhir/resources/group.py | 584 -- fhir/resources/guidanceresponse.py | 430 -- fhir/resources/healthcareservice.py | 617 -- fhir/resources/humanname.py | 153 - fhir/resources/identifier.py | 118 - fhir/resources/imagingstudy.py | 836 --- fhir/resources/immunization.py | 882 --- fhir/resources/immunizationevaluation.py | 365 - fhir/resources/immunizationrecommendation.py | 546 -- fhir/resources/implementationguide.py | 1841 ----- fhir/resources/insuranceplan.py | 767 -- fhir/resources/invoice.py | 669 -- fhir/resources/library.py | 643 -- fhir/resources/linkage.py | 202 - fhir/resources/list.py | 349 - fhir/resources/location.py | 505 -- fhir/resources/marketingstatus.py | 119 - fhir/resources/measure.py | 1185 --- fhir/resources/measurereport.py | 666 -- fhir/resources/media.py | 481 -- fhir/resources/medication.py | 318 - fhir/resources/medicationadministration.py | 707 -- fhir/resources/medicationdispense.py | 734 -- fhir/resources/medicationknowledge.py | 1466 ---- fhir/resources/medicationrequest.py | 1019 --- fhir/resources/medicationstatement.py | 483 -- fhir/resources/medicinalproduct.py | 809 -- .../medicinalproductauthorization.py | 447 -- .../medicinalproductcontraindication.py | 243 - fhir/resources/medicinalproductindication.py | 262 - fhir/resources/medicinalproductingredient.py | 424 -- fhir/resources/medicinalproductinteraction.py | 220 - .../resources/medicinalproductmanufactured.py | 124 - fhir/resources/medicinalproductpackaged.py | 347 - .../medicinalproductpharmaceutical.py | 392 - .../medicinalproductundesirableeffect.py | 94 - fhir/resources/messagedefinition.py | 813 -- fhir/resources/messageheader.py | 683 -- fhir/resources/meta.py | 136 - fhir/resources/metadataresource.py | 308 - fhir/resources/molecularsequence.py | 1474 ---- fhir/resources/money.py | 54 - fhir/resources/namingsystem.py | 485 -- fhir/resources/narrative.py | 129 - fhir/resources/nutritionorder.py | 991 --- fhir/resources/observation.py | 1227 --- fhir/resources/observationdefinition.py | 482 -- fhir/resources/operationdefinition.py | 1097 --- fhir/resources/operationoutcome.py | 246 - fhir/resources/organization.py | 233 - fhir/resources/organizationaffiliation.py | 205 - fhir/resources/parameterdefinition.py | 213 - fhir/resources/parameters.py | 967 --- fhir/resources/patient.py | 613 -- fhir/resources/paymentnotice.py | 256 - fhir/resources/paymentreconciliation.py | 502 -- fhir/resources/period.py | 60 - fhir/resources/person.py | 211 - fhir/resources/plandefinition.py | 1973 ----- fhir/resources/population.py | 135 - fhir/resources/practitioner.py | 248 - fhir/resources/practitionerrole.py | 436 -- fhir/resources/procedure.py | 774 -- fhir/resources/prodcharacteristic.py | 202 - fhir/resources/productshelflife.py | 94 - fhir/resources/provenance.py | 509 -- fhir/resources/quantity.py | 110 - fhir/resources/questionnaire.py | 1609 ---- fhir/resources/questionnaireresponse.py | 749 -- fhir/resources/range.py | 49 - fhir/resources/ratio.py | 50 - fhir/resources/reference.py | 106 - fhir/resources/relatedartifact.py | 222 - fhir/resources/relatedperson.py | 245 - fhir/resources/requestgroup.py | 1143 --- fhir/resources/researchdefinition.py | 714 -- fhir/resources/researchelementdefinition.py | 1137 --- fhir/resources/researchstudy.py | 625 -- fhir/resources/researchsubject.py | 232 - fhir/resources/resource.py | 85 - fhir/resources/riskassessment.py | 564 -- fhir/resources/riskevidencesynthesis.py | 926 --- fhir/resources/sampleddata.py | 211 - fhir/resources/schedule.py | 159 - fhir/resources/searchparameter.py | 696 -- fhir/resources/servicerequest.py | 782 -- fhir/resources/signature.py | 224 - fhir/resources/slot.py | 268 - fhir/resources/specimen.py | 700 -- fhir/resources/specimendefinition.py | 653 -- fhir/resources/structuredefinition.py | 884 --- fhir/resources/structuremap.py | 2451 ------ fhir/resources/subscription.py | 362 - fhir/resources/substance.py | 295 - fhir/resources/substanceamount.py | 217 - fhir/resources/substancenucleicacid.py | 408 - fhir/resources/substancepolymer.py | 463 -- fhir/resources/substanceprotein.py | 287 - .../substancereferenceinformation.py | 443 -- fhir/resources/substancesourcematerial.py | 701 -- fhir/resources/substancespecification.py | 1477 ---- fhir/resources/supplydelivery.py | 373 - fhir/resources/supplyrequest.py | 483 -- fhir/resources/task.py | 2307 ------ fhir/resources/terminologycapabilities.py | 1398 ---- fhir/resources/testreport.py | 858 --- fhir/resources/tests/__init__.py | 2 - fhir/resources/tests/conftest.py | 1 - fhir/resources/tests/fixtures.py | 87 - fhir/resources/tests/test_account.py | 135 - .../tests/test_activitydefinition.py | 911 --- fhir/resources/tests/test_adverseevent.py | 70 - .../tests/test_allergyintolerance.py | 360 - fhir/resources/tests/test_appointment.py | 264 - .../tests/test_appointmentresponse.py | 105 - fhir/resources/tests/test_auditevent.py | 865 --- fhir/resources/tests/test_basic.py | 182 - fhir/resources/tests/test_binary.py | 73 - .../tests/test_biologicallyderivedproduct.py | 47 - fhir/resources/tests/test_bodystructure.py | 152 - fhir/resources/tests/test_bundle.py | 424 -- .../tests/test_capabilitystatement.py | 2457 ------ fhir/resources/tests/test_careplan.py | 906 --- fhir/resources/tests/test_careteam.py | 65 - fhir/resources/tests/test_catalogentry.py | 50 - fhir/resources/tests/test_chargeitem.py | 100 - .../tests/test_chargeitemdefinition.py | 176 - fhir/resources/tests/test_claim.py | 1276 ---- fhir/resources/tests/test_claimresponse.py | 723 -- .../tests/test_clinicalimpression.py | 76 - fhir/resources/tests/test_codesystem.py | 905 --- fhir/resources/tests/test_communication.py | 207 - .../tests/test_communicationrequest.py | 116 - .../tests/test_compartmentdefinition.py | 350 - fhir/resources/tests/test_composition.py | 178 - fhir/resources/tests/test_conceptmap.py | 558 -- fhir/resources/tests/test_condition.py | 658 -- fhir/resources/tests/test_consent.py | 810 -- fhir/resources/tests/test_contract.py | 662 -- fhir/resources/tests/test_coverage.py | 323 - .../tests/test_coverageeligibilityrequest.py | 122 - .../tests/test_coverageeligibilityresponse.py | 479 -- fhir/resources/tests/test_detectedissue.py | 203 - fhir/resources/tests/test_device.py | 90 - fhir/resources/tests/test_devicedefinition.py | 48 - fhir/resources/tests/test_devicemetric.py | 63 - fhir/resources/tests/test_devicerequest.py | 260 - .../tests/test_deviceusestatement.py | 49 - fhir/resources/tests/test_diagnosticreport.py | 343 - fhir/resources/tests/test_documentmanifest.py | 115 - .../resources/tests/test_documentreference.py | 120 - .../tests/test_effectevidencesynthesis.py | 52 - fhir/resources/tests/test_encounter.py | 768 -- fhir/resources/tests/test_endpoint.py | 176 - .../resources/tests/test_enrollmentrequest.py | 54 - .../tests/test_enrollmentresponse.py | 61 - fhir/resources/tests/test_episodeofcare.py | 96 - fhir/resources/tests/test_eventdefinition.py | 57 - fhir/resources/tests/test_evidence.py | 47 - fhir/resources/tests/test_evidencevariable.py | 50 - fhir/resources/tests/test_examplescenario.py | 284 - .../tests/test_explanationofbenefit.py | 282 - .../tests/test_familymemberhistory.py | 129 - fhir/resources/tests/test_flag.py | 112 - fhir/resources/tests/test_goal.py | 128 - fhir/resources/tests/test_graphdefinition.py | 61 - fhir/resources/tests/test_group.py | 194 - fhir/resources/tests/test_guidanceresponse.py | 59 - .../resources/tests/test_healthcareservice.py | 134 - fhir/resources/tests/test_imagingstudy.py | 199 - fhir/resources/tests/test_immunization.py | 384 - .../tests/test_immunizationevaluation.py | 120 - .../tests/test_immunizationrecommendation.py | 202 - .../tests/test_implementationguide.py | 102 - fhir/resources/tests/test_insuranceplan.py | 48 - fhir/resources/tests/test_invoice.py | 61 - fhir/resources/tests/test_library.py | 895 --- fhir/resources/tests/test_linkage.py | 53 - fhir/resources/tests/test_list.py | 501 -- fhir/resources/tests/test_location.py | 365 - fhir/resources/tests/test_measure.py | 699 -- fhir/resources/tests/test_measurereport.py | 954 --- fhir/resources/tests/test_media.py | 238 - fhir/resources/tests/test_medication.py | 512 -- .../tests/test_medicationadministration.py | 654 -- .../tests/test_medicationdispense.py | 887 --- .../tests/test_medicationknowledge.py | 57 - .../resources/tests/test_medicationrequest.py | 934 --- .../tests/test_medicationstatement.py | 443 -- fhir/resources/tests/test_medicinalproduct.py | 103 - .../test_medicinalproductauthorization.py | 130 - .../test_medicinalproductcontraindication.py | 61 - .../tests/test_medicinalproductindication.py | 63 - .../tests/test_medicinalproductingredient.py | 67 - .../tests/test_medicinalproductinteraction.py | 66 - .../test_medicinalproductmanufactured.py | 61 - .../tests/test_medicinalproductpackaged.py | 144 - .../test_medicinalproductpharmaceutical.py | 65 - .../test_medicinalproductundesirableeffect.py | 65 - .../resources/tests/test_messagedefinition.py | 205 - fhir/resources/tests/test_messageheader.py | 70 - .../resources/tests/test_molecularsequence.py | 568 -- fhir/resources/tests/test_namingsystem.py | 117 - fhir/resources/tests/test_nutritionorder.py | 932 --- fhir/resources/tests/test_observation.py | 553 -- .../tests/test_observationdefinition.py | 45 - .../tests/test_operationdefinition.py | 901 --- fhir/resources/tests/test_operationoutcome.py | 248 - fhir/resources/tests/test_organization.py | 474 -- .../tests/test_organizationaffiliation.py | 215 - fhir/resources/tests/test_parameters.py | 49 - fhir/resources/tests/test_patient.py | 557 -- fhir/resources/tests/test_paymentnotice.py | 67 - .../tests/test_paymentreconciliation.py | 129 - fhir/resources/tests/test_person.py | 320 - fhir/resources/tests/test_plandefinition.py | 2036 ----- fhir/resources/tests/test_practitioner.py | 518 -- fhir/resources/tests/test_practitionerrole.py | 94 - fhir/resources/tests/test_procedure.py | 590 -- fhir/resources/tests/test_provenance.py | 295 - fhir/resources/tests/test_questionnaire.py | 3311 --------- .../tests/test_questionnaireresponse.py | 1756 ----- fhir/resources/tests/test_relatedperson.py | 277 - fhir/resources/tests/test_requestgroup.py | 260 - .../tests/test_researchdefinition.py | 47 - .../tests/test_researchelementdefinition.py | 53 - fhir/resources/tests/test_researchstudy.py | 46 - fhir/resources/tests/test_researchsubject.py | 51 - fhir/resources/tests/test_riskassessment.py | 373 - .../tests/test_riskevidencesynthesis.py | 48 - fhir/resources/tests/test_schedule.py | 176 - fhir/resources/tests/test_searchparameter.py | 466 -- fhir/resources/tests/test_servicerequest.py | 529 -- fhir/resources/tests/test_slot.py | 182 - fhir/resources/tests/test_specimen.py | 279 - .../tests/test_specimendefinition.py | 229 - fhir/resources/tests/test_structuremap.py | 177 - fhir/resources/tests/test_subscription.py | 105 - fhir/resources/tests/test_substance.py | 284 - .../tests/test_substancespecification.py | 229 - fhir/resources/tests/test_supplydelivery.py | 103 - fhir/resources/tests/test_supplyrequest.py | 60 - fhir/resources/tests/test_task.py | 666 -- .../tests/test_terminologycapabilities.py | 61 - fhir/resources/tests/test_testreport.py | 163 - fhir/resources/tests/test_testscript.py | 1259 ---- fhir/resources/tests/test_valueset.py | 661 -- .../tests/test_verificationresult.py | 48 - .../tests/test_visionprescription.py | 153 - fhir/resources/testscript.py | 2529 ------- fhir/resources/timing.py | 422 -- fhir/resources/triggerdefinition.py | 277 - fhir/resources/usagecontext.py | 171 - fhir/resources/valueset.py | 1584 ---- fhir/resources/verificationresult.py | 600 -- fhir/resources/visionprescription.py | 596 -- 341 files changed, 4 insertions(+), 184181 deletions(-) delete mode 100644 fhir/resources/account.py delete mode 100644 fhir/resources/activitydefinition.py delete mode 100644 fhir/resources/address.py delete mode 100644 fhir/resources/adverseevent.py delete mode 100644 fhir/resources/age.py delete mode 100644 fhir/resources/allergyintolerance.py delete mode 100644 fhir/resources/annotation.py delete mode 100644 fhir/resources/appointment.py delete mode 100644 fhir/resources/appointmentresponse.py delete mode 100644 fhir/resources/attachment.py delete mode 100644 fhir/resources/auditevent.py delete mode 100644 fhir/resources/backboneelement.py delete mode 100644 fhir/resources/basic.py delete mode 100644 fhir/resources/binary.py delete mode 100644 fhir/resources/biologicallyderivedproduct.py delete mode 100644 fhir/resources/bodystructure.py delete mode 100644 fhir/resources/bundle.py delete mode 100644 fhir/resources/capabilitystatement.py delete mode 100644 fhir/resources/careplan.py delete mode 100644 fhir/resources/careteam.py delete mode 100644 fhir/resources/catalogentry.py delete mode 100644 fhir/resources/chargeitem.py delete mode 100644 fhir/resources/chargeitemdefinition.py delete mode 100644 fhir/resources/claim.py delete mode 100644 fhir/resources/claimresponse.py delete mode 100644 fhir/resources/clinicalimpression.py delete mode 100644 fhir/resources/codeableconcept.py delete mode 100644 fhir/resources/codesystem.py delete mode 100644 fhir/resources/coding.py delete mode 100644 fhir/resources/communication.py delete mode 100644 fhir/resources/communicationrequest.py delete mode 100644 fhir/resources/compartmentdefinition.py delete mode 100644 fhir/resources/composition.py delete mode 100644 fhir/resources/conceptmap.py delete mode 100644 fhir/resources/condition.py delete mode 100644 fhir/resources/consent.py delete mode 100644 fhir/resources/contactdetail.py delete mode 100644 fhir/resources/contactpoint.py delete mode 100644 fhir/resources/contract.py delete mode 100644 fhir/resources/contributor.py create mode 100644 fhir/resources/core/patch/__init__.py create mode 100644 fhir/resources/core/patch/patch_r4b_test.py delete mode 100644 fhir/resources/count.py delete mode 100644 fhir/resources/coverage.py delete mode 100644 fhir/resources/coverageeligibilityrequest.py delete mode 100644 fhir/resources/coverageeligibilityresponse.py delete mode 100644 fhir/resources/datarequirement.py delete mode 100644 fhir/resources/detectedissue.py delete mode 100644 fhir/resources/device.py delete mode 100644 fhir/resources/devicedefinition.py delete mode 100644 fhir/resources/devicemetric.py delete mode 100644 fhir/resources/devicerequest.py delete mode 100644 fhir/resources/deviceusestatement.py delete mode 100644 fhir/resources/diagnosticreport.py delete mode 100644 fhir/resources/distance.py delete mode 100644 fhir/resources/documentmanifest.py delete mode 100644 fhir/resources/documentreference.py delete mode 100644 fhir/resources/domainresource.py delete mode 100644 fhir/resources/dosage.py delete mode 100644 fhir/resources/duration.py delete mode 100644 fhir/resources/effectevidencesynthesis.py delete mode 100644 fhir/resources/element.py delete mode 100644 fhir/resources/elementdefinition.py delete mode 100644 fhir/resources/encounter.py delete mode 100644 fhir/resources/endpoint.py delete mode 100644 fhir/resources/enrollmentrequest.py delete mode 100644 fhir/resources/enrollmentresponse.py delete mode 100644 fhir/resources/episodeofcare.py delete mode 100644 fhir/resources/eventdefinition.py delete mode 100644 fhir/resources/evidence.py delete mode 100644 fhir/resources/evidencevariable.py delete mode 100644 fhir/resources/examplescenario.py delete mode 100644 fhir/resources/explanationofbenefit.py delete mode 100644 fhir/resources/expression.py delete mode 100644 fhir/resources/extension.py delete mode 100644 fhir/resources/familymemberhistory.py delete mode 100644 fhir/resources/fhirprimitiveextension.py delete mode 100644 fhir/resources/fhirresourcemodel.py delete mode 100644 fhir/resources/fhirtypes.py delete mode 100644 fhir/resources/fhirtypesvalidators.py delete mode 100644 fhir/resources/flag.py delete mode 100644 fhir/resources/goal.py delete mode 100644 fhir/resources/graphdefinition.py delete mode 100644 fhir/resources/group.py delete mode 100644 fhir/resources/guidanceresponse.py delete mode 100644 fhir/resources/healthcareservice.py delete mode 100644 fhir/resources/humanname.py delete mode 100644 fhir/resources/identifier.py delete mode 100644 fhir/resources/imagingstudy.py delete mode 100644 fhir/resources/immunization.py delete mode 100644 fhir/resources/immunizationevaluation.py delete mode 100644 fhir/resources/immunizationrecommendation.py delete mode 100644 fhir/resources/implementationguide.py delete mode 100644 fhir/resources/insuranceplan.py delete mode 100644 fhir/resources/invoice.py delete mode 100644 fhir/resources/library.py delete mode 100644 fhir/resources/linkage.py delete mode 100644 fhir/resources/list.py delete mode 100644 fhir/resources/location.py delete mode 100644 fhir/resources/marketingstatus.py delete mode 100644 fhir/resources/measure.py delete mode 100644 fhir/resources/measurereport.py delete mode 100644 fhir/resources/media.py delete mode 100644 fhir/resources/medication.py delete mode 100644 fhir/resources/medicationadministration.py delete mode 100644 fhir/resources/medicationdispense.py delete mode 100644 fhir/resources/medicationknowledge.py delete mode 100644 fhir/resources/medicationrequest.py delete mode 100644 fhir/resources/medicationstatement.py delete mode 100644 fhir/resources/medicinalproduct.py delete mode 100644 fhir/resources/medicinalproductauthorization.py delete mode 100644 fhir/resources/medicinalproductcontraindication.py delete mode 100644 fhir/resources/medicinalproductindication.py delete mode 100644 fhir/resources/medicinalproductingredient.py delete mode 100644 fhir/resources/medicinalproductinteraction.py delete mode 100644 fhir/resources/medicinalproductmanufactured.py delete mode 100644 fhir/resources/medicinalproductpackaged.py delete mode 100644 fhir/resources/medicinalproductpharmaceutical.py delete mode 100644 fhir/resources/medicinalproductundesirableeffect.py delete mode 100644 fhir/resources/messagedefinition.py delete mode 100644 fhir/resources/messageheader.py delete mode 100644 fhir/resources/meta.py delete mode 100644 fhir/resources/metadataresource.py delete mode 100644 fhir/resources/molecularsequence.py delete mode 100644 fhir/resources/money.py delete mode 100644 fhir/resources/namingsystem.py delete mode 100644 fhir/resources/narrative.py delete mode 100644 fhir/resources/nutritionorder.py delete mode 100644 fhir/resources/observation.py delete mode 100644 fhir/resources/observationdefinition.py delete mode 100644 fhir/resources/operationdefinition.py delete mode 100644 fhir/resources/operationoutcome.py delete mode 100644 fhir/resources/organization.py delete mode 100644 fhir/resources/organizationaffiliation.py delete mode 100644 fhir/resources/parameterdefinition.py delete mode 100644 fhir/resources/parameters.py delete mode 100644 fhir/resources/patient.py delete mode 100644 fhir/resources/paymentnotice.py delete mode 100644 fhir/resources/paymentreconciliation.py delete mode 100644 fhir/resources/period.py delete mode 100644 fhir/resources/person.py delete mode 100644 fhir/resources/plandefinition.py delete mode 100644 fhir/resources/population.py delete mode 100644 fhir/resources/practitioner.py delete mode 100644 fhir/resources/practitionerrole.py delete mode 100644 fhir/resources/procedure.py delete mode 100644 fhir/resources/prodcharacteristic.py delete mode 100644 fhir/resources/productshelflife.py delete mode 100644 fhir/resources/provenance.py delete mode 100644 fhir/resources/quantity.py delete mode 100644 fhir/resources/questionnaire.py delete mode 100644 fhir/resources/questionnaireresponse.py delete mode 100644 fhir/resources/range.py delete mode 100644 fhir/resources/ratio.py delete mode 100644 fhir/resources/reference.py delete mode 100644 fhir/resources/relatedartifact.py delete mode 100644 fhir/resources/relatedperson.py delete mode 100644 fhir/resources/requestgroup.py delete mode 100644 fhir/resources/researchdefinition.py delete mode 100644 fhir/resources/researchelementdefinition.py delete mode 100644 fhir/resources/researchstudy.py delete mode 100644 fhir/resources/researchsubject.py delete mode 100644 fhir/resources/resource.py delete mode 100644 fhir/resources/riskassessment.py delete mode 100644 fhir/resources/riskevidencesynthesis.py delete mode 100644 fhir/resources/sampleddata.py delete mode 100644 fhir/resources/schedule.py delete mode 100644 fhir/resources/searchparameter.py delete mode 100644 fhir/resources/servicerequest.py delete mode 100644 fhir/resources/signature.py delete mode 100644 fhir/resources/slot.py delete mode 100644 fhir/resources/specimen.py delete mode 100644 fhir/resources/specimendefinition.py delete mode 100644 fhir/resources/structuredefinition.py delete mode 100644 fhir/resources/structuremap.py delete mode 100644 fhir/resources/subscription.py delete mode 100644 fhir/resources/substance.py delete mode 100644 fhir/resources/substanceamount.py delete mode 100644 fhir/resources/substancenucleicacid.py delete mode 100644 fhir/resources/substancepolymer.py delete mode 100644 fhir/resources/substanceprotein.py delete mode 100644 fhir/resources/substancereferenceinformation.py delete mode 100644 fhir/resources/substancesourcematerial.py delete mode 100644 fhir/resources/substancespecification.py delete mode 100644 fhir/resources/supplydelivery.py delete mode 100644 fhir/resources/supplyrequest.py delete mode 100644 fhir/resources/task.py delete mode 100644 fhir/resources/terminologycapabilities.py delete mode 100644 fhir/resources/testreport.py delete mode 100644 fhir/resources/tests/__init__.py delete mode 100644 fhir/resources/tests/conftest.py delete mode 100644 fhir/resources/tests/fixtures.py delete mode 100644 fhir/resources/tests/test_account.py delete mode 100644 fhir/resources/tests/test_activitydefinition.py delete mode 100644 fhir/resources/tests/test_adverseevent.py delete mode 100644 fhir/resources/tests/test_allergyintolerance.py delete mode 100644 fhir/resources/tests/test_appointment.py delete mode 100644 fhir/resources/tests/test_appointmentresponse.py delete mode 100644 fhir/resources/tests/test_auditevent.py delete mode 100644 fhir/resources/tests/test_basic.py delete mode 100644 fhir/resources/tests/test_binary.py delete mode 100644 fhir/resources/tests/test_biologicallyderivedproduct.py delete mode 100644 fhir/resources/tests/test_bodystructure.py delete mode 100644 fhir/resources/tests/test_bundle.py delete mode 100644 fhir/resources/tests/test_capabilitystatement.py delete mode 100644 fhir/resources/tests/test_careplan.py delete mode 100644 fhir/resources/tests/test_careteam.py delete mode 100644 fhir/resources/tests/test_catalogentry.py delete mode 100644 fhir/resources/tests/test_chargeitem.py delete mode 100644 fhir/resources/tests/test_chargeitemdefinition.py delete mode 100644 fhir/resources/tests/test_claim.py delete mode 100644 fhir/resources/tests/test_claimresponse.py delete mode 100644 fhir/resources/tests/test_clinicalimpression.py delete mode 100644 fhir/resources/tests/test_codesystem.py delete mode 100644 fhir/resources/tests/test_communication.py delete mode 100644 fhir/resources/tests/test_communicationrequest.py delete mode 100644 fhir/resources/tests/test_compartmentdefinition.py delete mode 100644 fhir/resources/tests/test_composition.py delete mode 100644 fhir/resources/tests/test_conceptmap.py delete mode 100644 fhir/resources/tests/test_condition.py delete mode 100644 fhir/resources/tests/test_consent.py delete mode 100644 fhir/resources/tests/test_contract.py delete mode 100644 fhir/resources/tests/test_coverage.py delete mode 100644 fhir/resources/tests/test_coverageeligibilityrequest.py delete mode 100644 fhir/resources/tests/test_coverageeligibilityresponse.py delete mode 100644 fhir/resources/tests/test_detectedissue.py delete mode 100644 fhir/resources/tests/test_device.py delete mode 100644 fhir/resources/tests/test_devicedefinition.py delete mode 100644 fhir/resources/tests/test_devicemetric.py delete mode 100644 fhir/resources/tests/test_devicerequest.py delete mode 100644 fhir/resources/tests/test_deviceusestatement.py delete mode 100644 fhir/resources/tests/test_diagnosticreport.py delete mode 100644 fhir/resources/tests/test_documentmanifest.py delete mode 100644 fhir/resources/tests/test_documentreference.py delete mode 100644 fhir/resources/tests/test_effectevidencesynthesis.py delete mode 100644 fhir/resources/tests/test_encounter.py delete mode 100644 fhir/resources/tests/test_endpoint.py delete mode 100644 fhir/resources/tests/test_enrollmentrequest.py delete mode 100644 fhir/resources/tests/test_enrollmentresponse.py delete mode 100644 fhir/resources/tests/test_episodeofcare.py delete mode 100644 fhir/resources/tests/test_eventdefinition.py delete mode 100644 fhir/resources/tests/test_evidence.py delete mode 100644 fhir/resources/tests/test_evidencevariable.py delete mode 100644 fhir/resources/tests/test_examplescenario.py delete mode 100644 fhir/resources/tests/test_explanationofbenefit.py delete mode 100644 fhir/resources/tests/test_familymemberhistory.py delete mode 100644 fhir/resources/tests/test_flag.py delete mode 100644 fhir/resources/tests/test_goal.py delete mode 100644 fhir/resources/tests/test_graphdefinition.py delete mode 100644 fhir/resources/tests/test_group.py delete mode 100644 fhir/resources/tests/test_guidanceresponse.py delete mode 100644 fhir/resources/tests/test_healthcareservice.py delete mode 100644 fhir/resources/tests/test_imagingstudy.py delete mode 100644 fhir/resources/tests/test_immunization.py delete mode 100644 fhir/resources/tests/test_immunizationevaluation.py delete mode 100644 fhir/resources/tests/test_immunizationrecommendation.py delete mode 100644 fhir/resources/tests/test_implementationguide.py delete mode 100644 fhir/resources/tests/test_insuranceplan.py delete mode 100644 fhir/resources/tests/test_invoice.py delete mode 100644 fhir/resources/tests/test_library.py delete mode 100644 fhir/resources/tests/test_linkage.py delete mode 100644 fhir/resources/tests/test_list.py delete mode 100644 fhir/resources/tests/test_location.py delete mode 100644 fhir/resources/tests/test_measure.py delete mode 100644 fhir/resources/tests/test_measurereport.py delete mode 100644 fhir/resources/tests/test_media.py delete mode 100644 fhir/resources/tests/test_medication.py delete mode 100644 fhir/resources/tests/test_medicationadministration.py delete mode 100644 fhir/resources/tests/test_medicationdispense.py delete mode 100644 fhir/resources/tests/test_medicationknowledge.py delete mode 100644 fhir/resources/tests/test_medicationrequest.py delete mode 100644 fhir/resources/tests/test_medicationstatement.py delete mode 100644 fhir/resources/tests/test_medicinalproduct.py delete mode 100644 fhir/resources/tests/test_medicinalproductauthorization.py delete mode 100644 fhir/resources/tests/test_medicinalproductcontraindication.py delete mode 100644 fhir/resources/tests/test_medicinalproductindication.py delete mode 100644 fhir/resources/tests/test_medicinalproductingredient.py delete mode 100644 fhir/resources/tests/test_medicinalproductinteraction.py delete mode 100644 fhir/resources/tests/test_medicinalproductmanufactured.py delete mode 100644 fhir/resources/tests/test_medicinalproductpackaged.py delete mode 100644 fhir/resources/tests/test_medicinalproductpharmaceutical.py delete mode 100644 fhir/resources/tests/test_medicinalproductundesirableeffect.py delete mode 100644 fhir/resources/tests/test_messagedefinition.py delete mode 100644 fhir/resources/tests/test_messageheader.py delete mode 100644 fhir/resources/tests/test_molecularsequence.py delete mode 100644 fhir/resources/tests/test_namingsystem.py delete mode 100644 fhir/resources/tests/test_nutritionorder.py delete mode 100644 fhir/resources/tests/test_observation.py delete mode 100644 fhir/resources/tests/test_observationdefinition.py delete mode 100644 fhir/resources/tests/test_operationdefinition.py delete mode 100644 fhir/resources/tests/test_operationoutcome.py delete mode 100644 fhir/resources/tests/test_organization.py delete mode 100644 fhir/resources/tests/test_organizationaffiliation.py delete mode 100644 fhir/resources/tests/test_parameters.py delete mode 100644 fhir/resources/tests/test_patient.py delete mode 100644 fhir/resources/tests/test_paymentnotice.py delete mode 100644 fhir/resources/tests/test_paymentreconciliation.py delete mode 100644 fhir/resources/tests/test_person.py delete mode 100644 fhir/resources/tests/test_plandefinition.py delete mode 100644 fhir/resources/tests/test_practitioner.py delete mode 100644 fhir/resources/tests/test_practitionerrole.py delete mode 100644 fhir/resources/tests/test_procedure.py delete mode 100644 fhir/resources/tests/test_provenance.py delete mode 100644 fhir/resources/tests/test_questionnaire.py delete mode 100644 fhir/resources/tests/test_questionnaireresponse.py delete mode 100644 fhir/resources/tests/test_relatedperson.py delete mode 100644 fhir/resources/tests/test_requestgroup.py delete mode 100644 fhir/resources/tests/test_researchdefinition.py delete mode 100644 fhir/resources/tests/test_researchelementdefinition.py delete mode 100644 fhir/resources/tests/test_researchstudy.py delete mode 100644 fhir/resources/tests/test_researchsubject.py delete mode 100644 fhir/resources/tests/test_riskassessment.py delete mode 100644 fhir/resources/tests/test_riskevidencesynthesis.py delete mode 100644 fhir/resources/tests/test_schedule.py delete mode 100644 fhir/resources/tests/test_searchparameter.py delete mode 100644 fhir/resources/tests/test_servicerequest.py delete mode 100644 fhir/resources/tests/test_slot.py delete mode 100644 fhir/resources/tests/test_specimen.py delete mode 100644 fhir/resources/tests/test_specimendefinition.py delete mode 100644 fhir/resources/tests/test_structuremap.py delete mode 100644 fhir/resources/tests/test_subscription.py delete mode 100644 fhir/resources/tests/test_substance.py delete mode 100644 fhir/resources/tests/test_substancespecification.py delete mode 100644 fhir/resources/tests/test_supplydelivery.py delete mode 100644 fhir/resources/tests/test_supplyrequest.py delete mode 100644 fhir/resources/tests/test_task.py delete mode 100644 fhir/resources/tests/test_terminologycapabilities.py delete mode 100644 fhir/resources/tests/test_testreport.py delete mode 100644 fhir/resources/tests/test_testscript.py delete mode 100644 fhir/resources/tests/test_valueset.py delete mode 100644 fhir/resources/tests/test_verificationresult.py delete mode 100644 fhir/resources/tests/test_visionprescription.py delete mode 100644 fhir/resources/testscript.py delete mode 100644 fhir/resources/timing.py delete mode 100644 fhir/resources/triggerdefinition.py delete mode 100644 fhir/resources/usagecontext.py delete mode 100644 fhir/resources/valueset.py delete mode 100644 fhir/resources/verificationresult.py delete mode 100644 fhir/resources/visionprescription.py diff --git a/HISTORY.rst b/HISTORY.rst index a11eeff9..cfeaf1c9 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,7 +5,9 @@ History 6.4.1 (unreleased) ------------------ -- Nothing changed yet. +Improvements + +- Issue #90 logging level downgraded from warning to debug. 6.4.0 (2022-05-11) diff --git a/fhir/resources/account.py b/fhir/resources/account.py deleted file mode 100644 index 848db455..00000000 --- a/fhir/resources/account.py +++ /dev/null @@ -1,374 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Account -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Account(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Tracks balance, charges, for patient or cost center. - A financial tool for tracking value accrued for a particular purpose. In - the healthcare field, used to track charges for a patient, cost centers, - etc. - """ - - resource_type = Field("Account", const=True) - - coverage: typing.List[fhirtypes.AccountCoverageType] = Field( - None, - alias="coverage", - title=( - "The party(s) that are responsible for covering the payment of this " - "account, and what order should they be applied to the account" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Explanation of purpose/use", - description=( - "Provides additional information about what the account tracks and how " - "it is used." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - guarantor: typing.List[fhirtypes.AccountGuarantorType] = Field( - None, - alias="guarantor", - title="The parties ultimately responsible for balancing the Account", - description=( - "The parties responsible for balancing the account if other payment " - "options fall short." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Account number", - description=( - "Unique identifier used to reference the account. Might or might not " - "be intended for human use (e.g. credit card number)." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Human-readable label", - description=( - "Name used for the account when displaying it to humans in reports, " "etc." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - owner: fhirtypes.ReferenceType = Field( - None, - alias="owner", - title="Entity managing the Account", - description=( - "Indicates the service area, hospital, department, etc. with " - "responsibility for managing the Account." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - partOf: fhirtypes.ReferenceType = Field( - None, - alias="partOf", - title="Reference to a parent Account", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Account"], - ) - - servicePeriod: fhirtypes.PeriodType = Field( - None, - alias="servicePeriod", - title="Transaction window", - description="The date range of services associated with this account.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | inactive | entered-in-error | on-hold | unknown", - description="Indicates whether the account is presently used/usable or not.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "inactive", "entered-in-error", "on-hold", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="subject", - title="The entity that caused the expenses", - description=( - "Identifies the entity which incurs the expenses. While the immediate " - "recipients of services or goods might be entities related to the " - "subject, the expenses were ultimately incurred by the subject of the " - "Account." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Device", - "Practitioner", - "PractitionerRole", - "Location", - "HealthcareService", - "Organization", - ], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="E.g. patient, expense, depreciation", - description="Categorizes the account for reporting and searching purposes.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Account`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "type", - "name", - "subject", - "servicePeriod", - "coverage", - "owner", - "description", - "guarantor", - "partOf", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_898( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class AccountCoverage(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The party(s) that are responsible for covering the payment of this account, - and what order should they be applied to the account. - """ - - resource_type = Field("AccountCoverage", const=True) - - coverage: fhirtypes.ReferenceType = Field( - ..., - alias="coverage", - title=( - "The party(s), such as insurances, that may contribute to the payment " - "of this account" - ), - description=( - "The party(s) that contribute to payment (or part of) of the charges " - "applied to this account (including self-pay). A coverage may only be " - "responsible for specific types of charges, and the sequence of the " - "coverages in the account could be important when processing billing." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Coverage"], - ) - - priority: fhirtypes.PositiveInt = Field( - None, - alias="priority", - title="The priority of the coverage in the context of this account", - description=None, - # if property is element of this resource. - element_property=True, - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AccountCoverage`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "coverage", "priority"] - - -class AccountGuarantor(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The parties ultimately responsible for balancing the Account. - The parties responsible for balancing the account if other payment options - fall short. - """ - - resource_type = Field("AccountGuarantor", const=True) - - onHold: bool = Field( - None, - alias="onHold", - title="Credit or other hold applied", - description=( - "A guarantor may be placed on credit hold or otherwise have their role " - "temporarily suspended." - ), - # if property is element of this resource. - element_property=True, - ) - onHold__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_onHold", title="Extension field for ``onHold``." - ) - - party: fhirtypes.ReferenceType = Field( - ..., - alias="party", - title="Responsible entity", - description="The entity who is responsible.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "RelatedPerson", "Organization"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Guarantee account during", - description=( - "The timeframe during which the guarantor accepts responsibility for " - "the account." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AccountGuarantor`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "party", "onHold", "period"] diff --git a/fhir/resources/activitydefinition.py b/fhir/resources/activitydefinition.py deleted file mode 100644 index a001c153..00000000 --- a/fhir/resources/activitydefinition.py +++ /dev/null @@ -1,1239 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ActivityDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ActivityDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The definition of a specific activity to be taken, independent of any - particular patient or context. - This resource allows for the definition of some activity to be performed, - independent of a particular patient, practitioner, or other performance - context. - """ - - resource_type = Field("ActivityDefinition", const=True) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the activity definition was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - author: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="author", - title="Who authored the content", - description=( - "An individiual or organization primarily involved in the creation and " - "maintenance of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - bodySite: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="bodySite", - title="What part of body to perform on", - description=( - "Indicates the sites on the subject's body where the procedure should " - "be performed (I.e. the target sites)." - ), - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Detail type of activity", - description=( - "Detailed description of the type of activity; e.g. What lab test, what" - " procedure, what kind of encounter." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the activity definition and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the activity definition." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the activity definition was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the activity definition " - "changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the activity definition", - description=( - "A free text natural language description of the activity definition " - "from a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - doNotPerform: bool = Field( - None, - alias="doNotPerform", - title="True if the activity should not be performed", - description=( - "Set this to true if the definition is to indicate that a particular " - "activity should NOT be performed. If true, this element should be " - "interpreted to reinforce a negative coding. For example NPO as a code " - "with a doNotPerform of true would still indicate to NOT perform the " - "action." - ), - # if property is element of this resource. - element_property=True, - ) - doNotPerform__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_doNotPerform", title="Extension field for ``doNotPerform``." - ) - - dosage: typing.List[fhirtypes.DosageType] = Field( - None, - alias="dosage", - title="Detailed dosage instructions", - description=( - "Provides detailed dosage instructions in the same way that they are " - "described for MedicationRequest resources." - ), - # if property is element of this resource. - element_property=True, - ) - - dynamicValue: typing.List[fhirtypes.ActivityDefinitionDynamicValueType] = Field( - None, - alias="dynamicValue", - title="Dynamic aspects of the definition", - description=( - "Dynamic values that will be evaluated to produce values for elements " - "of the resulting resource. For example, if the dosage of a medication " - "must be computed based on the patient's weight, a dynamic value would " - "be used to specify an expression that calculated the weight, and the " - "path on the request resource that would contain the result." - ), - # if property is element of this resource. - element_property=True, - ) - - editor: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="editor", - title="Who edited the content", - description=( - "An individual or organization primarily responsible for internal " - "coherence of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the activity definition is expected to be used", - description=( - "The period during which the activity definition content was or is " - "planned to be in active use." - ), - # if property is element of this resource. - element_property=True, - ) - - endorser: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="endorser", - title="Who endorsed the content", - description=( - "An individual or organization responsible for officially endorsing the" - " content for use in some setting." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this activity definition is authored " - "for testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the activity definition", - description=( - "A formal identifier that is used to identify this activity definition " - "when it is represented in other formats, or referenced in a " - "specification, model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - intent: fhirtypes.Code = Field( - None, - alias="intent", - title=( - "proposal | plan | directive | order | original-order | reflex-order | " - "filler-order | instance-order | option" - ), - description=( - "Indicates the level of authority/intentionality associated with the " - "activity and where the request should fit into the workflow chain." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "proposal", - "plan", - "directive", - "order", - "original-order", - "reflex-order", - "filler-order", - "instance-order", - "option", - ], - ) - intent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_intent", title="Extension field for ``intent``." - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for activity definition (if applicable)", - description=( - "A legal or geographic region in which the activity definition is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - kind: fhirtypes.Code = Field( - None, - alias="kind", - title="Kind of resource", - description=( - "A description of the kind of resource the activity definition is " - "representing. For example, a MedicationRequest, a ServiceRequest, or a" - " CommunicationRequest. Typically, but not always, this is a Request " - "resource." - ), - # if property is element of this resource. - element_property=True, - ) - kind__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_kind", title="Extension field for ``kind``." - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the activity definition was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - library: typing.List[fhirtypes.Canonical] = Field( - None, - alias="library", - title="Logic used by the activity definition", - description=( - "A reference to a Library resource containing any formal logic used by " - "the activity definition." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Library"], - ) - library__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_library", title="Extension field for ``library``.") - - location: fhirtypes.ReferenceType = Field( - None, - alias="location", - title="Where it should happen", - description=( - "Identifies the facility where the activity will occur; e.g. home, " - "hospital, specific clinic, etc." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this activity definition (computer friendly)", - description=( - "A natural language name identifying the activity definition. This name" - " should be usable as an identifier for the module by machine " - "processing applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - observationRequirement: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="observationRequirement", - title="What observations are required to perform this action", - description=( - "Defines observation requirements for the action to be performed, such " - "as body weight or surface area." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ObservationDefinition"], - ) - - observationResultRequirement: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="observationResultRequirement", - title="What observations must be produced by this action", - description=( - "Defines the observations that are expected to be produced by the " - "action." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ObservationDefinition"], - ) - - participant: typing.List[fhirtypes.ActivityDefinitionParticipantType] = Field( - None, - alias="participant", - title="Who should participate in the action", - description="Indicates who should participate in performing the action described.", - # if property is element of this resource. - element_property=True, - ) - - priority: fhirtypes.Code = Field( - None, - alias="priority", - title="routine | urgent | asap | stat", - description=( - "Indicates how quickly the activity should be addressed with respect " - "to other requests." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["routine", "urgent", "asap", "stat"], - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - productCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="productCodeableConcept", - title="What's administered/supplied", - description=( - "Identifies the food, drug or other product being consumed or supplied " - "in the activity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e product[x] - one_of_many="product", - one_of_many_required=False, - ) - - productReference: fhirtypes.ReferenceType = Field( - None, - alias="productReference", - title="What's administered/supplied", - description=( - "Identifies the food, drug or other product being consumed or supplied " - "in the activity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e product[x] - one_of_many="product", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Medication", "Substance"], - ) - - profile: fhirtypes.Canonical = Field( - None, - alias="profile", - title="What profile the resource needs to conform to", - description=( - "A profile to which the target of the activity definition is expected " - "to conform." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - profile__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_profile", title="Extension field for ``profile``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the activity" - " definition." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this activity definition is defined", - description=( - "Explanation of why this activity definition is needed and why it has " - "been designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="How much is administered/consumed/supplied", - description=( - "Identifies the quantity expected to be consumed at once (per dose, per" - " meal, etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="Additional documentation, citations, etc.", - description=( - "Related artifacts such as additional documentation, justification, or " - "bibliographic references." - ), - # if property is element of this resource. - element_property=True, - ) - - reviewer: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="reviewer", - title="Who reviewed the content", - description=( - "An individual or organization primarily responsible for review of some" - " aspect of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - specimenRequirement: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="specimenRequirement", - title="What specimens are required to perform this action", - description=( - "Defines specimen requirements for the action to be performed, such as " - "required specimens for a lab test." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SpecimenDefinition"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this activity definition. Enables tracking the life-" - "cycle of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subjectCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="subjectCodeableConcept", - title="Type of individual the activity definition is intended for", - description=( - "A code or group definition that describes the intended subject of the " - "activity being defined." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - ) - - subjectReference: fhirtypes.ReferenceType = Field( - None, - alias="subjectReference", - title="Type of individual the activity definition is intended for", - description=( - "A code or group definition that describes the intended subject of the " - "activity being defined." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Group"], - ) - - subtitle: fhirtypes.String = Field( - None, - alias="subtitle", - title="Subordinate title of the activity definition", - description=( - "An explanatory or alternate title for the activity definition giving " - "additional information about its content." - ), - # if property is element of this resource. - element_property=True, - ) - subtitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subtitle", title="Extension field for ``subtitle``." - ) - - timingAge: fhirtypes.AgeType = Field( - None, - alias="timingAge", - title="When activity is to occur", - description=( - "The period, timing or frequency upon which the described activity is " - "to occur." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingDateTime: fhirtypes.DateTime = Field( - None, - alias="timingDateTime", - title="When activity is to occur", - description=( - "The period, timing or frequency upon which the described activity is " - "to occur." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - timingDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timingDateTime", title="Extension field for ``timingDateTime``." - ) - - timingDuration: fhirtypes.DurationType = Field( - None, - alias="timingDuration", - title="When activity is to occur", - description=( - "The period, timing or frequency upon which the described activity is " - "to occur." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingPeriod: fhirtypes.PeriodType = Field( - None, - alias="timingPeriod", - title="When activity is to occur", - description=( - "The period, timing or frequency upon which the described activity is " - "to occur." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingRange: fhirtypes.RangeType = Field( - None, - alias="timingRange", - title="When activity is to occur", - description=( - "The period, timing or frequency upon which the described activity is " - "to occur." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingTiming: fhirtypes.TimingType = Field( - None, - alias="timingTiming", - title="When activity is to occur", - description=( - "The period, timing or frequency upon which the described activity is " - "to occur." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this activity definition (human friendly)", - description="A short, descriptive, user-friendly title for the activity definition.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="topic", - title="E.g. Education, Treatment, Assessment, etc.", - description=( - "Descriptive topics related to the content of the activity. Topics " - "provide a high-level categorization of the activity that can be useful" - " for filtering and searching." - ), - # if property is element of this resource. - element_property=True, - ) - - transform: fhirtypes.Canonical = Field( - None, - alias="transform", - title="Transform to apply the template", - description=( - "A reference to a StructureMap resource that defines a transform that " - "can be executed to produce the intent resource using the " - "ActivityDefinition instance as the input." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureMap"], - ) - transform__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_transform", title="Extension field for ``transform``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this activity definition, represented as a " - "URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this activity definition when" - " it is referenced in a specification, model, design or an instance; " - "also called its canonical identifier. This SHOULD be globally unique " - "and SHOULD be a literal address at which at which an authoritative " - "instance of this activity definition is (or will be) published. This " - "URL can be the target of a canonical reference. It SHALL remain the " - "same when the activity definition is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - usage: fhirtypes.String = Field( - None, - alias="usage", - title="Describes the clinical usage of the activity definition", - description=( - "A detailed description of how the activity definition is used from a " - "clinical perspective." - ), - # if property is element of this resource. - element_property=True, - ) - usage__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_usage", title="Extension field for ``usage``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate activity definition instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the activity definition", - description=( - "The identifier that is used to identify this version of the activity " - "definition when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the activity " - "definition author and is not expected to be globally unique. For " - "example, it might be a timestamp (e.g. yyyymmdd) if a managed version " - "is not available. There is also no expectation that versions can be " - "placed in a lexicographical sequence. To provide a version consistent " - "with the Decision Support Service specification, use the format " - "Major.Minor.Revision (e.g. 1.0.0). For more information on versioning " - "knowledge assets, refer to the Decision Support Service specification." - " Note that a version is required for non-experimental active assets." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ActivityDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "subtitle", - "status", - "experimental", - "subjectCodeableConcept", - "subjectReference", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "usage", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "topic", - "author", - "editor", - "reviewer", - "endorser", - "relatedArtifact", - "library", - "kind", - "profile", - "code", - "intent", - "priority", - "doNotPerform", - "timingTiming", - "timingDateTime", - "timingAge", - "timingPeriod", - "timingRange", - "timingDuration", - "location", - "participant", - "productReference", - "productCodeableConcept", - "quantity", - "dosage", - "bodySite", - "specimenRequirement", - "observationRequirement", - "observationResultRequirement", - "transform", - "dynamicValue", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2053( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2053( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "product": ["productCodeableConcept", "productReference"], - "subject": ["subjectCodeableConcept", "subjectReference"], - "timing": [ - "timingAge", - "timingDateTime", - "timingDuration", - "timingPeriod", - "timingRange", - "timingTiming", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ActivityDefinitionDynamicValue(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Dynamic aspects of the definition. - Dynamic values that will be evaluated to produce values for elements of the - resulting resource. For example, if the dosage of a medication must be - computed based on the patient's weight, a dynamic value would be used to - specify an expression that calculated the weight, and the path on the - request resource that would contain the result. - """ - - resource_type = Field("ActivityDefinitionDynamicValue", const=True) - - expression: fhirtypes.ExpressionType = Field( - ..., - alias="expression", - title="An expression that provides the dynamic value for the customization", - description="An expression specifying the value of the customized element.", - # if property is element of this resource. - element_property=True, - ) - - path: fhirtypes.String = Field( - None, - alias="path", - title="The path to the element to be set dynamically", - description=( - "The path to the element to be customized. This is the path on the " - "resource that will hold the result of the calculation defined by the " - "expression. The specified path SHALL be a FHIRPath resolveable on the " - "specified target type of the ActivityDefinition, and SHALL consist " - "only of identifiers, constant indexers, and a restricted subset of " - "functions. The path is allowed to contain qualifiers (.) to traverse " - "sub-elements, as well as indexers ([x]) to traverse multiple-" - "cardinality sub-elements (see the [Simple FHIRPath " - "Profile](fhirpath.html#simple) for full details)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_path", title="Extension field for ``path``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ActivityDefinitionDynamicValue`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "path", "expression"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3262( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("path", "path__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ActivityDefinitionParticipant(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Who should participate in the action. - Indicates who should participate in performing the action described. - """ - - resource_type = Field("ActivityDefinitionParticipant", const=True) - - role: fhirtypes.CodeableConceptType = Field( - None, - alias="role", - title="E.g. Nurse, Surgeon, Parent, etc.", - description=( - "The role the participant should play in performing the described " - "action." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="patient | practitioner | related-person | device", - description="The type of participant in the action.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["patient", "practitioner", "related-person", "device"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ActivityDefinitionParticipant`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "role"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3210( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/address.py b/fhir/resources/address.py deleted file mode 100644 index 82e4209d..00000000 --- a/fhir/resources/address.py +++ /dev/null @@ -1,193 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Address -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import element, fhirtypes - - -class Address(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An address expressed using postal conventions (as opposed to GPS or other - location definition formats). - An address expressed using postal conventions (as opposed to GPS or other - location definition formats). This data type may be used to convey - addresses for use in delivering mail as well as for visiting locations - which might not be valid for mail delivery. There are a variety of postal - address formats defined around the world. - """ - - resource_type = Field("Address", const=True) - - city: fhirtypes.String = Field( - None, - alias="city", - title="Name of city, town etc.", - description=( - "The name of the city, town, suburb, village or other community or " - "delivery center." - ), - # if property is element of this resource. - element_property=True, - ) - city__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_city", title="Extension field for ``city``." - ) - - country: fhirtypes.String = Field( - None, - alias="country", - title="Country (e.g. can be ISO 3166 2 or 3 letter code)", - description="Country - a nation as commonly understood or generally accepted.", - # if property is element of this resource. - element_property=True, - ) - country__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_country", title="Extension field for ``country``." - ) - - district: fhirtypes.String = Field( - None, - alias="district", - title="District name (aka county)", - description="The name of the administrative area (county).", - # if property is element of this resource. - element_property=True, - ) - district__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_district", title="Extension field for ``district``." - ) - - line: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="line", - title="Street name, number, direction & P.O. Box etc.", - description=( - "This component contains the house number, apartment number, street " - "name, street direction, P.O. Box number, delivery hints, and similar " - "address information." - ), - # if property is element of this resource. - element_property=True, - ) - line__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_line", title="Extension field for ``line``.") - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Time period when address was/is in use", - description=None, - # if property is element of this resource. - element_property=True, - ) - - postalCode: fhirtypes.String = Field( - None, - alias="postalCode", - title="Postal code for area", - description="A postal code designating a region defined by the postal service.", - # if property is element of this resource. - element_property=True, - ) - postalCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_postalCode", title="Extension field for ``postalCode``." - ) - - state: fhirtypes.String = Field( - None, - alias="state", - title="Sub-unit of country (abbreviations ok)", - description=( - "Sub-unit of a country with limited sovereignty in a federally " - "organized country. A code may be used if codes are in common use (e.g." - " US 2 letter state codes)." - ), - # if property is element of this resource. - element_property=True, - ) - state__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_state", title="Extension field for ``state``." - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Text representation of the address", - description=( - "Specifies the entire address as it should be displayed e.g. on a " - "postal label. This may be provided instead of or as well as the " - "specific parts." - ), - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="postal | physical | both", - description=( - "Distinguishes between physical addresses (those you can visit) and " - "mailing addresses (e.g. PO Boxes and care-of addresses). Most " - "addresses are both." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["postal", "physical", "both"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - use: fhirtypes.Code = Field( - None, - alias="use", - title="home | work | temp | old | billing - purpose of this address", - description="The purpose of this address.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["home", "work", "temp", "old", "billing"], - ) - use__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_use", title="Extension field for ``use``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Address`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "use", - "type", - "text", - "line", - "city", - "district", - "state", - "postalCode", - "country", - "period", - ] diff --git a/fhir/resources/adverseevent.py b/fhir/resources/adverseevent.py deleted file mode 100644 index f03d4530..00000000 --- a/fhir/resources/adverseevent.py +++ /dev/null @@ -1,526 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/AdverseEvent -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class AdverseEvent(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Medical care, research study or other healthcare event causing physical - injury. - Actual or potential/avoided event causing unintended physical injury - resulting from or contributed to by medical care, a research study or other - healthcare setting factors that requires additional monitoring, treatment, - or hospitalization, or that results in death. - """ - - resource_type = Field("AdverseEvent", const=True) - - actuality: fhirtypes.Code = Field( - None, - alias="actuality", - title="actual | potential", - description=( - "Whether the event actually happened, or just had the potential to. " - "Note that this is independent of whether anyone was affected or harmed" - " or how severely." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["actual", "potential"], - ) - actuality__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_actuality", title="Extension field for ``actuality``." - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title=( - "product-problem | product-quality | product-use-error | wrong-dose | " - "incorrect-prescribing-information | wrong-technique | wrong-route-of-" - "administration | wrong-rate | wrong-duration | wrong-time | expired-" - "drug | medical-device-use-error | problem-different-manufacturer | " - "unsafe-physical-environment" - ), - description="The overall type of event, intended for search and filtering purposes.", - # if property is element of this resource. - element_property=True, - ) - - contributor: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="contributor", - title="Who was involved in the adverse event or the potential adverse event", - description=( - "Parties that may or should contribute or have contributed information " - "to the adverse event, which can consist of one or more activities. " - "Such information includes information leading to the decision to " - "perform the activity and how to perform the activity (e.g. " - "consultant), information that the activity itself seeks to reveal " - "(e.g. informant of clinical history), or information about what " - "activity was performed (e.g. informant witness)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Device"], - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="When the event occurred", - description="The date (and perhaps time) when the adverse event occurred.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - detected: fhirtypes.DateTime = Field( - None, - alias="detected", - title="When the event was detected", - description=( - "Estimated or actual date the AdverseEvent began, in the opinion of the" - " reporter." - ), - # if property is element of this resource. - element_property=True, - ) - detected__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_detected", title="Extension field for ``detected``." - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter created as part of", - description=( - "The Encounter during which AdverseEvent was created or to which the " - "creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - event: fhirtypes.CodeableConceptType = Field( - None, - alias="event", - title="Type of the event itself in relation to the subject", - description=( - "This element defines the specific type of event that occurred or that " - "was prevented from occurring." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Business identifier for the event", - description=( - "Business identifiers assigned to this adverse event by the performer " - "or other systems which remain constant as the resource is updated and " - "propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - location: fhirtypes.ReferenceType = Field( - None, - alias="location", - title="Location where adverse event occurred", - description="The information about where the adverse event occurred.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - outcome: fhirtypes.CodeableConceptType = Field( - None, - alias="outcome", - title=( - "resolved | recovering | ongoing | resolvedWithSequelae | fatal | " - "unknown" - ), - description="Describes the type of outcome from the adverse event.", - # if property is element of this resource. - element_property=True, - ) - - recordedDate: fhirtypes.DateTime = Field( - None, - alias="recordedDate", - title="When the event was recorded", - description=( - "The date on which the existence of the AdverseEvent was first " "recorded." - ), - # if property is element of this resource. - element_property=True, - ) - recordedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_recordedDate", title="Extension field for ``recordedDate``." - ) - - recorder: fhirtypes.ReferenceType = Field( - None, - alias="recorder", - title="Who recorded the adverse event", - description=( - "Information on who recorded the adverse event. May be the patient or " - "a practitioner." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - ], - ) - - referenceDocument: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="referenceDocument", - title="AdverseEvent.referenceDocument", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - resultingCondition: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="resultingCondition", - title="Effect on the subject due to this event", - description=( - "Includes information about the reaction that occurred as a result of " - "exposure to a substance (for example, a drug or a chemical)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition"], - ) - - seriousness: fhirtypes.CodeableConceptType = Field( - None, - alias="seriousness", - title="Seriousness of the event", - description="Assessment whether this event was of real importance.", - # if property is element of this resource. - element_property=True, - ) - - severity: fhirtypes.CodeableConceptType = Field( - None, - alias="severity", - title="mild | moderate | severe", - description=( - "Describes the severity of the adverse event, in relation to the " - "subject. Contrast to AdverseEvent.seriousness - a severe rash might " - "not be serious, but a mild heart problem is." - ), - # if property is element of this resource. - element_property=True, - ) - - study: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="study", - title="AdverseEvent.study", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ResearchStudy"], - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Subject impacted by event", - description="This subject or group impacted by the event.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group", "Practitioner", "RelatedPerson"], - ) - - subjectMedicalHistory: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="subjectMedicalHistory", - title="AdverseEvent.subjectMedicalHistory", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "AllergyIntolerance", - "FamilyMemberHistory", - "Immunization", - "Procedure", - "Media", - "DocumentReference", - ], - ) - - suspectEntity: typing.List[fhirtypes.AdverseEventSuspectEntityType] = Field( - None, - alias="suspectEntity", - title="The suspected agent causing the adverse event", - description=( - "Describes the entity that is suspected to have caused the adverse " - "event." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AdverseEvent`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "actuality", - "category", - "event", - "subject", - "encounter", - "date", - "detected", - "recordedDate", - "resultingCondition", - "location", - "seriousness", - "severity", - "outcome", - "recorder", - "contributor", - "suspectEntity", - "subjectMedicalHistory", - "referenceDocument", - "study", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1409( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("actuality", "actuality__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class AdverseEventSuspectEntity(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The suspected agent causing the adverse event. - Describes the entity that is suspected to have caused the adverse event. - """ - - resource_type = Field("AdverseEventSuspectEntity", const=True) - - causality: typing.List[fhirtypes.AdverseEventSuspectEntityCausalityType] = Field( - None, - alias="causality", - title="Information on the possible cause of the event", - description=None, - # if property is element of this resource. - element_property=True, - ) - - instance: fhirtypes.ReferenceType = Field( - ..., - alias="instance", - title="Refers to the specific entity that caused the adverse event", - description=( - "Identifies the actual instance of what caused the adverse event. May " - "be a substance, medication, medication administration, medication " - "statement or a device." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Immunization", - "Procedure", - "Substance", - "Medication", - "MedicationAdministration", - "MedicationStatement", - "Device", - ], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AdverseEventSuspectEntity`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "instance", "causality"] - - -class AdverseEventSuspectEntityCausality(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information on the possible cause of the event. - """ - - resource_type = Field("AdverseEventSuspectEntityCausality", const=True) - - assessment: fhirtypes.CodeableConceptType = Field( - None, - alias="assessment", - title="Assessment of if the entity caused the event", - description=None, - # if property is element of this resource. - element_property=True, - ) - - author: fhirtypes.ReferenceType = Field( - None, - alias="author", - title="AdverseEvent.suspectEntity.causalityAuthor", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - method: fhirtypes.CodeableConceptType = Field( - None, - alias="method", - title="ProbabilityScale | Bayesian | Checklist", - description=None, - # if property is element of this resource. - element_property=True, - ) - - productRelatedness: fhirtypes.String = Field( - None, - alias="productRelatedness", - title="AdverseEvent.suspectEntity.causalityProductRelatedness", - description=None, - # if property is element of this resource. - element_property=True, - ) - productRelatedness__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_productRelatedness", - title="Extension field for ``productRelatedness``.", - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AdverseEventSuspectEntityCausality`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "assessment", - "productRelatedness", - "author", - "method", - ] diff --git a/fhir/resources/age.py b/fhir/resources/age.py deleted file mode 100644 index 898a7eb0..00000000 --- a/fhir/resources/age.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Age -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import quantity - - -class Age(quantity.Quantity): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A duration of time during which an organism (or a process) has existed. - """ - - resource_type = Field("Age", const=True) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Age`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "value", "comparator", "unit", "system", "code"] diff --git a/fhir/resources/allergyintolerance.py b/fhir/resources/allergyintolerance.py deleted file mode 100644 index 15bc2fa3..00000000 --- a/fhir/resources/allergyintolerance.py +++ /dev/null @@ -1,552 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/AllergyIntolerance -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class AllergyIntolerance(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Allergy or Intolerance (generally: Risk of adverse reaction to a substance). - Risk of harmful or undesirable, physiological response which is unique to - an individual and associated with exposure to a substance. - """ - - resource_type = Field("AllergyIntolerance", const=True) - - asserter: fhirtypes.ReferenceType = Field( - None, - alias="asserter", - title="Source of the information about the allergy", - description="The source of the information about the allergy that is recorded.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "RelatedPerson", - "Practitioner", - "PractitionerRole", - ], - ) - - category: typing.List[fhirtypes.Code] = Field( - None, - alias="category", - title="food | medication | environment | biologic", - description="Category of the identified substance.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["food", "medication", "environment", "biologic"], - ) - category__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_category", title="Extension field for ``category``.") - - clinicalStatus: fhirtypes.CodeableConceptType = Field( - None, - alias="clinicalStatus", - title="active | inactive | resolved", - description="The clinical status of the allergy or intolerance.", - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Code that identifies the allergy or intolerance", - description=( - "Code for an allergy or intolerance statement (either a positive or a " - "negated/excluded statement). This may be a code for a substance or " - "pharmaceutical product that is considered to be responsible for the " - 'adverse reaction risk (e.g., "Latex"), an allergy or intolerance ' - 'condition (e.g., "Latex allergy"), or a negated/excluded code for a ' - 'specific substance or class (e.g., "No latex allergy") or a general or' - ' categorical negated statement (e.g., "No known allergy", "No known ' - 'drug allergies"). Note: the substance for a specific reaction may be ' - "different from the substance identified as the cause of the risk, but " - "it must be consistent with it. For instance, it may be a more specific" - " substance (e.g. a brand medication) or a composite product that " - "includes the identified substance. It must be clinically safe to only " - "process the 'code' and ignore the 'reaction.substance'. If a " - "receiving system is unable to confirm that " - "AllergyIntolerance.reaction.substance falls within the semantic scope " - "of AllergyIntolerance.code, then the receiving system should ignore " - "AllergyIntolerance.reaction.substance." - ), - # if property is element of this resource. - element_property=True, - ) - - criticality: fhirtypes.Code = Field( - None, - alias="criticality", - title="low | high | unable-to-assess", - description=( - "Estimate of the potential clinical harm, or seriousness, of the " - "reaction to the identified substance." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["low", "high", "unable-to-assess"], - ) - criticality__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_criticality", title="Extension field for ``criticality``." - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter when the allergy or intolerance was asserted", - description="The encounter when the allergy or intolerance was asserted.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External ids for this item", - description=( - "Business identifiers assigned to this AllergyIntolerance by the " - "performer or other systems which remain constant as the resource is " - "updated and propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - lastOccurrence: fhirtypes.DateTime = Field( - None, - alias="lastOccurrence", - title="Date(/time) of last known occurrence of a reaction", - description=( - "Represents the date and/or time of the last known occurrence of a " - "reaction event." - ), - # if property is element of this resource. - element_property=True, - ) - lastOccurrence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastOccurrence", title="Extension field for ``lastOccurrence``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Additional text not captured in other fields", - description=( - "Additional narrative about the propensity for the Adverse Reaction, " - "not captured in other fields." - ), - # if property is element of this resource. - element_property=True, - ) - - onsetAge: fhirtypes.AgeType = Field( - None, - alias="onsetAge", - title="When allergy or intolerance was identified", - description=( - "Estimated or actual date, date-time, or age when allergy or " - "intolerance was identified." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - - onsetDateTime: fhirtypes.DateTime = Field( - None, - alias="onsetDateTime", - title="When allergy or intolerance was identified", - description=( - "Estimated or actual date, date-time, or age when allergy or " - "intolerance was identified." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - onsetDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_onsetDateTime", title="Extension field for ``onsetDateTime``." - ) - - onsetPeriod: fhirtypes.PeriodType = Field( - None, - alias="onsetPeriod", - title="When allergy or intolerance was identified", - description=( - "Estimated or actual date, date-time, or age when allergy or " - "intolerance was identified." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - - onsetRange: fhirtypes.RangeType = Field( - None, - alias="onsetRange", - title="When allergy or intolerance was identified", - description=( - "Estimated or actual date, date-time, or age when allergy or " - "intolerance was identified." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - - onsetString: fhirtypes.String = Field( - None, - alias="onsetString", - title="When allergy or intolerance was identified", - description=( - "Estimated or actual date, date-time, or age when allergy or " - "intolerance was identified." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - onsetString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_onsetString", title="Extension field for ``onsetString``." - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="Who the sensitivity is for", - description="The patient who has the allergy or intolerance.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - reaction: typing.List[fhirtypes.AllergyIntoleranceReactionType] = Field( - None, - alias="reaction", - title="Adverse Reaction Events linked to exposure to substance", - description=( - "Details about each adverse reaction event linked to exposure to the " - "identified substance." - ), - # if property is element of this resource. - element_property=True, - ) - - recordedDate: fhirtypes.DateTime = Field( - None, - alias="recordedDate", - title="Date first version of the resource instance was recorded", - description=( - "The recordedDate represents when this particular AllergyIntolerance " - "record was created in the system, which is often a system-generated " - "date." - ), - # if property is element of this resource. - element_property=True, - ) - recordedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_recordedDate", title="Extension field for ``recordedDate``." - ) - - recorder: fhirtypes.ReferenceType = Field( - None, - alias="recorder", - title="Who recorded the sensitivity", - description=( - "Individual who recorded the record and takes responsibility for its " - "content." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Patient", - "RelatedPerson", - ], - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="allergy | intolerance - Underlying mechanism (if known)", - description=( - "Identification of the underlying physiological mechanism for the " - "reaction risk." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["allergy", "intolerance"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - verificationStatus: fhirtypes.CodeableConceptType = Field( - None, - alias="verificationStatus", - title="unconfirmed | confirmed | refuted | entered-in-error", - description=( - "Assertion about certainty associated with the propensity, or potential" - " risk, of a reaction to the identified substance (including " - "pharmaceutical product)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AllergyIntolerance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "clinicalStatus", - "verificationStatus", - "type", - "category", - "criticality", - "code", - "patient", - "encounter", - "onsetDateTime", - "onsetAge", - "onsetPeriod", - "onsetRange", - "onsetString", - "recordedDate", - "recorder", - "asserter", - "lastOccurrence", - "note", - "reaction", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2026( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "onset": [ - "onsetAge", - "onsetDateTime", - "onsetPeriod", - "onsetRange", - "onsetString", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class AllergyIntoleranceReaction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Adverse Reaction Events linked to exposure to substance. - Details about each adverse reaction event linked to exposure to the - identified substance. - """ - - resource_type = Field("AllergyIntoleranceReaction", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Description of the event as a whole", - description=( - "Text description about the reaction as a whole, including details of " - "the manifestation if required." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - exposureRoute: fhirtypes.CodeableConceptType = Field( - None, - alias="exposureRoute", - title="How the subject was exposed to the substance", - description=( - "Identification of the route by which the subject was exposed to the " - "substance." - ), - # if property is element of this resource. - element_property=True, - ) - - manifestation: typing.List[fhirtypes.CodeableConceptType] = Field( - ..., - alias="manifestation", - title="Clinical symptoms/signs associated with the Event", - description=( - "Clinical symptoms and/or signs that are observed or associated with " - "the adverse reaction event." - ), - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Text about event not captured in other fields", - description=( - "Additional text about the adverse reaction event not captured in other" - " fields." - ), - # if property is element of this resource. - element_property=True, - ) - - onset: fhirtypes.DateTime = Field( - None, - alias="onset", - title="Date(/time) when manifestations showed", - description="Record of the date and/or time of the onset of the Reaction.", - # if property is element of this resource. - element_property=True, - ) - onset__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_onset", title="Extension field for ``onset``." - ) - - severity: fhirtypes.Code = Field( - None, - alias="severity", - title="mild | moderate | severe (of event as a whole)", - description=( - "Clinical assessment of the severity of the reaction event as a whole, " - "potentially considering multiple different manifestations." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["mild", "moderate", "severe"], - ) - severity__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_severity", title="Extension field for ``severity``." - ) - - substance: fhirtypes.CodeableConceptType = Field( - None, - alias="substance", - title=( - "Specific substance or pharmaceutical product considered to be " - "responsible for event" - ), - description=( - "Identification of the specific substance (or pharmaceutical product) " - "considered to be responsible for the Adverse Reaction event. Note: the" - " substance for a specific reaction may be different from the substance" - " identified as the cause of the risk, but it must be consistent with " - "it. For instance, it may be a more specific substance (e.g. a brand " - "medication) or a composite product that includes the identified " - "substance. It must be clinically safe to only process the 'code' and " - "ignore the 'reaction.substance'. If a receiving system is unable to " - "confirm that AllergyIntolerance.reaction.substance falls within the " - "semantic scope of AllergyIntolerance.code, then the receiving system " - "should ignore AllergyIntolerance.reaction.substance." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AllergyIntoleranceReaction`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "substance", - "manifestation", - "description", - "onset", - "severity", - "exposureRoute", - "note", - ] diff --git a/fhir/resources/annotation.py b/fhir/resources/annotation.py deleted file mode 100644 index f1a01107..00000000 --- a/fhir/resources/annotation.py +++ /dev/null @@ -1,192 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Annotation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import element, fhirtypes - - -class Annotation(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Text node with attribution. - A text note which also contains information about who made the statement - and when. - """ - - resource_type = Field("Annotation", const=True) - - authorReference: fhirtypes.ReferenceType = Field( - None, - alias="authorReference", - title="Individual responsible for the annotation", - description="The individual responsible for making the annotation.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e author[x] - one_of_many="author", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "Patient", - "RelatedPerson", - "Organization", - ], - ) - - authorString: fhirtypes.String = Field( - None, - alias="authorString", - title="Individual responsible for the annotation", - description="The individual responsible for making the annotation.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e author[x] - one_of_many="author", - one_of_many_required=False, - ) - authorString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_authorString", title="Extension field for ``authorString``." - ) - - text: fhirtypes.Markdown = Field( - None, - alias="text", - title="The annotation - text content (as markdown)", - description="The text of the annotation in markdown format.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - time: fhirtypes.DateTime = Field( - None, - alias="time", - title="When the annotation was made", - description="Indicates when this particular annotation was made.", - # if property is element of this resource. - element_property=True, - ) - time__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_time", title="Extension field for ``time``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Annotation`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "authorReference", "authorString", "time", "text"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1226( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("text", "text__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1226( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"author": ["authorReference", "authorString"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/appointment.py b/fhir/resources/appointment.py deleted file mode 100644 index 1c8f4130..00000000 --- a/fhir/resources/appointment.py +++ /dev/null @@ -1,624 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Appointment -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Appointment(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A booking of a healthcare event among patient(s), practitioner(s), related - person(s) and/or device(s) for a specific date/time. This may result in one - or more Encounter(s). - """ - - resource_type = Field("Appointment", const=True) - - appointmentType: fhirtypes.CodeableConceptType = Field( - None, - alias="appointmentType", - title=( - "The style of appointment or patient that has been booked in the slot " - "(not service type)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="The service request this appointment is allocated to assess", - description=( - "The service request this appointment is allocated to assess (e.g. " - "incoming referral or procedure request)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ServiceRequest"], - ) - - cancelationReason: fhirtypes.CodeableConceptType = Field( - None, - alias="cancelationReason", - title="The coded reason for the appointment being cancelled", - description=( - "The coded reason for the appointment being cancelled. This is often " - "used in reporting/billing/futher processing to determine if further " - "actions are required, or specific fees apply." - ), - # if property is element of this resource. - element_property=True, - ) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Additional comments", - description="Additional comments about the appointment.", - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="The date that this appointment was initially created", - description=( - "The date that this appointment was initially created. This could be " - "different to the meta.lastModified value on the initial entry, as this" - " could have been before the resource was created on the FHIR server, " - "and should remain unchanged over the lifespan of the appointment." - ), - # if property is element of this resource. - element_property=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Shown on a subject line in a meeting request, or appointment list", - description=( - "The brief description of the appointment as would be shown on a " - "subject line in a meeting request, or appointment list. Detailed or " - "expanded information should be put in the comment field." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - end: fhirtypes.Instant = Field( - None, - alias="end", - title="When appointment is to conclude", - description="Date/Time that the appointment is to conclude.", - # if property is element of this resource. - element_property=True, - ) - end__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_end", title="Extension field for ``end``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Ids for this item", - description=( - "This records identifiers associated with this appointment concern that" - " are defined by business processes and/or used to refer to it when a " - "direct URL reference to the resource itself is not appropriate (e.g. " - "in CDA documents, or in written / printed documentation)." - ), - # if property is element of this resource. - element_property=True, - ) - - minutesDuration: fhirtypes.PositiveInt = Field( - None, - alias="minutesDuration", - title="Can be less than start/end (e.g. estimate)", - description=( - "Number of minutes that the appointment is to take. This can be less " - "than the duration between the start and end times. For example, where" - " the actual time of appointment is only an estimate or if a 30 minute " - "appointment is being requested, but any time would work. Also, if " - "there is, for example, a planned 15 minute break in the middle of a " - "long appointment, the duration may be 15 minutes less than the " - "difference between the start and end." - ), - # if property is element of this resource. - element_property=True, - ) - minutesDuration__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_minutesDuration", title="Extension field for ``minutesDuration``." - ) - - participant: typing.List[fhirtypes.AppointmentParticipantType] = Field( - ..., - alias="participant", - title="Participants involved in appointment", - description="List of participants involved in the appointment.", - # if property is element of this resource. - element_property=True, - ) - - patientInstruction: fhirtypes.String = Field( - None, - alias="patientInstruction", - title="Detailed information and instructions for the patient", - description=( - "While Appointment.comment contains information for internal use, " - "Appointment.patientInstructions is used to capture patient facing " - "information about the Appointment (e.g. please bring your referral or " - "fast from 8pm night before)." - ), - # if property is element of this resource. - element_property=True, - ) - patientInstruction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_patientInstruction", - title="Extension field for ``patientInstruction``.", - ) - - priority: fhirtypes.UnsignedInt = Field( - None, - alias="priority", - title="Used to make informed decisions if needing to re-prioritize", - description=( - "The priority of the appointment. Can be used to make informed " - "decisions if needing to re-prioritize appointments. (The iCal Standard" - " specifies 0 as undefined, 1 as highest, 9 as lowest priority)." - ), - # if property is element of this resource. - element_property=True, - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Coded reason this appointment is scheduled", - description=( - "The coded reason that this appointment is being scheduled. This is " - "more clinical than administrative." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Reason the appointment is to take place (resource)", - description=( - "Reason the appointment has been scheduled to take place, as specified " - "using information from another resource. When the patient arrives and " - "the encounter begins it may be used as the admission diagnosis. The " - "indication will typically be a Condition (with other resources " - "referenced in the evidence.detail), or a Procedure." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Procedure", - "Observation", - "ImmunizationRecommendation", - ], - ) - - requestedPeriod: typing.List[fhirtypes.PeriodType] = Field( - None, - alias="requestedPeriod", - title=( - "Potential date/time interval(s) requested to allocate the appointment " - "within" - ), - description=( - "A set of date ranges (potentially including times) that the " - "appointment is preferred to be scheduled within. The duration " - "(usually in minutes) could also be provided to indicate the length of " - "the appointment to fill and populate the start/end times for the " - "actual allocated time. However, in other situations the duration may " - "be calculated by the scheduling system." - ), - # if property is element of this resource. - element_property=True, - ) - - serviceCategory: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="serviceCategory", - title=( - "A broad categorization of the service that is to be performed during " - "this appointment" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - serviceType: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="serviceType", - title="The specific service that is to be performed during this appointment", - description=None, - # if property is element of this resource. - element_property=True, - ) - - slot: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="slot", - title="The slots that this appointment is filling", - description=( - "The slots from the participants' schedules that will be filled by the " - "appointment." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Slot"], - ) - - specialty: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="specialty", - title=( - "The specialty of a practitioner that would be required to perform the " - "service requested in this appointment" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - start: fhirtypes.Instant = Field( - None, - alias="start", - title="When appointment is to take place", - description="Date/Time that the appointment is to take place.", - # if property is element of this resource. - element_property=True, - ) - start__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_start", title="Extension field for ``start``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "proposed | pending | booked | arrived | fulfilled | cancelled | noshow" - " | entered-in-error | checked-in | waitlist" - ), - description=( - "The overall status of the Appointment. Each of the participants has " - "their own participation status which indicates their involvement in " - "the process, however this status indicates the shared status." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "proposed", - "pending", - "booked", - "arrived", - "fulfilled", - "cancelled", - "noshow", - "entered-in-error", - "checked-in", - "waitlist", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - supportingInformation: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingInformation", - title="Additional information to support the appointment", - description=( - "Additional information to support the appointment provided when making" - " the appointment." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Appointment`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "cancelationReason", - "serviceCategory", - "serviceType", - "specialty", - "appointmentType", - "reasonCode", - "reasonReference", - "priority", - "description", - "supportingInformation", - "start", - "end", - "minutesDuration", - "slot", - "created", - "comment", - "patientInstruction", - "basedOn", - "participant", - "requestedPeriod", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1348( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class AppointmentParticipant(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Participants involved in appointment. - List of participants involved in the appointment. - """ - - resource_type = Field("AppointmentParticipant", const=True) - - actor: fhirtypes.ReferenceType = Field( - None, - alias="actor", - title="Person, Location/HealthcareService or Device", - description=( - "A Person, Location/HealthcareService or Device that is participating " - "in the appointment." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Device", - "HealthcareService", - "Location", - ], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Participation period of the actor", - description=None, - # if property is element of this resource. - element_property=True, - ) - - required: fhirtypes.Code = Field( - None, - alias="required", - title="required | optional | information-only", - description=( - "Whether this participant is required to be present at the meeting. " - "This covers a use-case where two doctors need to meet to discuss the " - "results for a specific patient, and the patient is not required to be " - "present." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["required", "optional", "information-only"], - ) - required__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_required", title="Extension field for ``required``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="accepted | declined | tentative | needs-action", - description="Participation status of the actor.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["accepted", "declined", "tentative", "needs-action"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Role of participant in the appointment", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AppointmentParticipant`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "actor", - "required", - "status", - "period", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2499( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/appointmentresponse.py b/fhir/resources/appointmentresponse.py deleted file mode 100644 index 8e4e8de5..00000000 --- a/fhir/resources/appointmentresponse.py +++ /dev/null @@ -1,234 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/AppointmentResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class AppointmentResponse(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A reply to an appointment request for a patient and/or practitioner(s), - such as a confirmation or rejection. - """ - - resource_type = Field("AppointmentResponse", const=True) - - actor: fhirtypes.ReferenceType = Field( - None, - alias="actor", - title="Person, Location, HealthcareService, or Device", - description=( - "A Person, Location, HealthcareService, or Device that is participating" - " in the appointment." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Device", - "HealthcareService", - "Location", - ], - ) - - appointment: fhirtypes.ReferenceType = Field( - ..., - alias="appointment", - title="Appointment this response relates to", - description="Appointment that this response is replying to.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Appointment"], - ) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Additional comments", - description="Additional comments about the appointment.", - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - end: fhirtypes.Instant = Field( - None, - alias="end", - title="Time from appointment, or requested new end time", - description=( - "This may be either the same as the appointment request to confirm the " - "details of the appointment, or alternately a new time to request a re-" - "negotiation of the end time." - ), - # if property is element of this resource. - element_property=True, - ) - end__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_end", title="Extension field for ``end``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Ids for this item", - description=( - "This records identifiers associated with this appointment response " - "concern that are defined by business processes and/ or used to refer " - "to it when a direct URL reference to the resource itself is not " - "appropriate." - ), - # if property is element of this resource. - element_property=True, - ) - - participantStatus: fhirtypes.Code = Field( - None, - alias="participantStatus", - title="accepted | declined | tentative | needs-action", - description=( - "Participation status of the participant. When the status is declined " - "or tentative if the start/end times are different to the appointment, " - "then these times should be interpreted as a requested time change. " - "When the status is accepted, the times can either be the time of the " - "appointment (as a confirmation of the time) or can be empty." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["accepted", "declined", "tentative", "needs-action"], - ) - participantStatus__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_participantStatus", - title="Extension field for ``participantStatus``.", - ) - - participantType: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="participantType", - title="Role of participant in the appointment", - description=None, - # if property is element of this resource. - element_property=True, - ) - - start: fhirtypes.Instant = Field( - None, - alias="start", - title="Time from appointment, or requested new start time", - description=( - "Date/Time that the appointment is to take place, or requested new " - "start time." - ), - # if property is element of this resource. - element_property=True, - ) - start__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_start", title="Extension field for ``start``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AppointmentResponse`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "appointment", - "start", - "end", - "participantType", - "actor", - "participantStatus", - "comment", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2180( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("participantStatus", "participantStatus__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/attachment.py b/fhir/resources/attachment.py deleted file mode 100644 index 14792a7d..00000000 --- a/fhir/resources/attachment.py +++ /dev/null @@ -1,151 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Attachment -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import element, fhirtypes - - -class Attachment(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Content in a format defined elsewhere. - For referring to data content defined in other formats. - """ - - resource_type = Field("Attachment", const=True) - - contentType: fhirtypes.Code = Field( - None, - alias="contentType", - title="Mime type of the content, with charset etc.", - description=( - "Identifies the type of the data in the attachment and allows a method " - "to be chosen to interpret or render the data. Includes mime type " - "parameters such as charset where appropriate." - ), - # if property is element of this resource. - element_property=True, - ) - contentType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_contentType", title="Extension field for ``contentType``." - ) - - creation: fhirtypes.DateTime = Field( - None, - alias="creation", - title="Date attachment was first created", - description="The date that the attachment was first created.", - # if property is element of this resource. - element_property=True, - ) - creation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_creation", title="Extension field for ``creation``." - ) - - data: fhirtypes.Base64Binary = Field( - None, - alias="data", - title="Data inline, base64ed", - description=( - "The actual data of the attachment - a sequence of bytes, base64 " - "encoded." - ), - # if property is element of this resource. - element_property=True, - ) - data__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_data", title="Extension field for ``data``." - ) - - hash: fhirtypes.Base64Binary = Field( - None, - alias="hash", - title="Hash of the data (sha-1, base64ed)", - description="The calculated hash of the data using SHA-1. Represented using base64.", - # if property is element of this resource. - element_property=True, - ) - hash__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_hash", title="Extension field for ``hash``." - ) - - language: fhirtypes.Code = Field( - None, - alias="language", - title="Human language of the content (BCP-47)", - description=( - "The human language of the content. The value can be any valid value " - "according to BCP 47." - ), - # if property is element of this resource. - element_property=True, - ) - language__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_language", title="Extension field for ``language``." - ) - - size: fhirtypes.UnsignedInt = Field( - None, - alias="size", - title="Number of bytes of content (if url provided)", - description=( - "The number of bytes of data that make up this attachment (before " - "base64 encoding, if that is done)." - ), - # if property is element of this resource. - element_property=True, - ) - size__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_size", title="Extension field for ``size``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Label to display in place of the data", - description="A label or set of text to display in place of the data.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Url = Field( - None, - alias="url", - title="Uri where the data can be found", - description="A location where the data can be accessed.", - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Attachment`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "contentType", - "language", - "data", - "url", - "size", - "hash", - "title", - "creation", - ] diff --git a/fhir/resources/auditevent.py b/fhir/resources/auditevent.py deleted file mode 100644 index 86219d5a..00000000 --- a/fhir/resources/auditevent.py +++ /dev/null @@ -1,903 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/AuditEvent -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class AuditEvent(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Event record kept for security purposes. - A record of an event made for purposes of maintaining a security log. - Typical uses include detection of intrusion attempts and monitoring for - inappropriate usage. - """ - - resource_type = Field("AuditEvent", const=True) - - action: fhirtypes.Code = Field( - None, - alias="action", - title="Type of action performed during the event", - description=( - "Indicator for type of action performed during the event that generated" - " the audit." - ), - # if property is element of this resource. - element_property=True, - ) - action__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_action", title="Extension field for ``action``." - ) - - agent: typing.List[fhirtypes.AuditEventAgentType] = Field( - ..., - alias="agent", - title="Actor involved in the event", - description=( - "An actor taking an active role in the event or activity that is " "logged." - ), - # if property is element of this resource. - element_property=True, - ) - - entity: typing.List[fhirtypes.AuditEventEntityType] = Field( - None, - alias="entity", - title="Data or objects used", - description="Specific instances of data or objects that have been accessed.", - # if property is element of this resource. - element_property=True, - ) - - outcome: fhirtypes.Code = Field( - None, - alias="outcome", - title="Whether the event succeeded or failed", - description="Indicates whether the event succeeded or failed.", - # if property is element of this resource. - element_property=True, - ) - outcome__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_outcome", title="Extension field for ``outcome``." - ) - - outcomeDesc: fhirtypes.String = Field( - None, - alias="outcomeDesc", - title="Description of the event outcome", - description="A free text description of the outcome of the event.", - # if property is element of this resource. - element_property=True, - ) - outcomeDesc__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_outcomeDesc", title="Extension field for ``outcomeDesc``." - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="When the activity occurred", - description="The period during which the activity occurred.", - # if property is element of this resource. - element_property=True, - ) - - purposeOfEvent: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="purposeOfEvent", - title="The purposeOfUse of the event", - description=( - "The purposeOfUse (reason) that was used during the event being " - "recorded." - ), - # if property is element of this resource. - element_property=True, - ) - - recorded: fhirtypes.Instant = Field( - None, - alias="recorded", - title="Time when the event was recorded", - description="The time when the event was recorded.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - recorded__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_recorded", title="Extension field for ``recorded``." - ) - - source: fhirtypes.AuditEventSourceType = Field( - ..., - alias="source", - title="Audit Event Reporter", - description="The system that is reporting the event.", - # if property is element of this resource. - element_property=True, - ) - - subtype: typing.List[fhirtypes.CodingType] = Field( - None, - alias="subtype", - title="More specific type/id for the event", - description="Identifier for the category of event.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodingType = Field( - ..., - alias="type", - title="Type/identifier of event", - description=( - "Identifier for a family of the event. For example, a menu item, " - "program, rule, policy, function code, application name or URL. It " - "identifies the performed function." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AuditEvent`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "type", - "subtype", - "action", - "period", - "recorded", - "outcome", - "outcomeDesc", - "purposeOfEvent", - "agent", - "source", - "entity", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1198( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("recorded", "recorded__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class AuditEventAgent(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Actor involved in the event. - An actor taking an active role in the event or activity that is logged. - """ - - resource_type = Field("AuditEventAgent", const=True) - - altId: fhirtypes.String = Field( - None, - alias="altId", - title="Alternative User identity", - description=( - "Alternative agent Identifier. For a human, this should be a user " - "identifier text string from authentication system. This identifier " - "would be one known to a common authentication system (e.g. single " - "sign-on), if available." - ), - # if property is element of this resource. - element_property=True, - ) - altId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_altId", title="Extension field for ``altId``." - ) - - location: fhirtypes.ReferenceType = Field( - None, - alias="location", - title="Where", - description="Where the event occurred.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - media: fhirtypes.CodingType = Field( - None, - alias="media", - title="Type of media", - description=( - "Type of media involved. Used when the event is about " - "exporting/importing onto media." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Human friendly name for the agent", - description="Human-meaningful name for the agent.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - network: fhirtypes.AuditEventAgentNetworkType = Field( - None, - alias="network", - title="Logical network location for application activity", - description=( - "Logical network location for application activity, if the activity has" - " a network location." - ), - # if property is element of this resource. - element_property=True, - ) - - policy: typing.List[fhirtypes.Uri] = Field( - None, - alias="policy", - title="Policy that authorized event", - description=( - "The policy or plan that authorized the activity being recorded. " - "Typically, a single activity may have multiple applicable policies, " - "such as patient consent, guarantor funding, etc. The policy would also" - " indicate the security token used." - ), - # if property is element of this resource. - element_property=True, - ) - policy__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_policy", title="Extension field for ``policy``.") - - purposeOfUse: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="purposeOfUse", - title="Reason given for this user", - description=( - "The reason (purpose of use), specific to this agent, that was used " - "during the event being recorded." - ), - # if property is element of this resource. - element_property=True, - ) - - requestor: bool = Field( - None, - alias="requestor", - title="Whether user is initiator", - description=( - "Indicator that the user is or is not the requestor, or initiator, for " - "the event being audited." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - requestor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_requestor", title="Extension field for ``requestor``." - ) - - role: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="role", - title="Agent role in the event", - description=( - "The security role that the user was acting under, that come from local" - " codes defined by the access control security system (e.g. RBAC, ABAC)" - " used in the local context." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="How agent participated", - description=( - "Specification of the participation type the user plays when performing" - " the event." - ), - # if property is element of this resource. - element_property=True, - ) - - who: fhirtypes.ReferenceType = Field( - None, - alias="who", - title="Identifier of who", - description="Reference to who this agent is that was involved in the event.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "PractitionerRole", - "Practitioner", - "Organization", - "Device", - "Patient", - "RelatedPerson", - ], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AuditEventAgent`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "role", - "who", - "altId", - "name", - "requestor", - "location", - "policy", - "media", - "network", - "purposeOfUse", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1693( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("requestor", "requestor__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class AuditEventAgentNetwork(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Logical network location for application activity. - Logical network location for application activity, if the activity has a - network location. - """ - - resource_type = Field("AuditEventAgentNetwork", const=True) - - address: fhirtypes.String = Field( - None, - alias="address", - title="Identifier for the network access point of the user device", - description=( - "An identifier for the network access point of the user device for the " - "audit event." - ), - # if property is element of this resource. - element_property=True, - ) - address__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_address", title="Extension field for ``address``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="The type of network access point", - description=( - "An identifier for the type of network access point that originated the" - " audit event." - ), - # if property is element of this resource. - element_property=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AuditEventAgentNetwork`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "address", "type"] - - -class AuditEventEntity(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Data or objects used. - Specific instances of data or objects that have been accessed. - """ - - resource_type = Field("AuditEventEntity", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Descriptive text", - description="Text that describes the entity in more detail.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - detail: typing.List[fhirtypes.AuditEventEntityDetailType] = Field( - None, - alias="detail", - title="Additional Information about the entity", - description=( - "Tagged value pairs for conveying additional information about the " - "entity." - ), - # if property is element of this resource. - element_property=True, - ) - - lifecycle: fhirtypes.CodingType = Field( - None, - alias="lifecycle", - title="Life-cycle stage for the entity", - description="Identifier for the data life-cycle stage for the entity.", - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Descriptor for entity", - description="A name of the entity in the audit event.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - query: fhirtypes.Base64Binary = Field( - None, - alias="query", - title="Query parameters", - description="The query parameters for a query-type entities.", - # if property is element of this resource. - element_property=True, - ) - query__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_query", title="Extension field for ``query``." - ) - - role: fhirtypes.CodingType = Field( - None, - alias="role", - title="What role the entity played", - description=( - "Code representing the role the entity played in the event being " - "audited." - ), - # if property is element of this resource. - element_property=True, - ) - - securityLabel: typing.List[fhirtypes.CodingType] = Field( - None, - alias="securityLabel", - title="Security labels on the entity", - description="Security labels for the identified entity.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodingType = Field( - None, - alias="type", - title="Type of entity involved", - description="The type of the object that was involved in this audit event.", - # if property is element of this resource. - element_property=True, - ) - - what: fhirtypes.ReferenceType = Field( - None, - alias="what", - title="Specific instance of resource", - description=( - "Identifies a specific instance of the entity. The reference should be " - "version specific." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AuditEventEntity`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "what", - "type", - "role", - "lifecycle", - "securityLabel", - "name", - "description", - "query", - "detail", - ] - - -class AuditEventEntityDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Additional Information about the entity. - Tagged value pairs for conveying additional information about the entity. - """ - - resource_type = Field("AuditEventEntityDetail", const=True) - - type: fhirtypes.String = Field( - None, - alias="type", - title="Name of the property", - description="The type of extra detail provided in the value.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - valueBase64Binary: fhirtypes.Base64Binary = Field( - None, - alias="valueBase64Binary", - title="Property value", - description="The value of the extra detail.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBase64Binary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valueBase64Binary", - title="Extension field for ``valueBase64Binary``.", - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Property value", - description="The value of the extra detail.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AuditEventEntityDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "valueString", - "valueBase64Binary", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2422( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2422( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"value": ["valueBase64Binary", "valueString"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class AuditEventSource(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Audit Event Reporter. - The system that is reporting the event. - """ - - resource_type = Field("AuditEventSource", const=True) - - observer: fhirtypes.ReferenceType = Field( - ..., - alias="observer", - title="The identity of source detecting the event", - description="Identifier of the source where the event was detected.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "PractitionerRole", - "Practitioner", - "Organization", - "Device", - "Patient", - "RelatedPerson", - ], - ) - - site: fhirtypes.String = Field( - None, - alias="site", - title="Logical source location within the enterprise", - description=( - "Logical source location within the healthcare enterprise network. For" - " example, a hospital or other provider location within a multi-entity " - "provider group." - ), - # if property is element of this resource. - element_property=True, - ) - site__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_site", title="Extension field for ``site``." - ) - - type: typing.List[fhirtypes.CodingType] = Field( - None, - alias="type", - title="The type of source where event originated", - description="Code specifying the type of source where event originated.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``AuditEventSource`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "site", "observer", "type"] diff --git a/fhir/resources/backboneelement.py b/fhir/resources/backboneelement.py deleted file mode 100644 index c7502e99..00000000 --- a/fhir/resources/backboneelement.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/BackboneElement -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import element, fhirtypes - - -class BackboneElement(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Base for elements defined inside a resource. - Base definition for all elements that are defined inside a resource - but - not those in a data type. - """ - - resource_type = Field("BackboneElement", const=True) - - modifierExtension: typing.List[fhirtypes.ExtensionType] = Field( - None, - alias="modifierExtension", - title="Extensions that cannot be ignored even if unrecognized", - description=( - "May be used to represent additional information that is not part of " - "the basic definition of the element and that modifies the " - "understanding of the element in which it is contained and/or the " - "understanding of the containing element's descendants. Usually " - "modifier elements provide negation or qualification. To make the use " - "of extensions safe and manageable, there is a strict set of governance" - " applied to the definition and use of extensions. Though any " - "implementer can define an extension, there is a set of requirements " - "that SHALL be met as part of the definition of the extension. " - "Applications processing a resource are required to check for modifier " - "extensions. Modifier extensions SHALL NOT change the meaning of any " - "elements on Resource or DomainResource (including cannot change the " - "meaning of modifierExtension itself)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BackboneElement`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension"] diff --git a/fhir/resources/basic.py b/fhir/resources/basic.py deleted file mode 100644 index fdae7dac..00000000 --- a/fhir/resources/basic.py +++ /dev/null @@ -1,116 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Basic -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import domainresource, fhirtypes - - -class Basic(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Resource for non-supported content. - Basic is used for handling concepts not yet defined in FHIR, narrative-only - resources that don't map to an existing resource, and custom resources not - appropriate for inclusion in the FHIR specification. - """ - - resource_type = Field("Basic", const=True) - - author: fhirtypes.ReferenceType = Field( - None, - alias="author", - title="Who created", - description="Indicates who was responsible for creating the resource instance.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Patient", - "RelatedPerson", - "Organization", - ], - ) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Kind of Resource", - description=( - "Identifies the 'type' of resource - equivalent to the resource name " - "for other resources." - ), - # if property is element of this resource. - element_property=True, - ) - - created: fhirtypes.Date = Field( - None, - alias="created", - title="When created", - description="Identifies when the resource was first created.", - # if property is element of this resource. - element_property=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier", - description=( - "Identifier assigned to the resource for business purposes, outside the" - " context of FHIR." - ), - # if property is element of this resource. - element_property=True, - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Identifies the focus of this resource", - description=( - "Identifies the patient, practitioner, device or any other resource " - 'that is the "focus" of this resource.' - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Basic`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "code", - "subject", - "created", - "author", - ] diff --git a/fhir/resources/binary.py b/fhir/resources/binary.py deleted file mode 100644 index 66a7ac85..00000000 --- a/fhir/resources/binary.py +++ /dev/null @@ -1,158 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Binary -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import fhirtypes, resource - - -class Binary(resource.Resource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Pure binary content defined by a format other than FHIR. - A resource that represents the data of a single raw artifact as digital - content accessible in its native format. A Binary resource can contain any - content, whether text, image, pdf, zip archive, etc. - """ - - resource_type = Field("Binary", const=True) - - contentType: fhirtypes.Code = Field( - None, - alias="contentType", - title="MimeType of the binary content", - description=( - "MimeType of the binary content represented as a standard MimeType (BCP" - " 13)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - contentType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_contentType", title="Extension field for ``contentType``." - ) - - data: fhirtypes.Base64Binary = Field( - None, - alias="data", - title="The actual content", - description="The actual content, base64 encoded.", - # if property is element of this resource. - element_property=True, - ) - data__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_data", title="Extension field for ``data``." - ) - - securityContext: fhirtypes.ReferenceType = Field( - None, - alias="securityContext", - title=( - "Identifies another resource to use as proxy when enforcing access " - "control" - ), - description=( - "This element identifies another resource that can be used as a proxy " - "of the security sensitivity to use when deciding and enforcing access " - "control rules for the Binary resource. Given that the Binary resource " - "contains very few elements that can be used to determine the " - "sensitivity of the data and relationships to individuals, the " - "referenced resource stands in as a proxy equivalent for this purpose. " - "This referenced resource may be related to the Binary (e.g. Media, " - "DocumentReference), or may be some non-related Resource purely as a " - "security proxy. E.g. to identify that the binary resource relates to a" - " patient, and access should only be granted to applications that have " - "access to the patient." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Binary`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "contentType", - "securityContext", - "data", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_800( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("contentType", "contentType__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/biologicallyderivedproduct.py b/fhir/resources/biologicallyderivedproduct.py deleted file mode 100644 index 84c5aa00..00000000 --- a/fhir/resources/biologicallyderivedproduct.py +++ /dev/null @@ -1,618 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/BiologicallyDerivedProduct -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class BiologicallyDerivedProduct(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A material substance originating from a biological entity. - A material substance originating from a biological entity intended to be - transplanted or infused - into another (possibly the same) biological entity. - """ - - resource_type = Field("BiologicallyDerivedProduct", const=True) - - collection: fhirtypes.BiologicallyDerivedProductCollectionType = Field( - None, - alias="collection", - title="How this product was collected", - description=None, - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External ids for this item", - description=( - "This records identifiers associated with this biologically derived " - "product instance that are defined by business processes and/or used to" - " refer to it when a direct URL reference to the resource itself is not" - " appropriate (e.g. in CDA documents, or in written / printed " - "documentation)." - ), - # if property is element of this resource. - element_property=True, - ) - - manipulation: fhirtypes.BiologicallyDerivedProductManipulationType = Field( - None, - alias="manipulation", - title="Any manipulation of product post-collection", - description=( - "Any manipulation of product post-collection that is intended to alter " - "the product. For example a buffy-coat enrichment or CD8 reduction of " - "Peripheral Blood Stem Cells to make it more suitable for infusion." - ), - # if property is element of this resource. - element_property=True, - ) - - parent: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="parent", - title="BiologicallyDerivedProduct parent", - description="Parent product (if any).", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["BiologicallyDerivedProduct"], - ) - - processing: typing.List[fhirtypes.BiologicallyDerivedProductProcessingType] = Field( - None, - alias="processing", - title="Any processing of the product during collection", - description=( - "Any processing of the product during collection that does not change " - "the fundamental nature of the product. For example adding anti-" - "coagulants during the collection of Peripheral Blood Stem Cells." - ), - # if property is element of this resource. - element_property=True, - ) - - productCategory: fhirtypes.Code = Field( - None, - alias="productCategory", - title="organ | tissue | fluid | cells | biologicalAgent", - description="Broad category of this product.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["organ", "tissue", "fluid", "cells", "biologicalAgent"], - ) - productCategory__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_productCategory", title="Extension field for ``productCategory``." - ) - - productCode: fhirtypes.CodeableConceptType = Field( - None, - alias="productCode", - title="What this biologically derived product is", - description=( - "A code that identifies the kind of this biologically derived product " - "(SNOMED Ctcode)." - ), - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.Integer = Field( - None, - alias="quantity", - title="The amount of this biologically derived product", - description="Number of discrete units within this product.", - # if property is element of this resource. - element_property=True, - ) - quantity__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_quantity", title="Extension field for ``quantity``." - ) - - request: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="request", - title="Procedure request", - description="Procedure request to obtain this biologically derived product.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ServiceRequest"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="available | unavailable", - description="Whether the product is currently available.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["available", "unavailable"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - storage: typing.List[fhirtypes.BiologicallyDerivedProductStorageType] = Field( - None, - alias="storage", - title="Product storage", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BiologicallyDerivedProduct`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "productCategory", - "productCode", - "status", - "request", - "quantity", - "parent", - "collection", - "processing", - "manipulation", - "storage", - ] - - -class BiologicallyDerivedProductCollection(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - How this product was collected. - """ - - resource_type = Field("BiologicallyDerivedProductCollection", const=True) - - collectedDateTime: fhirtypes.DateTime = Field( - None, - alias="collectedDateTime", - title="Time of product collection", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e collected[x] - one_of_many="collected", - one_of_many_required=False, - ) - collectedDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_collectedDateTime", - title="Extension field for ``collectedDateTime``.", - ) - - collectedPeriod: fhirtypes.PeriodType = Field( - None, - alias="collectedPeriod", - title="Time of product collection", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e collected[x] - one_of_many="collected", - one_of_many_required=False, - ) - - collector: fhirtypes.ReferenceType = Field( - None, - alias="collector", - title="Individual performing collection", - description="Healthcare professional who is performing the collection.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - source: fhirtypes.ReferenceType = Field( - None, - alias="source", - title="Who is product from", - description=( - "The patient or entity, such as a hospital or vendor in the case of a " - "processed/manipulated/manufactured product, providing the product." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Organization"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BiologicallyDerivedProductCollection`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "collector", - "source", - "collectedDateTime", - "collectedPeriod", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3898( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"collected": ["collectedDateTime", "collectedPeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class BiologicallyDerivedProductManipulation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Any manipulation of product post-collection. - Any manipulation of product post-collection that is intended to alter the - product. For example a buffy-coat enrichment or CD8 reduction of - Peripheral Blood Stem Cells to make it more suitable for infusion. - """ - - resource_type = Field("BiologicallyDerivedProductManipulation", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Description of manipulation", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - timeDateTime: fhirtypes.DateTime = Field( - None, - alias="timeDateTime", - title="Time of manipulation", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e time[x] - one_of_many="time", - one_of_many_required=False, - ) - timeDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timeDateTime", title="Extension field for ``timeDateTime``." - ) - - timePeriod: fhirtypes.PeriodType = Field( - None, - alias="timePeriod", - title="Time of manipulation", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e time[x] - one_of_many="time", - one_of_many_required=False, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BiologicallyDerivedProductManipulation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "timeDateTime", - "timePeriod", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4127( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"time": ["timeDateTime", "timePeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class BiologicallyDerivedProductProcessing(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Any processing of the product during collection. - Any processing of the product during collection that does not change the - fundamental nature of the product. For example adding anti-coagulants - during the collection of Peripheral Blood Stem Cells. - """ - - resource_type = Field("BiologicallyDerivedProductProcessing", const=True) - - additive: fhirtypes.ReferenceType = Field( - None, - alias="additive", - title="Substance added during processing", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Substance"], - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Description of of processing", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - procedure: fhirtypes.CodeableConceptType = Field( - None, - alias="procedure", - title="Procesing code", - description=None, - # if property is element of this resource. - element_property=True, - ) - - timeDateTime: fhirtypes.DateTime = Field( - None, - alias="timeDateTime", - title="Time of processing", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e time[x] - one_of_many="time", - one_of_many_required=False, - ) - timeDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timeDateTime", title="Extension field for ``timeDateTime``." - ) - - timePeriod: fhirtypes.PeriodType = Field( - None, - alias="timePeriod", - title="Time of processing", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e time[x] - one_of_many="time", - one_of_many_required=False, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BiologicallyDerivedProductProcessing`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "procedure", - "additive", - "timeDateTime", - "timePeriod", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3908( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"time": ["timeDateTime", "timePeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class BiologicallyDerivedProductStorage(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Product storage. - """ - - resource_type = Field("BiologicallyDerivedProductStorage", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Description of storage", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - duration: fhirtypes.PeriodType = Field( - None, - alias="duration", - title="Storage timeperiod", - description=None, - # if property is element of this resource. - element_property=True, - ) - - scale: fhirtypes.Code = Field( - None, - alias="scale", - title="farenheit | celsius | kelvin", - description="Temperature scale used.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["farenheit", "celsius", "kelvin"], - ) - scale__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_scale", title="Extension field for ``scale``." - ) - - temperature: fhirtypes.Decimal = Field( - None, - alias="temperature", - title="Storage temperature", - description=None, - # if property is element of this resource. - element_property=True, - ) - temperature__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_temperature", title="Extension field for ``temperature``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BiologicallyDerivedProductStorage`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "temperature", - "scale", - "duration", - ] diff --git a/fhir/resources/bodystructure.py b/fhir/resources/bodystructure.py deleted file mode 100644 index c5cc6763..00000000 --- a/fhir/resources/bodystructure.py +++ /dev/null @@ -1,142 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/BodyStructure -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import domainresource, fhirtypes - - -class BodyStructure(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Specific and identified anatomical structure. - Record details about an anatomical structure. This resource may be used - when a coded concept does not provide the necessary detail needed for the - use case. - """ - - resource_type = Field("BodyStructure", const=True) - - active: bool = Field( - None, - alias="active", - title="Whether this record is in active use", - description="Whether this body site is in active use.", - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Text description", - description="A summary, characterization or explanation of the body structure.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Bodystructure identifier", - description="Identifier for this instance of the anatomical structure.", - # if property is element of this resource. - element_property=True, - ) - - image: typing.List[fhirtypes.AttachmentType] = Field( - None, - alias="image", - title="Attached images", - description="Image or images used to identify a location.", - # if property is element of this resource. - element_property=True, - ) - - location: fhirtypes.CodeableConceptType = Field( - None, - alias="location", - title="Body site", - description=( - "The anatomical location or region of the specimen, lesion, or body " - "structure." - ), - # if property is element of this resource. - element_property=True, - ) - - locationQualifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="locationQualifier", - title="Body site modifier", - description=( - "Qualifier to refine the anatomical location. These include qualifiers" - " for laterality, relative location, directionality, number, and plane." - ), - # if property is element of this resource. - element_property=True, - ) - - morphology: fhirtypes.CodeableConceptType = Field( - None, - alias="morphology", - title="Kind of Structure", - description=( - "The kind of structure being represented by the body structure at " - "`BodyStructure.location`. This can define both normal and abnormal " - "morphologies." - ), - # if property is element of this resource. - element_property=True, - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="Who this is about", - description="The person to which the body site belongs.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BodyStructure`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "active", - "morphology", - "location", - "locationQualifier", - "description", - "image", - "patient", - ] diff --git a/fhir/resources/bundle.py b/fhir/resources/bundle.py deleted file mode 100644 index fc81f4cd..00000000 --- a/fhir/resources/bundle.py +++ /dev/null @@ -1,839 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Bundle -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, fhirtypes, resource - - -class Bundle(resource.Resource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contains a collection of resources. - A container for a collection of resources. - """ - - resource_type = Field("Bundle", const=True) - - entry: typing.List[fhirtypes.BundleEntryType] = Field( - None, - alias="entry", - title="Entry in the bundle - will have a resource or information", - description=( - "An entry in a bundle resource - will either contain a resource or " - "information about a resource (transactions and history only)." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Persistent identifier for the bundle", - description=( - "A persistent identifier for the bundle that won't change as a bundle " - "is copied from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - link: typing.List[fhirtypes.BundleLinkType] = Field( - None, - alias="link", - title="Links related to this Bundle", - description="A series of links that provide context to this bundle.", - # if property is element of this resource. - element_property=True, - ) - - signature: fhirtypes.SignatureType = Field( - None, - alias="signature", - title="Digital Signature", - description="Digital Signature - base64 encoded. XML-DSig or a JWT.", - # if property is element of this resource. - element_property=True, - ) - - timestamp: fhirtypes.Instant = Field( - None, - alias="timestamp", - title="When the bundle was assembled", - description=( - "The date/time that the bundle was assembled - i.e. when the resources " - "were placed in the bundle." - ), - # if property is element of this resource. - element_property=True, - ) - timestamp__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timestamp", title="Extension field for ``timestamp``." - ) - - total: fhirtypes.UnsignedInt = Field( - None, - alias="total", - title="If search, the total number of matches", - description=( - "If a set of search matches, this is the total number of entries of " - "type 'match' across all pages in the search. It does not include " - "search.mode = 'include' or 'outcome' entries and it does not provide a" - " count of the number of entries in the Bundle." - ), - # if property is element of this resource. - element_property=True, - ) - total__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_total", title="Extension field for ``total``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title=( - "document | message | transaction | transaction-response | batch | " - "batch-response | history | searchset | collection" - ), - description="Indicates the purpose of this bundle - how it is intended to be used.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "document", - "message", - "transaction", - "transaction-response", - "batch", - "batch-response", - "history", - "searchset", - "collection", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Bundle`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "identifier", - "type", - "timestamp", - "total", - "link", - "entry", - "signature", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_769( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class BundleEntry(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Entry in the bundle - will have a resource or information. - An entry in a bundle resource - will either contain a resource or - information about a resource (transactions and history only). - """ - - resource_type = Field("BundleEntry", const=True) - - fullUrl: fhirtypes.Uri = Field( - None, - alias="fullUrl", - title="URI for resource (Absolute URL server address or URI for UUID/OID)", - description=( - "The Absolute URL for the resource. The fullUrl SHALL NOT disagree " - "with the id in the resource - i.e. if the fullUrl is not a urn:uuid, " - "the URL shall be version-independent URL consistent with the " - "Resource.id. The fullUrl is a version independent reference to the " - "resource. The fullUrl element SHALL have a value except that: * " - "fullUrl can be empty on a POST (although it does not need to when " - "specifying a temporary id for reference in the bundle) * Results from " - "operations might involve resources that are not identified." - ), - # if property is element of this resource. - element_property=True, - ) - fullUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fullUrl", title="Extension field for ``fullUrl``." - ) - - link: typing.List[fhirtypes.BundleLinkType] = Field( - None, - alias="link", - title="Links related to this entry", - description="A series of links that provide context to this entry.", - # if property is element of this resource. - element_property=True, - ) - - request: fhirtypes.BundleEntryRequestType = Field( - None, - alias="request", - title="Additional execution information (transaction/batch/history)", - description=( - "Additional information about how this entry should be processed as " - "part of a transaction or batch. For history, it shows how the entry " - "was processed to create the version contained in the entry." - ), - # if property is element of this resource. - element_property=True, - ) - - resource: fhirtypes.ResourceType = Field( - None, - alias="resource", - title="A resource in the bundle", - description=( - "The Resource for the entry. The purpose/meaning of the resource is " - "determined by the Bundle.type." - ), - # if property is element of this resource. - element_property=True, - ) - - response: fhirtypes.BundleEntryResponseType = Field( - None, - alias="response", - title="Results of execution (transaction/batch/history)", - description=( - "Indicates the results of processing the corresponding 'request' entry " - "in the batch or transaction being responded to or what the results of " - "an operation where when returning history." - ), - # if property is element of this resource. - element_property=True, - ) - - search: fhirtypes.BundleEntrySearchType = Field( - None, - alias="search", - title="Search related information", - description=( - "Information about the search process that lead to the creation of this" - " entry." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BundleEntry`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "link", - "fullUrl", - "resource", - "search", - "request", - "response", - ] - - -class BundleEntryRequest(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Additional execution information (transaction/batch/history). - Additional information about how this entry should be processed as part of - a transaction or batch. For history, it shows how the entry was processed - to create the version contained in the entry. - """ - - resource_type = Field("BundleEntryRequest", const=True) - - ifMatch: fhirtypes.String = Field( - None, - alias="ifMatch", - title="For managing update contention", - description=( - "Only perform the operation if the Etag value matches. For more " - 'information, see the API section ["Managing Resource ' - 'Contention"](http.html#concurrency).' - ), - # if property is element of this resource. - element_property=True, - ) - ifMatch__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_ifMatch", title="Extension field for ``ifMatch``." - ) - - ifModifiedSince: fhirtypes.Instant = Field( - None, - alias="ifModifiedSince", - title="For managing cache currency", - description=( - "Only perform the operation if the last updated date matches. See the " - 'API documentation for ["Conditional Read"](http.html#cread).' - ), - # if property is element of this resource. - element_property=True, - ) - ifModifiedSince__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_ifModifiedSince", title="Extension field for ``ifModifiedSince``." - ) - - ifNoneExist: fhirtypes.String = Field( - None, - alias="ifNoneExist", - title="For conditional creates", - description=( - "Instruct the server not to perform the create if a specified resource " - "already exists. For further information, see the API documentation for" - ' ["Conditional Create"](http.html#ccreate). This is just the query ' - 'portion of the URL - what follows the "?" (not including the "?").' - ), - # if property is element of this resource. - element_property=True, - ) - ifNoneExist__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_ifNoneExist", title="Extension field for ``ifNoneExist``." - ) - - ifNoneMatch: fhirtypes.String = Field( - None, - alias="ifNoneMatch", - title="For managing cache currency", - description=( - "If the ETag values match, return a 304 Not Modified status. See the " - 'API documentation for ["Conditional Read"](http.html#cread).' - ), - # if property is element of this resource. - element_property=True, - ) - ifNoneMatch__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_ifNoneMatch", title="Extension field for ``ifNoneMatch``." - ) - - method: fhirtypes.Code = Field( - None, - alias="method", - title="GET | HEAD | POST | PUT | DELETE | PATCH", - description=( - "In a transaction or batch, this is the HTTP action to be executed for " - "this entry. In a history bundle, this indicates the HTTP action that " - "occurred." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["GET", "HEAD", "POST", "PUT", "DELETE", "PATCH"], - ) - method__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_method", title="Extension field for ``method``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title="URL for HTTP equivalent of this entry", - description=( - "The URL for this entry, relative to the root (the address to which the" - " request is posted)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BundleEntryRequest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "method", - "url", - "ifNoneMatch", - "ifModifiedSince", - "ifMatch", - "ifNoneExist", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2059( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("method", "method__ext"), ("url", "url__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class BundleEntryResponse(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Results of execution (transaction/batch/history). - Indicates the results of processing the corresponding 'request' entry in - the batch or transaction being responded to or what the results of an - operation where when returning history. - """ - - resource_type = Field("BundleEntryResponse", const=True) - - etag: fhirtypes.String = Field( - None, - alias="etag", - title="The Etag for the resource (if relevant)", - description=( - "The Etag for the resource, if the operation for the entry produced a " - "versioned resource (see [Resource Metadata and " - "Versioning](http.html#versioning) and [Managing Resource " - "Contention](http.html#concurrency))." - ), - # if property is element of this resource. - element_property=True, - ) - etag__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_etag", title="Extension field for ``etag``." - ) - - lastModified: fhirtypes.Instant = Field( - None, - alias="lastModified", - title="Server's date time modified", - description="The date/time that the resource was modified on the server.", - # if property is element of this resource. - element_property=True, - ) - lastModified__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastModified", title="Extension field for ``lastModified``." - ) - - location: fhirtypes.Uri = Field( - None, - alias="location", - title="The location (if the operation returns a location)", - description=( - "The location header created by processing this operation, populated if" - " the operation returns a location." - ), - # if property is element of this resource. - element_property=True, - ) - location__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_location", title="Extension field for ``location``." - ) - - outcome: fhirtypes.ResourceType = Field( - None, - alias="outcome", - title="OperationOutcome with hints and warnings (for batch/transaction)", - description=( - "An OperationOutcome containing hints and warnings produced as part of " - "processing this entry in a batch or transaction." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.String = Field( - None, - alias="status", - title="Status response code (text optional)", - description=( - "The status code returned by processing this entry. The status SHALL " - "start with a 3 digit HTTP code (e.g. 404) and may contain the standard" - " HTTP description associated with the status code." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BundleEntryResponse`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "status", - "location", - "etag", - "lastModified", - "outcome", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2146( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class BundleEntrySearch(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Search related information. - Information about the search process that lead to the creation of this - entry. - """ - - resource_type = Field("BundleEntrySearch", const=True) - - mode: fhirtypes.Code = Field( - None, - alias="mode", - title="match | include | outcome - why this is in the result set", - description=( - "Why this entry is in the result set - whether it's included as a match" - " or because of an _include requirement, or to convey information or " - "warning information about the search process." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["match", "include", "outcome"], - ) - mode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mode", title="Extension field for ``mode``." - ) - - score: fhirtypes.Decimal = Field( - None, - alias="score", - title="Search ranking (between 0 and 1)", - description="When searching, the server's search ranking score for the entry.", - # if property is element of this resource. - element_property=True, - ) - score__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_score", title="Extension field for ``score``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BundleEntrySearch`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "mode", "score"] - - -class BundleLink(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Links related to this Bundle. - A series of links that provide context to this bundle. - """ - - resource_type = Field("BundleLink", const=True) - - relation: fhirtypes.String = Field( - None, - alias="relation", - title=( - "See http://www.iana.org/assignments/link-relations/link-" - "relations.xhtml#link-relations-1" - ), - description=( - "A name which details the functional use for this link - see " - "[http://www.iana.org/assignments/link-relations/link-" - "relations.xhtml#link-" - "relations-1](http://www.iana.org/assignments/link-relations/link-" - "relations.xhtml#link-relations-1)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - relation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_relation", title="Extension field for ``relation``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title="Reference details for the link", - description="The reference details for the link.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``BundleLink`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "relation", "url"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1173( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("relation", "relation__ext"), ("url", "url__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/capabilitystatement.py b/fhir/resources/capabilitystatement.py deleted file mode 100644 index 1bc9af34..00000000 --- a/fhir/resources/capabilitystatement.py +++ /dev/null @@ -1,2469 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CapabilityStatement -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class CapabilityStatement(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A statement of system capabilities. - A Capability Statement documents a set of capabilities (behaviors) of a - FHIR Server for a particular version of FHIR that may be used as a - statement of actual server functionality or a statement of required or - desired server implementation. - """ - - resource_type = Field("CapabilityStatement", const=True) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the capability statement and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the capability statement." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the capability statement was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the capability statement " - "changes." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the capability statement", - description=( - "A free text natural language description of the capability statement " - "from a consumer's perspective. Typically, this is used when the " - "capability statement describes a desired rather than an actual " - "solution, for example as a formal expression of requirements as part " - "of an RFP." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - document: typing.List[fhirtypes.CapabilityStatementDocumentType] = Field( - None, - alias="document", - title="Document definition", - description="A document definition.", - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this capability statement is authored" - " for testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - fhirVersion: fhirtypes.Code = Field( - None, - alias="fhirVersion", - title="FHIR Version the system supports", - description=( - "The version of the FHIR specification that this CapabilityStatement " - "describes (which SHALL be the same as the FHIR version of the " - "CapabilityStatement itself). There is no default value." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - fhirVersion__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fhirVersion", title="Extension field for ``fhirVersion``." - ) - - format: typing.List[fhirtypes.Code] = Field( - None, - alias="format", - title="formats supported (xml | json | ttl | mime type)", - description=( - "A list of the formats supported by this implementation using their " - "content types." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["formats", "json", "ttl", "mime"], - ) - format__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_format", title="Extension field for ``format``.") - - implementation: fhirtypes.CapabilityStatementImplementationType = Field( - None, - alias="implementation", - title="If this describes a specific instance", - description=( - "Identifies a specific implementation instance that is described by the" - " capability statement - i.e. a particular installation, rather than " - "the capabilities of a software program." - ), - # if property is element of this resource. - element_property=True, - ) - - implementationGuide: typing.List[fhirtypes.Canonical] = Field( - None, - alias="implementationGuide", - title="Implementation guides supported", - description=( - "A list of implementation guides that the server does (or should) " - "support in their entirety." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ImplementationGuide"], - ) - implementationGuide__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_implementationGuide", - title="Extension field for ``implementationGuide``.", - ) - - imports: typing.List[fhirtypes.Canonical] = Field( - None, - alias="imports", - title="Canonical URL of another capability statement this adds to", - description=( - "Reference to a canonical URL of another CapabilityStatement that this " - "software adds to. The capability statement automatically includes " - "everything in the other statement, and it is not duplicated, though " - "the server may repeat the same resources, interactions and operations " - "to add additional details to them." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CapabilityStatement"], - ) - imports__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_imports", title="Extension field for ``imports``.") - - instantiates: typing.List[fhirtypes.Canonical] = Field( - None, - alias="instantiates", - title="Canonical URL of another capability statement this implements", - description=( - "Reference to a canonical URL of another CapabilityStatement that this " - "software implements. This capability statement is a published API " - "description that corresponds to a business service. The server may " - "actually implement a subset of the capability statement it claims to " - "implement, so the capability statement must specify the full " - "capability details." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CapabilityStatement"], - ) - instantiates__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiates", title="Extension field for ``instantiates``." - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for capability statement (if applicable)", - description=( - "A legal or geographic region in which the capability statement is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - kind: fhirtypes.Code = Field( - None, - alias="kind", - title="instance | capability | requirements", - description=( - "The way that this statement is intended to be used, to describe an " - "actual running instance of software, a particular product (kind, not " - "instance of software) or a class of implementation (e.g. a desired " - "purchase)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["instance", "capability", "requirements"], - ) - kind__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_kind", title="Extension field for ``kind``." - ) - - messaging: typing.List[fhirtypes.CapabilityStatementMessagingType] = Field( - None, - alias="messaging", - title="If messaging is supported", - description="A description of the messaging capabilities of the solution.", - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this capability statement (computer friendly)", - description=( - "A natural language name identifying the capability statement. This " - "name should be usable as an identifier for the module by machine " - "processing applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - patchFormat: typing.List[fhirtypes.Code] = Field( - None, - alias="patchFormat", - title="Patch formats supported", - description=( - "A list of the patch formats supported by this implementation using " - "their content types." - ), - # if property is element of this resource. - element_property=True, - ) - patchFormat__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_patchFormat", title="Extension field for ``patchFormat``.") - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the " - "capability statement." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this capability statement is defined", - description=( - "Explanation of why this capability statement is needed and why it has " - "been designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - rest: typing.List[fhirtypes.CapabilityStatementRestType] = Field( - None, - alias="rest", - title="If the endpoint is a RESTful one", - description="A definition of the restful capabilities of the solution, if any.", - # if property is element of this resource. - element_property=True, - ) - - software: fhirtypes.CapabilityStatementSoftwareType = Field( - None, - alias="software", - title="Software that is covered by this capability statement", - description=( - "Software that is covered by this capability statement. It is used " - "when the capability statement describes the capabilities of a " - "particular software version, independent of an installation." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this capability statement. Enables tracking the life-" - "cycle of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this capability statement (human friendly)", - description=( - "A short, descriptive, user-friendly title for the capability " "statement." - ), - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this capability statement, represented as a " - "URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this capability statement " - "when it is referenced in a specification, model, design or an " - "instance; also called its canonical identifier. This SHOULD be " - "globally unique and SHOULD be a literal address at which at which an " - "authoritative instance of this capability statement is (or will be) " - "published. This URL can be the target of a canonical reference. It " - "SHALL remain the same when the capability statement is stored on " - "different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate capability statement instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the capability statement", - description=( - "The identifier that is used to identify this version of the capability" - " statement when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the capability " - "statement author and is not expected to be globally unique. For " - "example, it might be a timestamp (e.g. yyyymmdd) if a managed version " - "is not available. There is also no expectation that versions can be " - "placed in a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatement`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "version", - "name", - "title", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "copyright", - "kind", - "instantiates", - "imports", - "software", - "implementation", - "fhirVersion", - "format", - "patchFormat", - "implementationGuide", - "rest", - "messaging", - "document", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2158( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("date", "date__ext"), - ("fhirVersion", "fhirVersion__ext"), - ("format", "format__ext"), - ("kind", "kind__ext"), - ("status", "status__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CapabilityStatementDocument(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Document definition. - A document definition. - """ - - resource_type = Field("CapabilityStatementDocument", const=True) - - documentation: fhirtypes.Markdown = Field( - None, - alias="documentation", - title="Description of document support", - description=( - "A description of how the application supports or uses the specified " - "document profile. For example, when documents are created, what " - "action is taken with consumed documents, etc." - ), - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - mode: fhirtypes.Code = Field( - None, - alias="mode", - title="producer | consumer", - description=( - "Mode of this document declaration - whether an application is a " - "producer or consumer." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["producer", "consumer"], - ) - mode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mode", title="Extension field for ``mode``." - ) - - profile: fhirtypes.Canonical = Field( - None, - alias="profile", - title="Constraint on the resources used in the document", - description=( - "A profile on the document Bundle that constrains which resources are " - "present, and their contents." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - profile__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_profile", title="Extension field for ``profile``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementDocument`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "mode", - "documentation", - "profile", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2989( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("mode", "mode__ext"), ("profile", "profile__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CapabilityStatementImplementation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - If this describes a specific instance. - Identifies a specific implementation instance that is described by the - capability statement - i.e. a particular installation, rather than the - capabilities of a software program. - """ - - resource_type = Field("CapabilityStatementImplementation", const=True) - - custodian: fhirtypes.ReferenceType = Field( - None, - alias="custodian", - title="Organization that manages the data", - description=( - "The organization responsible for the management of the instance and " - "oversight of the data on the server at the specified URL." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Describes this specific instance", - description=( - "Information about the specific installation that this capability " - "statement relates to." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - url: fhirtypes.Url = Field( - None, - alias="url", - title="Base URL for the installation", - description=( - "An absolute base URL for the implementation. This forms the base for " - "REST interfaces as well as the mailbox and document interfaces." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementImplementation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "url", - "custodian", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3630( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("description", "description__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CapabilityStatementMessaging(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - If messaging is supported. - A description of the messaging capabilities of the solution. - """ - - resource_type = Field("CapabilityStatementMessaging", const=True) - - documentation: fhirtypes.Markdown = Field( - None, - alias="documentation", - title="Messaging interface behavior details", - description=( - "Documentation about the system's messaging capabilities for this " - "endpoint not otherwise documented by the capability statement. For " - "example, the process for becoming an authorized messaging exchange " - "partner." - ), - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - endpoint: typing.List[fhirtypes.CapabilityStatementMessagingEndpointType] = Field( - None, - alias="endpoint", - title="Where messages should be sent", - description=( - "An endpoint (network accessible address) to which messages and/or " - "replies are to be sent." - ), - # if property is element of this resource. - element_property=True, - ) - - reliableCache: fhirtypes.UnsignedInt = Field( - None, - alias="reliableCache", - title="Reliable Message Cache Length (min)", - description=( - "Length if the receiver's reliable messaging cache in minutes (if a " - "receiver) or how long the cache length on the receiver should be (if a" - " sender)." - ), - # if property is element of this resource. - element_property=True, - ) - reliableCache__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_reliableCache", title="Extension field for ``reliableCache``." - ) - - supportedMessage: typing.List[ - fhirtypes.CapabilityStatementMessagingSupportedMessageType - ] = Field( - None, - alias="supportedMessage", - title="Messages supported by this system", - description=( - "References to message definitions for messages this system can send or" - " receive." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementMessaging`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "endpoint", - "reliableCache", - "documentation", - "supportedMessage", - ] - - -class CapabilityStatementMessagingEndpoint(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Where messages should be sent. - An endpoint (network accessible address) to which messages and/or replies - are to be sent. - """ - - resource_type = Field("CapabilityStatementMessagingEndpoint", const=True) - - address: fhirtypes.Url = Field( - None, - alias="address", - title="Network address or identifier of the end-point", - description=( - "The network address of the endpoint. For solutions that do not use " - "network addresses for routing, it can be just an identifier." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - address__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_address", title="Extension field for ``address``." - ) - - protocol: fhirtypes.CodingType = Field( - ..., - alias="protocol", - title="http | ftp | mllp +", - description=( - "A list of the messaging transport protocol(s) identifiers, supported " - "by this endpoint." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementMessagingEndpoint`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "protocol", "address"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3917( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("address", "address__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CapabilityStatementMessagingSupportedMessage(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Messages supported by this system. - References to message definitions for messages this system can send or - receive. - """ - - resource_type = Field("CapabilityStatementMessagingSupportedMessage", const=True) - - definition: fhirtypes.Canonical = Field( - None, - alias="definition", - title="Message supported by this system", - description=( - "Points to a message definition that identifies the messaging event, " - "message structure, allowed responses, etc." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MessageDefinition"], - ) - definition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_definition", title="Extension field for ``definition``." - ) - - mode: fhirtypes.Code = Field( - None, - alias="mode", - title="sender | receiver", - description=( - "The mode of this event declaration - whether application is sender or " - "receiver." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["sender", "receiver"], - ) - mode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mode", title="Extension field for ``mode``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementMessagingSupportedMessage`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "mode", "definition"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4744( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("definition", "definition__ext"), ("mode", "mode__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CapabilityStatementRest(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - If the endpoint is a RESTful one. - A definition of the restful capabilities of the solution, if any. - """ - - resource_type = Field("CapabilityStatementRest", const=True) - - compartment: typing.List[fhirtypes.Canonical] = Field( - None, - alias="compartment", - title="Compartments served/used by system", - description=( - "An absolute URI which is a reference to the definition of a " - "compartment that the system supports. The reference is to a " - "CompartmentDefinition resource by its canonical URL ." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CompartmentDefinition"], - ) - compartment__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_compartment", title="Extension field for ``compartment``.") - - documentation: fhirtypes.Markdown = Field( - None, - alias="documentation", - title="General description of implementation", - description=( - "Information about the system's restful capabilities that apply across " - "all applications, such as security." - ), - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - interaction: typing.List[fhirtypes.CapabilityStatementRestInteractionType] = Field( - None, - alias="interaction", - title="What operations are supported?", - description="A specification of restful operations supported by the system.", - # if property is element of this resource. - element_property=True, - ) - - mode: fhirtypes.Code = Field( - None, - alias="mode", - title="client | server", - description=( - "Identifies whether this portion of the statement is describing the " - "ability to initiate or receive restful operations." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["client", "server"], - ) - mode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mode", title="Extension field for ``mode``." - ) - - operation: typing.List[ - fhirtypes.CapabilityStatementRestResourceOperationType - ] = Field( - None, - alias="operation", - title="Definition of a system level operation", - description=( - "Definition of an operation or a named query together with its " - "parameters and their meaning and type." - ), - # if property is element of this resource. - element_property=True, - ) - - resource: typing.List[fhirtypes.CapabilityStatementRestResourceType] = Field( - None, - alias="resource", - title="Resource served on the REST interface", - description=( - "A specification of the restful capabilities of the solution for a " - "specific resource type." - ), - # if property is element of this resource. - element_property=True, - ) - - searchParam: typing.List[ - fhirtypes.CapabilityStatementRestResourceSearchParamType - ] = Field( - None, - alias="searchParam", - title="Search parameters for searching all resources", - description=( - "Search parameters that are supported for searching all resources for " - "implementations to support and/or make use of - either references to " - "ones defined in the specification, or additional ones defined for/by " - "the implementation." - ), - # if property is element of this resource. - element_property=True, - ) - - security: fhirtypes.CapabilityStatementRestSecurityType = Field( - None, - alias="security", - title="Information about security of implementation", - description=( - "Information about security implementation from an interface " - "perspective - what a client needs to know." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementRest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "mode", - "documentation", - "security", - "resource", - "interaction", - "searchParam", - "operation", - "compartment", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2572( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("mode", "mode__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CapabilityStatementRestInteraction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What operations are supported?. - A specification of restful operations supported by the system. - """ - - resource_type = Field("CapabilityStatementRestInteraction", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="transaction | batch | search-system | history-system", - description="A coded identifier of the operation, supported by the system.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["transaction", "batch", "search-system", "history-system"], - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - documentation: fhirtypes.Markdown = Field( - None, - alias="documentation", - title="Anything special about operation behavior", - description=( - "Guidance specific to the implementation of this operation, such as " - "limitations on the kind of transactions allowed, or information about " - "system wide search is implemented." - ), - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementRestInteraction`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "documentation"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3718( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CapabilityStatementRestResource(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Resource served on the REST interface. - A specification of the restful capabilities of the solution for a specific - resource type. - """ - - resource_type = Field("CapabilityStatementRestResource", const=True) - - conditionalCreate: bool = Field( - None, - alias="conditionalCreate", - title="If allows/uses conditional create", - description="A flag that indicates that the server supports conditional create.", - # if property is element of this resource. - element_property=True, - ) - conditionalCreate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_conditionalCreate", - title="Extension field for ``conditionalCreate``.", - ) - - conditionalDelete: fhirtypes.Code = Field( - None, - alias="conditionalDelete", - title=( - "not-supported | single | multiple - how conditional delete is " "supported" - ), - description="A code that indicates how the server supports conditional delete.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["not-supported", "single", "multiple"], - ) - conditionalDelete__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_conditionalDelete", - title="Extension field for ``conditionalDelete``.", - ) - - conditionalRead: fhirtypes.Code = Field( - None, - alias="conditionalRead", - title="not-supported | modified-since | not-match | full-support", - description="A code that indicates how the server supports conditional read.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["not-supported", "modified-since", "not-match", "full-support"], - ) - conditionalRead__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_conditionalRead", title="Extension field for ``conditionalRead``." - ) - - conditionalUpdate: bool = Field( - None, - alias="conditionalUpdate", - title="If allows/uses conditional update", - description="A flag that indicates that the server supports conditional update.", - # if property is element of this resource. - element_property=True, - ) - conditionalUpdate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_conditionalUpdate", - title="Extension field for ``conditionalUpdate``.", - ) - - documentation: fhirtypes.Markdown = Field( - None, - alias="documentation", - title="Additional information about the use of the resource type", - description="Additional information about the resource type used by the system.", - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - interaction: typing.List[ - fhirtypes.CapabilityStatementRestResourceInteractionType - ] = Field( - None, - alias="interaction", - title="What operations are supported?", - description="Identifies a restful operation supported by the solution.", - # if property is element of this resource. - element_property=True, - ) - - operation: typing.List[ - fhirtypes.CapabilityStatementRestResourceOperationType - ] = Field( - None, - alias="operation", - title="Definition of a resource operation", - description=( - "Definition of an operation or a named query together with its " - "parameters and their meaning and type. Consult the definition of the " - "operation for details about how to invoke the operation, and the " - "parameters." - ), - # if property is element of this resource. - element_property=True, - ) - - profile: fhirtypes.Canonical = Field( - None, - alias="profile", - title="Base System profile for all uses of resource", - description=( - "A specification of the profile that describes the solution's overall " - "support for the resource, including any constraints on cardinality, " - "bindings, lengths or other limitations. See further discussion in " - "[Using Profiles](profiling.html#profile-uses)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - profile__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_profile", title="Extension field for ``profile``." - ) - - readHistory: bool = Field( - None, - alias="readHistory", - title="Whether vRead can return past versions", - description=( - "A flag for whether the server is able to return past versions as part " - "of the vRead operation." - ), - # if property is element of this resource. - element_property=True, - ) - readHistory__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_readHistory", title="Extension field for ``readHistory``." - ) - - referencePolicy: typing.List[fhirtypes.Code] = Field( - None, - alias="referencePolicy", - title="literal | logical | resolves | enforced | local", - description="A set of flags that defines how references are supported.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["literal", "logical", "resolves", "enforced", "local"], - ) - referencePolicy__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_referencePolicy", title="Extension field for ``referencePolicy``." - ) - - searchInclude: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="searchInclude", - title="_include values supported by the server", - description="A list of _include values supported by the server.", - # if property is element of this resource. - element_property=True, - ) - searchInclude__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_searchInclude", title="Extension field for ``searchInclude``." - ) - - searchParam: typing.List[ - fhirtypes.CapabilityStatementRestResourceSearchParamType - ] = Field( - None, - alias="searchParam", - title="Search parameters supported by implementation", - description=( - "Search parameters for implementations to support and/or make use of - " - "either references to ones defined in the specification, or additional " - "ones defined for/by the implementation." - ), - # if property is element of this resource. - element_property=True, - ) - - searchRevInclude: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="searchRevInclude", - title="_revinclude values supported by the server", - description=( - "A list of _revinclude (reverse include) values supported by the " "server." - ), - # if property is element of this resource. - element_property=True, - ) - searchRevInclude__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_searchRevInclude", - title="Extension field for ``searchRevInclude``.", - ) - - supportedProfile: typing.List[fhirtypes.Canonical] = Field( - None, - alias="supportedProfile", - title="Profiles for use cases supported", - description=( - "A list of profiles that represent different use cases supported by the" - ' system. For a server, "supported by the system" means the system ' - "hosts/produces a set of resources that are conformant to a particular " - "profile, and allows clients that use its services to search using this" - " profile and to find appropriate data. For a client, it means the " - "system will search by this profile and process data according to the " - "guidance implicit in the profile. See further discussion in [Using " - "Profiles](profiling.html#profile-uses)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - supportedProfile__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_supportedProfile", - title="Extension field for ``supportedProfile``.", - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="A resource type that is supported", - description="A type of resource exposed via the restful interface.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - updateCreate: bool = Field( - None, - alias="updateCreate", - title="If update can commit to a new identity", - description=( - "A flag to indicate that the server allows or needs to allow the client" - " to create new identities on the server (that is, the client PUTs to a" - " location where there is no existing resource). Allowing this " - "operation means that the server allows the client to create new " - "identities on the server." - ), - # if property is element of this resource. - element_property=True, - ) - updateCreate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_updateCreate", title="Extension field for ``updateCreate``." - ) - - versioning: fhirtypes.Code = Field( - None, - alias="versioning", - title="no-version | versioned | versioned-update", - description=( - "This field is set to no-version to specify that the system does not " - "support (server) or use (client) versioning for this resource type. If" - " this has some other value, the server must at least correctly track " - "and populate the versionId meta-property on resources. If the value is" - " 'versioned-update', then the server supports all the versioning " - "features, including using e-tags for version integrity in the API." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["no-version", "versioned", "versioned-update"], - ) - versioning__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_versioning", title="Extension field for ``versioning``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementRestResource`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "profile", - "supportedProfile", - "documentation", - "interaction", - "versioning", - "readHistory", - "updateCreate", - "conditionalCreate", - "conditionalRead", - "conditionalUpdate", - "conditionalDelete", - "referencePolicy", - "searchInclude", - "searchRevInclude", - "searchParam", - "operation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3397( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CapabilityStatementRestResourceInteraction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What operations are supported?. - Identifies a restful operation supported by the solution. - """ - - resource_type = Field("CapabilityStatementRestResourceInteraction", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title=( - "read | vread | update | patch | delete | history-instance | history-" - "type | create | search-type" - ), - description="Coded identifier of the operation, supported by the system resource.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "read", - "vread", - "update", - "patch", - "delete", - "history-instance", - "history-type", - "create", - "search-type", - ], - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - documentation: fhirtypes.Markdown = Field( - None, - alias="documentation", - title="Anything special about operation behavior", - description=( - "Guidance specific to the implementation of this operation, such as " - "'delete is a logical delete' or 'updates are only allowed with version" - " id' or 'creates permitted from pre-authorized certificates only'." - ), - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementRestResourceInteraction`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "documentation"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4558( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CapabilityStatementRestResourceOperation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Definition of a resource operation. - Definition of an operation or a named query together with its parameters - and their meaning and type. Consult the definition of the operation for - details about how to invoke the operation, and the parameters. - """ - - resource_type = Field("CapabilityStatementRestResourceOperation", const=True) - - definition: fhirtypes.Canonical = Field( - None, - alias="definition", - title="The defined operation/query", - description=( - "Where the formal definition can be found. If a server references the " - "base definition of an Operation (i.e. from the specification itself " - "such as ```http://hl7.org/fhir/OperationDefinition/ValueSet-" - "expand```), that means it supports the full capabilities of the " - "operation - e.g. both GET and POST invocation. If it only supports a " - "subset, it must define its own custom " - "[OperationDefinition](operationdefinition.html#) with a 'base' of the " - "original OperationDefinition. The custom definition would describe " - "the specific subset of functionality supported." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["OperationDefinition"], - ) - definition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_definition", title="Extension field for ``definition``." - ) - - documentation: fhirtypes.Markdown = Field( - None, - alias="documentation", - title="Specific details about operation behavior", - description=( - "Documentation that describes anything special about the operation " - "behavior, possibly detailing different behavior for system, type and " - "instance-level invocation of the operation." - ), - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name by which the operation/query is invoked", - description=( - "The name of the operation or query. For an operation, this is the name" - " prefixed with $ and used in the URL. For a query, this is the name " - "used in the _query parameter when the query is called." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementRestResourceOperation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "definition", - "documentation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4351( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("definition", "definition__ext"), ("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CapabilityStatementRestResourceSearchParam(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Search parameters supported by implementation. - Search parameters for implementations to support and/or make use of - - either references to ones defined in the specification, or additional ones - defined for/by the implementation. - """ - - resource_type = Field("CapabilityStatementRestResourceSearchParam", const=True) - - definition: fhirtypes.Canonical = Field( - None, - alias="definition", - title="Source of definition for parameter", - description=( - "An absolute URI that is a formal reference to where this parameter was" - " first defined, so that a client can be confident of the meaning of " - "the search parameter (a reference to " - "[SearchParameter.url](searchparameter-" - "definitions.html#SearchParameter.url)). This element SHALL be " - "populated if the search parameter refers to a SearchParameter defined " - "by the FHIR core specification or externally defined IGs." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SearchParameter"], - ) - definition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_definition", title="Extension field for ``definition``." - ) - - documentation: fhirtypes.Markdown = Field( - None, - alias="documentation", - title="Server-specific usage", - description=( - "This allows documentation of any distinct behaviors about how the " - "search parameter is used. For example, text matching algorithms." - ), - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name of search parameter", - description="The name of the search parameter used in the interface.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title=( - "number | date | string | token | reference | composite | quantity | " - "uri | special" - ), - description=( - "The type of value a search parameter refers to, and how the content is" - " interpreted." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "number", - "date", - "string", - "token", - "reference", - "composite", - "quantity", - "uri", - "special", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementRestResourceSearchParam`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "definition", - "type", - "documentation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4500( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CapabilityStatementRestSecurity(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about security of implementation. - Information about security implementation from an interface perspective - - what a client needs to know. - """ - - resource_type = Field("CapabilityStatementRestSecurity", const=True) - - cors: bool = Field( - None, - alias="cors", - title="Adds CORS Headers (http://enable-cors.org/)", - description=( - "Server adds CORS headers when responding to requests - this enables " - "Javascript applications to use the server." - ), - # if property is element of this resource. - element_property=True, - ) - cors__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_cors", title="Extension field for ``cors``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="General description of how security works", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - service: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="service", - title="OAuth | SMART-on-FHIR | NTLM | Basic | Kerberos | Certificates", - description="Types of security services that are supported/required by the system.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementRestSecurity`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "cors", - "service", - "description", - ] - - -class CapabilityStatementSoftware(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Software that is covered by this capability statement. - Software that is covered by this capability statement. It is used when the - capability statement describes the capabilities of a particular software - version, independent of an installation. - """ - - resource_type = Field("CapabilityStatementSoftware", const=True) - - name: fhirtypes.String = Field( - None, - alias="name", - title="A name the software is known by", - description="Name the software is known by.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - releaseDate: fhirtypes.DateTime = Field( - None, - alias="releaseDate", - title="Date this version was released", - description="Date this version of the software was released.", - # if property is element of this resource. - element_property=True, - ) - releaseDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_releaseDate", title="Extension field for ``releaseDate``." - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Version covered by this statement", - description="The version identifier for the software covered by this statement.", - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CapabilityStatementSoftware`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "version", - "releaseDate", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2986( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/careplan.py b/fhir/resources/careplan.py deleted file mode 100644 index 5248bf6f..00000000 --- a/fhir/resources/careplan.py +++ /dev/null @@ -1,1090 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CarePlan -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class CarePlan(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Healthcare plan for patient or group. - Describes the intention of how one or more practitioners intend to deliver - care for a particular patient, group or community for a period of time, - possibly limited to care for a specific condition or set of conditions. - """ - - resource_type = Field("CarePlan", const=True) - - activity: typing.List[fhirtypes.CarePlanActivityType] = Field( - None, - alias="activity", - title="Action to occur as part of plan", - description=( - "Identifies a planned action to occur as part of the plan. For " - "example, a medication to be used, lab tests to perform, self-" - "monitoring, education, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - addresses: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="addresses", - title="Health issues this plan addresses", - description=( - "Identifies the conditions/problems/concerns/diagnoses/etc. whose " - "management and/or mitigation are handled by this plan." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition"], - ) - - author: fhirtypes.ReferenceType = Field( - None, - alias="author", - title="Who is the designated responsible party", - description=( - "When populated, the author is responsible for the care plan. The care" - " plan is attributed to the author." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "Device", - "RelatedPerson", - "Organization", - "CareTeam", - ], - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Fulfills CarePlan", - description="A care plan that is fulfilled in whole or in part by this care plan.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CarePlan"], - ) - - careTeam: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="careTeam", - title="Who's involved in plan?", - description=( - "Identifies all people and organizations who are expected to be " - "involved in the care envisioned by this plan." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CareTeam"], - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Type of plan", - description=( - 'Identifies what "kind" of plan this is to support differentiation ' - 'between multiple co-existing plans; e.g. "Home health", "psychiatric",' - ' "asthma", "disease management", "wellness plan", etc.' - ), - # if property is element of this resource. - element_property=True, - ) - - contributor: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="contributor", - title="Who provided the content of the care plan", - description=( - "Identifies the individual(s) or organization who provided the contents" - " of the care plan." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "Device", - "RelatedPerson", - "Organization", - "CareTeam", - ], - ) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="Date record was first recorded", - description=( - "Represents when this particular CarePlan record was created in the " - "system, which is often a system-generated date." - ), - # if property is element of this resource. - element_property=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Summary of nature of plan", - description="A description of the scope and nature of the plan.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter created as part of", - description=( - "The Encounter during which this CarePlan was created or to which the " - "creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - goal: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="goal", - title="Desired outcome of plan", - description="Describes the intended objective(s) of carrying out the care plan.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Goal"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Ids for this plan", - description=( - "Business identifiers assigned to this care plan by the performer or " - "other systems which remain constant as the resource is updated and " - "propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - instantiatesCanonical: typing.List[fhirtypes.Canonical] = Field( - None, - alias="instantiatesCanonical", - title="Instantiates FHIR protocol or definition", - description=( - "The URL pointing to a FHIR-defined protocol, guideline, questionnaire " - "or other definition that is adhered to in whole or in part by this " - "CarePlan." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "PlanDefinition", - "Questionnaire", - "Measure", - "ActivityDefinition", - "OperationDefinition", - ], - ) - instantiatesCanonical__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_instantiatesCanonical", - title="Extension field for ``instantiatesCanonical``.", - ) - - instantiatesUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiatesUri", - title="Instantiates external protocol or definition", - description=( - "The URL pointing to an externally maintained protocol, guideline, " - "questionnaire or other definition that is adhered to in whole or in " - "part by this CarePlan." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - intent: fhirtypes.Code = Field( - None, - alias="intent", - title="proposal | plan | order | option", - description=( - "Indicates the level of authority/intentionality associated with the " - "care plan and where the care plan fits into the workflow chain." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["proposal", "plan", "order", "option"], - ) - intent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_intent", title="Extension field for ``intent``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments about the plan", - description="General notes about the care plan not covered elsewhere.", - # if property is element of this resource. - element_property=True, - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Part of referenced CarePlan", - description=( - "A larger care plan of which this particular care plan is a component " - "or step." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CarePlan"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Time period plan covers", - description=( - "Indicates when the plan did (or is intended to) come into effect and " - "end." - ), - # if property is element of this resource. - element_property=True, - ) - - replaces: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="replaces", - title="CarePlan replaced by this CarePlan", - description=( - "Completed or terminated care plan whose function is taken by this new " - "care plan." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CarePlan"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "draft | active | on-hold | revoked | completed | entered-in-error | " - "unknown" - ), - description=( - "Indicates whether the plan is currently being acted upon, represents " - "future intentions or is now a historical record." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "draft", - "active", - "on-hold", - "revoked", - "completed", - "entered-in-error", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Who the care plan is for", - description=( - "Identifies the patient or group whose intended care is described by " - "the plan." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - supportingInfo: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingInfo", - title="Information considered as part of plan", - description=( - "Identifies portions of the patient's record that specifically " - "influenced the formation of the plan. These might include " - "comorbidities, recent procedures, limitations, recent assessments, " - "etc." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Human-friendly name for the care plan", - description=None, - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CarePlan`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "instantiatesCanonical", - "instantiatesUri", - "basedOn", - "replaces", - "partOf", - "status", - "intent", - "category", - "title", - "description", - "subject", - "encounter", - "period", - "created", - "author", - "contributor", - "careTeam", - "addresses", - "supportingInfo", - "goal", - "activity", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_951( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("intent", "intent__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CarePlanActivity(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Action to occur as part of plan. - Identifies a planned action to occur as part of the plan. For example, a - medication to be used, lab tests to perform, self-monitoring, education, - etc. - """ - - resource_type = Field("CarePlanActivity", const=True) - - detail: fhirtypes.CarePlanActivityDetailType = Field( - None, - alias="detail", - title="In-line definition of activity", - description=( - "A simple summary of a planned activity suitable for a general care " - "plan system (e.g. form driven) that doesn't know about specific " - "resources such as procedure etc." - ), - # if property is element of this resource. - element_property=True, - ) - - outcomeCodeableConcept: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="outcomeCodeableConcept", - title="Results of the activity", - description=( - "Identifies the outcome at the point when the status of the activity is" - " assessed. For example, the outcome of an education activity could be" - " patient understands (or not)." - ), - # if property is element of this resource. - element_property=True, - ) - - outcomeReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="outcomeReference", - title="Appointment, Encounter, Procedure, etc.", - description=( - "Details of the outcome or action resulting from the activity. The " - 'reference to an "event" resource, such as Procedure or Encounter or ' - "Observation, is the result/outcome of the activity itself. The " - "activity can be conveyed using CarePlan.activity.detail OR using the " - "CarePlan.activity.reference (a reference to a \u201crequest\u201d resource)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - progress: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="progress", - title="Comments about the activity status/progress", - description="Notes about the adherence/status/progress of the activity.", - # if property is element of this resource. - element_property=True, - ) - - reference: fhirtypes.ReferenceType = Field( - None, - alias="reference", - title="Activity details defined in specific resource", - description=( - "The details of the proposed activity represented in a specific " - "resource." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Appointment", - "CommunicationRequest", - "DeviceRequest", - "MedicationRequest", - "NutritionOrder", - "Task", - "ServiceRequest", - "VisionPrescription", - "RequestGroup", - ], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CarePlanActivity`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "outcomeCodeableConcept", - "outcomeReference", - "progress", - "reference", - "detail", - ] - - -class CarePlanActivityDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - In-line definition of activity. - A simple summary of a planned activity suitable for a general care plan - system (e.g. form driven) that doesn't know about specific resources such - as procedure etc. - """ - - resource_type = Field("CarePlanActivityDetail", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Detail type of activity", - description=( - "Detailed description of the type of planned activity; e.g. what lab " - "test, what procedure, what kind of encounter." - ), - # if property is element of this resource. - element_property=True, - ) - - dailyAmount: fhirtypes.QuantityType = Field( - None, - alias="dailyAmount", - title="How to consume/day?", - description="Identifies the quantity expected to be consumed in a given day.", - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Extra info describing activity to perform", - description=( - "This provides a textual description of constraints on the intended " - "activity occurrence, including relation to other activities. It may " - "also include objectives, pre-conditions and end-conditions. Finally, " - "it may convey specifics about the activity such as body site, method, " - "route, etc." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - doNotPerform: bool = Field( - None, - alias="doNotPerform", - title="If true, activity is prohibiting action", - description=( - "If true, indicates that the described activity is one that must NOT be" - " engaged in when following the plan. If false, or missing, indicates " - "that the described activity is one that should be engaged in when " - "following the plan." - ), - # if property is element of this resource. - element_property=True, - ) - doNotPerform__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_doNotPerform", title="Extension field for ``doNotPerform``." - ) - - goal: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="goal", - title="Goals this activity relates to", - description=( - "Internal reference that identifies the goals that this activity is " - "intended to contribute towards meeting." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Goal"], - ) - - instantiatesCanonical: typing.List[fhirtypes.Canonical] = Field( - None, - alias="instantiatesCanonical", - title="Instantiates FHIR protocol or definition", - description=( - "The URL pointing to a FHIR-defined protocol, guideline, questionnaire " - "or other definition that is adhered to in whole or in part by this " - "CarePlan activity." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "PlanDefinition", - "ActivityDefinition", - "Questionnaire", - "Measure", - "OperationDefinition", - ], - ) - instantiatesCanonical__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_instantiatesCanonical", - title="Extension field for ``instantiatesCanonical``.", - ) - - instantiatesUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiatesUri", - title="Instantiates external protocol or definition", - description=( - "The URL pointing to an externally maintained protocol, guideline, " - "questionnaire or other definition that is adhered to in whole or in " - "part by this CarePlan activity." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - kind: fhirtypes.Code = Field( - None, - alias="kind", - title=( - "Appointment | CommunicationRequest | DeviceRequest | MedicationRequest" - " | NutritionOrder | Task | ServiceRequest | VisionPrescription" - ), - description=( - "A description of the kind of resource the in-line definition of a care" - " plan activity is representing. The CarePlan.activity.detail is an " - "in-line definition when a resource is not referenced using " - "CarePlan.activity.reference. For example, a MedicationRequest, a " - "ServiceRequest, or a CommunicationRequest." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "Appointment", - "CommunicationRequest", - "DeviceRequest", - "MedicationRequest", - "NutritionOrder", - "Task", - "ServiceRequest", - "VisionPrescription", - ], - ) - kind__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_kind", title="Extension field for ``kind``." - ) - - location: fhirtypes.ReferenceType = Field( - None, - alias="location", - title="Where it should happen", - description=( - "Identifies the facility where the activity will occur; e.g. home, " - "hospital, specific clinic, etc." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - performer: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="performer", - title="Who will be responsible?", - description="Identifies who's expected to be involved in the activity.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "RelatedPerson", - "Patient", - "CareTeam", - "HealthcareService", - "Device", - ], - ) - - productCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="productCodeableConcept", - title="What is to be administered/supplied", - description=( - "Identifies the food, drug or other product to be consumed or supplied " - "in the activity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e product[x] - one_of_many="product", - one_of_many_required=False, - ) - - productReference: fhirtypes.ReferenceType = Field( - None, - alias="productReference", - title="What is to be administered/supplied", - description=( - "Identifies the food, drug or other product to be consumed or supplied " - "in the activity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e product[x] - one_of_many="product", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Medication", "Substance"], - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="How much to administer/supply/consume", - description=( - "Identifies the quantity expected to be supplied, administered or " - "consumed by the subject." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why activity should be done or why activity was prohibited", - description=( - "Provides the rationale that drove the inclusion of this particular " - "activity as part of the plan or the reason why the activity was " - "prohibited." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why activity is needed", - description=( - "Indicates another resource, such as the health condition(s), whose " - "existence justifies this request and drove the inclusion of this " - "particular activity as part of the plan." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "DiagnosticReport", - "DocumentReference", - ], - ) - - scheduledPeriod: fhirtypes.PeriodType = Field( - None, - alias="scheduledPeriod", - title="When activity is to occur", - description=( - "The period, timing or frequency upon which the described activity is " - "to occur." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e scheduled[x] - one_of_many="scheduled", - one_of_many_required=False, - ) - - scheduledString: fhirtypes.String = Field( - None, - alias="scheduledString", - title="When activity is to occur", - description=( - "The period, timing or frequency upon which the described activity is " - "to occur." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e scheduled[x] - one_of_many="scheduled", - one_of_many_required=False, - ) - scheduledString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_scheduledString", title="Extension field for ``scheduledString``." - ) - - scheduledTiming: fhirtypes.TimingType = Field( - None, - alias="scheduledTiming", - title="When activity is to occur", - description=( - "The period, timing or frequency upon which the described activity is " - "to occur." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e scheduled[x] - one_of_many="scheduled", - one_of_many_required=False, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "not-started | scheduled | in-progress | on-hold | completed | " - "cancelled | stopped | unknown | entered-in-error" - ), - description="Identifies what progress is being made for the specific activity.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "not-started", - "scheduled", - "in-progress", - "on-hold", - "completed", - "cancelled", - "stopped", - "unknown", - "entered-in-error", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReason: fhirtypes.CodeableConceptType = Field( - None, - alias="statusReason", - title="Reason for current status", - description=( - "Provides reason why the activity isn't yet started, is on hold, was " - "cancelled, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CarePlanActivityDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "kind", - "instantiatesCanonical", - "instantiatesUri", - "code", - "reasonCode", - "reasonReference", - "goal", - "status", - "statusReason", - "doNotPerform", - "scheduledTiming", - "scheduledPeriod", - "scheduledString", - "location", - "performer", - "productCodeableConcept", - "productReference", - "dailyAmount", - "quantity", - "description", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2389( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2389( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "product": ["productCodeableConcept", "productReference"], - "scheduled": ["scheduledPeriod", "scheduledString", "scheduledTiming"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/careteam.py b/fhir/resources/careteam.py deleted file mode 100644 index 8e7879ca..00000000 --- a/fhir/resources/careteam.py +++ /dev/null @@ -1,303 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CareTeam -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class CareTeam(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Planned participants in the coordination and delivery of care for a patient - or group. - The Care Team includes all the people and organizations who plan to - participate in the coordination and delivery of care for a patient. - """ - - resource_type = Field("CareTeam", const=True) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Type of team", - description=( - "Identifies what kind of team. This is to support differentiation " - "between multiple co-existing teams, such as care plan team, episode of" - " care team, longitudinal care team." - ), - # if property is element of this resource. - element_property=True, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter created as part of", - description=( - "The Encounter during which this CareTeam was created or to which the " - "creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Ids for this team", - description=( - "Business identifiers assigned to this care team by the performer or " - "other systems which remain constant as the resource is updated and " - "propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - managingOrganization: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="managingOrganization", - title="Organization responsible for the care team", - description="The organization responsible for the care team.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name of the team, such as crisis assessment team", - description=( - "A label for human use intended to distinguish like teams. E.g. the " - '"red" vs. "green" trauma teams.' - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments made about the CareTeam", - description=None, - # if property is element of this resource. - element_property=True, - ) - - participant: typing.List[fhirtypes.CareTeamParticipantType] = Field( - None, - alias="participant", - title="Members of the team", - description=( - "Identifies all people and organizations who are expected to be " - "involved in the care team." - ), - # if property is element of this resource. - element_property=True, - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Time period team covers", - description=( - "Indicates when the team did (or is intended to) come into effect and " - "end." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why the care team exists", - description="Describes why the care team exists.", - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why the care team exists", - description="Condition(s) that this care team addresses.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="proposed | active | suspended | inactive | entered-in-error", - description="Indicates the current state of the care team.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["proposed", "active", "suspended", "inactive", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Who care team is for", - description=( - "Identifies the patient or group whose intended care is handled by the " - "team." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="A contact detail for the care team (that applies to all members)", - description=( - "A central contact detail for the care team (that applies to all " - "members)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CareTeam`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "category", - "name", - "subject", - "encounter", - "period", - "participant", - "reasonCode", - "reasonReference", - "managingOrganization", - "telecom", - "note", - ] - - -class CareTeamParticipant(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Members of the team. - Identifies all people and organizations who are expected to be involved in - the care team. - """ - - resource_type = Field("CareTeamParticipant", const=True) - - member: fhirtypes.ReferenceType = Field( - None, - alias="member", - title="Who is involved", - description=( - "The specific person or organization who is participating/expected to " - "participate in the care team." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Patient", - "Organization", - "CareTeam", - ], - ) - - onBehalfOf: fhirtypes.ReferenceType = Field( - None, - alias="onBehalfOf", - title="Organization of the practitioner", - description="The organization of the practitioner.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Time period of participant", - description=( - "Indicates when the specific member or organization did (or is intended" - " to) come into effect and end." - ), - # if property is element of this resource. - element_property=True, - ) - - role: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="role", - title="Type of involvement", - description=( - "Indicates specific responsibility of an individual within the care " - 'team, such as "Primary care physician", "Trained social worker ' - 'counselor", "Caregiver", etc.' - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CareTeamParticipant`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "role", - "member", - "onBehalfOf", - "period", - ] diff --git a/fhir/resources/catalogentry.py b/fhir/resources/catalogentry.py deleted file mode 100644 index ff053b1b..00000000 --- a/fhir/resources/catalogentry.py +++ /dev/null @@ -1,389 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CatalogEntry -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class CatalogEntry(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An entry in a catalog. - Catalog entries are wrappers that contextualize items included in a - catalog. - """ - - resource_type = Field("CatalogEntry", const=True) - - additionalCharacteristic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="additionalCharacteristic", - title="Additional characteristics of the catalog entry", - description="Used for examplefor Out of Formulary, or any specifics.", - # if property is element of this resource. - element_property=True, - ) - - additionalClassification: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="additionalClassification", - title="Additional classification of the catalog entry", - description="User for example for ATC classification, or.", - # if property is element of this resource. - element_property=True, - ) - - additionalIdentifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="additionalIdentifier", - title=( - "Any additional identifier(s) for the catalog item, in the same " - "granularity or concept" - ), - description="Used in supporting related concepts, e.g. NDC to RxNorm.", - # if property is element of this resource. - element_property=True, - ) - - classification: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="classification", - title="Classification (category or class) of the item entry", - description="Classes of devices, or ATC for medication.", - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Unique identifier of the catalog item", - description=( - "Used in supporting different identifiers for the same product, e.g. " - "manufacturer code and retailer code." - ), - # if property is element of this resource. - element_property=True, - ) - - lastUpdated: fhirtypes.DateTime = Field( - None, - alias="lastUpdated", - title="When was this catalog last updated", - description=( - "Typically date of issue is different from the beginning of the " - "validity. This can be used to see when an item was last updated." - ), - # if property is element of this resource. - element_property=True, - ) - lastUpdated__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastUpdated", title="Extension field for ``lastUpdated``." - ) - - orderable: bool = Field( - None, - alias="orderable", - title="Whether the entry represents an orderable item", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - orderable__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_orderable", title="Extension field for ``orderable``." - ) - - referencedItem: fhirtypes.ReferenceType = Field( - ..., - alias="referencedItem", - title="The item that is being defined", - description="The item in a catalog or definition.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Medication", - "Device", - "Organization", - "Practitioner", - "PractitionerRole", - "HealthcareService", - "ActivityDefinition", - "PlanDefinition", - "SpecimenDefinition", - "ObservationDefinition", - "Binary", - ], - ) - - relatedEntry: typing.List[fhirtypes.CatalogEntryRelatedEntryType] = Field( - None, - alias="relatedEntry", - title="An item that this catalog entry is related to", - description=( - "Used for example, to point to a substance, or to a device used to " - "administer a medication." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "Used to support catalog exchange even for unsupported products, e.g. " - "getting list of medications even if not prescribable." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="The type of item - medication, device, service, protocol or other", - description=None, - # if property is element of this resource. - element_property=True, - ) - - validTo: fhirtypes.DateTime = Field( - None, - alias="validTo", - title="The date until which this catalog entry is expected to be active", - description=None, - # if property is element of this resource. - element_property=True, - ) - validTo__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_validTo", title="Extension field for ``validTo``." - ) - - validityPeriod: fhirtypes.PeriodType = Field( - None, - alias="validityPeriod", - title="The time period in which this catalog entry is expected to be active", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CatalogEntry`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "type", - "orderable", - "referencedItem", - "additionalIdentifier", - "classification", - "status", - "validityPeriod", - "validTo", - "lastUpdated", - "additionalCharacteristic", - "additionalClassification", - "relatedEntry", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1417( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("orderable", "orderable__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CatalogEntryRelatedEntry(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An item that this catalog entry is related to. - Used for example, to point to a substance, or to a device used to - administer a medication. - """ - - resource_type = Field("CatalogEntryRelatedEntry", const=True) - - item: fhirtypes.ReferenceType = Field( - ..., - alias="item", - title="The reference to the related item", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CatalogEntry"], - ) - - relationtype: fhirtypes.Code = Field( - None, - alias="relationtype", - title="triggers | is-replaced-by", - description=( - "The type of relation to the related item: child, parent, " - "packageContent, containerPackage, usedIn, uses, requires, etc." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["triggers", "is-replaced-by"], - ) - relationtype__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_relationtype", title="Extension field for ``relationtype``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CatalogEntryRelatedEntry`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "relationtype", "item"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2652( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("relationtype", "relationtype__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/chargeitem.py b/fhir/resources/chargeitem.py deleted file mode 100644 index bb0f5432..00000000 --- a/fhir/resources/chargeitem.py +++ /dev/null @@ -1,633 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ChargeItem -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ChargeItem(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Item containing charge code(s) associated with the provision of healthcare - provider products. - The resource ChargeItem describes the provision of healthcare provider - products for a certain patient, therefore referring not only to the - product, but containing in addition details of the provision, like date, - time, amounts and participating organizations and persons. Main Usage of - the ChargeItem is to enable the billing process and internal cost - allocation. - """ - - resource_type = Field("ChargeItem", const=True) - - account: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="account", - title="Account to place this charge", - description="Account into which this ChargeItems belongs.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Account"], - ) - - bodysite: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="bodysite", - title="Anatomical location, if relevant", - description="The anatomical location where the related service has been applied.", - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="A code that identifies the charge, like a billing code", - description=None, - # if property is element of this resource. - element_property=True, - ) - - context: fhirtypes.ReferenceType = Field( - None, - alias="context", - title="Encounter / Episode associated with event", - description=( - "The encounter or episode of care that establishes the context for this" - " event." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter", "EpisodeOfCare"], - ) - - costCenter: fhirtypes.ReferenceType = Field( - None, - alias="costCenter", - title="Organization that has ownership of the (potential, future) revenue", - description="The financial cost center permits the tracking of charge attribution.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - definitionCanonical: typing.List[fhirtypes.Canonical] = Field( - None, - alias="definitionCanonical", - title="Resource defining the code of this ChargeItem", - description=( - "References the source of pricing information, rules of application for" - " the code this ChargeItem uses." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ChargeItemDefinition"], - ) - definitionCanonical__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_definitionCanonical", - title="Extension field for ``definitionCanonical``.", - ) - - definitionUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="definitionUri", - title="Defining information about the code of this charge item", - description=( - "References the (external) source of pricing information, rules of " - "application for the code this ChargeItem uses." - ), - # if property is element of this resource. - element_property=True, - ) - definitionUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_definitionUri", title="Extension field for ``definitionUri``." - ) - - enteredDate: fhirtypes.DateTime = Field( - None, - alias="enteredDate", - title="Date the charge item was entered", - description=None, - # if property is element of this resource. - element_property=True, - ) - enteredDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_enteredDate", title="Extension field for ``enteredDate``." - ) - - enterer: fhirtypes.ReferenceType = Field( - None, - alias="enterer", - title="Individual who was entering", - description="The device, practitioner, etc. who entered the charge item.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Patient", - "Device", - "RelatedPerson", - ], - ) - - factorOverride: fhirtypes.Decimal = Field( - None, - alias="factorOverride", - title="Factor overriding the associated rules", - description=( - "Factor overriding the factor determined by the rules associated with " - "the code." - ), - # if property is element of this resource. - element_property=True, - ) - factorOverride__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factorOverride", title="Extension field for ``factorOverride``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for item", - description="Identifiers assigned to this event performer or other systems.", - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments made about the ChargeItem", - description=( - "Comments made about the event by the performer, subject or other " - "participants." - ), - # if property is element of this resource. - element_property=True, - ) - - occurrenceDateTime: fhirtypes.DateTime = Field( - None, - alias="occurrenceDateTime", - title="When the charged service was applied", - description="Date/time(s) or duration when the charged service was applied.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - occurrenceDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurrenceDateTime", - title="Extension field for ``occurrenceDateTime``.", - ) - - occurrencePeriod: fhirtypes.PeriodType = Field( - None, - alias="occurrencePeriod", - title="When the charged service was applied", - description="Date/time(s) or duration when the charged service was applied.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - occurrenceTiming: fhirtypes.TimingType = Field( - None, - alias="occurrenceTiming", - title="When the charged service was applied", - description="Date/time(s) or duration when the charged service was applied.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - overrideReason: fhirtypes.String = Field( - None, - alias="overrideReason", - title="Reason for overriding the list price/factor", - description=( - "If the list price or the rule-based factor associated with the code is" - " overridden, this attribute can capture a text to indicate the reason" - " for this action." - ), - # if property is element of this resource. - element_property=True, - ) - overrideReason__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_overrideReason", title="Extension field for ``overrideReason``." - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Part of referenced ChargeItem", - description=( - "ChargeItems can be grouped to larger ChargeItems covering the whole " - "set." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ChargeItem"], - ) - - performer: typing.List[fhirtypes.ChargeItemPerformerType] = Field( - None, - alias="performer", - title="Who performed charged service", - description=( - "Indicates who or what performed or participated in the charged " "service." - ), - # if property is element of this resource. - element_property=True, - ) - - performingOrganization: fhirtypes.ReferenceType = Field( - None, - alias="performingOrganization", - title="Organization providing the charged service", - description="The organization requesting the service.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - priceOverride: fhirtypes.MoneyType = Field( - None, - alias="priceOverride", - title="Price overriding the associated rules", - description=( - "Total price of the charge overriding the list price associated with " - "the code." - ), - # if property is element of this resource. - element_property=True, - ) - - productCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="productCodeableConcept", - title="Product charged", - description=( - "Identifies the device, food, drug or other product being charged " - "either by type code or reference to an instance." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e product[x] - one_of_many="product", - one_of_many_required=False, - ) - - productReference: fhirtypes.ReferenceType = Field( - None, - alias="productReference", - title="Product charged", - description=( - "Identifies the device, food, drug or other product being charged " - "either by type code or reference to an instance." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e product[x] - one_of_many="product", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device", "Medication", "Substance"], - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Quantity of which the charge item has been serviced", - description=None, - # if property is element of this resource. - element_property=True, - ) - - reason: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reason", - title="Why was the charged service rendered?", - description="Describes why the event occurred in coded or textual form.", - # if property is element of this resource. - element_property=True, - ) - - requestingOrganization: fhirtypes.ReferenceType = Field( - None, - alias="requestingOrganization", - title="Organization requesting the charged service", - description="The organization performing the service.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - service: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="service", - title="Which rendered service is being charged?", - description="Indicated the rendered service that caused this charge.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "DiagnosticReport", - "ImagingStudy", - "Immunization", - "MedicationAdministration", - "MedicationDispense", - "Observation", - "Procedure", - "SupplyDelivery", - ], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "planned | billable | not-billable | aborted | billed | entered-in-" - "error | unknown" - ), - description="The current state of the ChargeItem.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "planned", - "billable", - "not-billable", - "aborted", - "billed", - "entered-in-error", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Individual service was done for/to", - description=( - "The individual or set of individuals the action is being or was " - "performed on." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - supportingInformation: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingInformation", - title="Further information supporting this charge", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ChargeItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "definitionUri", - "definitionCanonical", - "status", - "partOf", - "code", - "subject", - "context", - "occurrenceDateTime", - "occurrencePeriod", - "occurrenceTiming", - "performer", - "performingOrganization", - "requestingOrganization", - "costCenter", - "quantity", - "bodysite", - "factorOverride", - "priceOverride", - "overrideReason", - "enterer", - "enteredDate", - "reason", - "service", - "productReference", - "productCodeableConcept", - "account", - "note", - "supportingInformation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1161( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1161( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "occurrence": [ - "occurrenceDateTime", - "occurrencePeriod", - "occurrenceTiming", - ], - "product": ["productCodeableConcept", "productReference"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ChargeItemPerformer(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Who performed charged service. - Indicates who or what performed or participated in the charged service. - """ - - resource_type = Field("ChargeItemPerformer", const=True) - - actor: fhirtypes.ReferenceType = Field( - ..., - alias="actor", - title="Individual who was performing", - description=( - "The device, practitioner, etc. who performed or participated in the " - "service." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "CareTeam", - "Patient", - "Device", - "RelatedPerson", - ], - ) - - function: fhirtypes.CodeableConceptType = Field( - None, - alias="function", - title="What type of performance was done", - description=( - "Describes the type of performance or participation(e.g. primary " - "surgeon, anesthesiologiest, etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ChargeItemPerformer`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "function", "actor"] diff --git a/fhir/resources/chargeitemdefinition.py b/fhir/resources/chargeitemdefinition.py deleted file mode 100644 index b5d89d30..00000000 --- a/fhir/resources/chargeitemdefinition.py +++ /dev/null @@ -1,775 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ChargeItemDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ChargeItemDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Definition of properties and rules about how the price and the - applicability of a ChargeItem can be determined. - The ChargeItemDefinition resource provides the properties that apply to the - (billing) codes necessary to calculate costs and prices. The properties may - differ largely depending on type and realm, therefore this resource gives - only a rough structure and requires profiling for each type of billing code - system. - """ - - resource_type = Field("ChargeItemDefinition", const=True) - - applicability: typing.List[fhirtypes.ChargeItemDefinitionApplicabilityType] = Field( - None, - alias="applicability", - title="Whether or not the billing code is applicable", - description="Expressions that describe applicability criteria for the billing code.", - # if property is element of this resource. - element_property=True, - ) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the charge item definition was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Billing codes or product types this definition applies to", - description=( - "The defined billing details in this resource pertain to the given " - "billing code." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the charge item definition and/or " - "its contents. Copyright statements are generally legal restrictions on" - " the use and publishing of the charge item definition." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the charge item definition was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the charge item definition " - "changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - derivedFromUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="derivedFromUri", - title="Underlying externally-defined charge item definition", - description=( - "The URL pointing to an externally-defined charge item definition that " - "is adhered to in whole or in part by this definition." - ), - # if property is element of this resource. - element_property=True, - ) - derivedFromUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_derivedFromUri", title="Extension field for ``derivedFromUri``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the charge item definition", - description=( - "A free text natural language description of the charge item definition" - " from a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the charge item definition is expected to be used", - description=( - "The period during which the charge item definition content was or is " - "planned to be in active use." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this charge item definition is " - "authored for testing purposes (or education/evaluation/marketing) and " - "is not intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the charge item definition", - description=( - "A formal identifier that is used to identify this charge item " - "definition when it is represented in other formats, or referenced in a" - " specification, model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - instance: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="instance", - title="Instances this definition applies to", - description=( - "The defined billing details in this resource pertain to the given " - "product instance(s)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Medication", "Substance", "Device"], - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for charge item definition (if applicable)", - description=( - "A legal or geographic region in which the charge item definition is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the charge item definition was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - partOf: typing.List[fhirtypes.Canonical] = Field( - None, - alias="partOf", - title=( - "A larger definition of which this particular definition is a component" - " or step" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ChargeItemDefinition"], - ) - partOf__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_partOf", title="Extension field for ``partOf``.") - - propertyGroup: typing.List[fhirtypes.ChargeItemDefinitionPropertyGroupType] = Field( - None, - alias="propertyGroup", - title="Group of properties which are applicable under the same conditions", - description=( - "Group of properties which are applicable under the same conditions. If" - " no applicability rules are established for the group, then all " - "properties always apply." - ), - # if property is element of this resource. - element_property=True, - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the charge " - "item definition." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - replaces: typing.List[fhirtypes.Canonical] = Field( - None, - alias="replaces", - title=( - "Completed or terminated request(s) whose function is taken by this new" - " request" - ), - description=( - "As new versions of a protocol or guideline are defined, allows " - "identification of what versions are replaced by a new instance." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ChargeItemDefinition"], - ) - replaces__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_replaces", title="Extension field for ``replaces``.") - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description="The current state of the ChargeItemDefinition.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this charge item definition (human friendly)", - description=( - "A short, descriptive, user-friendly title for the charge item " - "definition." - ), - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this charge item definition, represented as a" - " URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this charge item definition " - "when it is referenced in a specification, model, design or an " - "instance; also called its canonical identifier. This SHOULD be " - "globally unique and SHOULD be a literal address at which at which an " - "authoritative instance of this charge item definition is (or will be) " - "published. This URL can be the target of a canonical reference. It " - "SHALL remain the same when the charge item definition is stored on " - "different servers." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate charge item definition " - "instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the charge item definition", - description=( - "The identifier that is used to identify this version of the charge " - "item definition when it is referenced in a specification, model, " - "design or instance. This is an arbitrary value managed by the charge " - "item definition author and is not expected to be globally unique. For " - "example, it might be a timestamp (e.g. yyyymmdd) if a managed version " - "is not available. There is also no expectation that versions can be " - "placed in a lexicographical sequence. To provide a version consistent " - "with the Decision Support Service specification, use the format " - "Major.Minor.Revision (e.g. 1.0.0). For more information on versioning " - "knowledge assets, refer to the Decision Support Service specification." - " Note that a version is required for non-experimental active assets." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ChargeItemDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "title", - "derivedFromUri", - "partOf", - "replaces", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "code", - "instance", - "applicability", - "propertyGroup", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2195( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext"), ("url", "url__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ChargeItemDefinitionApplicability(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Whether or not the billing code is applicable. - Expressions that describe applicability criteria for the billing code. - """ - - resource_type = Field("ChargeItemDefinitionApplicability", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Natural language description of the condition", - description=( - "A brief, natural language description of the condition that " - "effectively communicates the intended semantics." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - expression: fhirtypes.String = Field( - None, - alias="expression", - title="Boolean-valued expression", - description=( - "An expression that returns true or false, indicating whether the " - "condition is satisfied. When using FHIRPath expressions, the %context " - "environment variable must be replaced at runtime with the ChargeItem " - "resource to which this definition is applied." - ), - # if property is element of this resource. - element_property=True, - ) - expression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expression", title="Extension field for ``expression``." - ) - - language: fhirtypes.String = Field( - None, - alias="language", - title="Language of the expression", - description=( - 'The media type of the language for the expression, e.g. "text/cql" for' - ' Clinical Query Language expressions or "text/fhirpath" for FHIRPath ' - "expressions." - ), - # if property is element of this resource. - element_property=True, - ) - language__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_language", title="Extension field for ``language``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ChargeItemDefinitionApplicability`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "language", - "expression", - ] - - -class ChargeItemDefinitionPropertyGroup(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Group of properties which are applicable under the same conditions. - Group of properties which are applicable under the same conditions. If no - applicability rules are established for the group, then all properties - always apply. - """ - - resource_type = Field("ChargeItemDefinitionPropertyGroup", const=True) - - applicability: typing.List[fhirtypes.ChargeItemDefinitionApplicabilityType] = Field( - None, - alias="applicability", - title="Conditions under which the priceComponent is applicable", - description=( - "Expressions that describe applicability criteria for the " - "priceComponent." - ), - # if property is element of this resource. - element_property=True, - ) - - priceComponent: typing.List[ - fhirtypes.ChargeItemDefinitionPropertyGroupPriceComponentType - ] = Field( - None, - alias="priceComponent", - title="Components of total line item price", - description=( - "The price for a ChargeItem may be calculated as a base price with " - "surcharges/deductions that apply in certain conditions. A " - "ChargeItemDefinition resource that defines the prices, factors and " - "conditions that apply to a billing code is currently under " - "development. The priceComponent element can be used to offer " - "transparency to the recipient of the Invoice of how the prices have " - "been calculated." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ChargeItemDefinitionPropertyGroup`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "applicability", - "priceComponent", - ] - - -class ChargeItemDefinitionPropertyGroupPriceComponent(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Components of total line item price. - The price for a ChargeItem may be calculated as a base price with - surcharges/deductions that apply in certain conditions. A - ChargeItemDefinition resource that defines the prices, factors and - conditions that apply to a billing code is currently under development. The - priceComponent element can be used to offer transparency to the recipient - of the Invoice of how the prices have been calculated. - """ - - resource_type = Field("ChargeItemDefinitionPropertyGroupPriceComponent", const=True) - - amount: fhirtypes.MoneyType = Field( - None, - alias="amount", - title="Monetary amount associated with this component", - description="The amount calculated for this component.", - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Code identifying the specific component", - description=( - "A code that identifies the component. Codes may be used to " - "differentiate between kinds of taxes, surcharges, discounts etc." - ), - # if property is element of this resource. - element_property=True, - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Factor used for calculating this component", - description=( - "The factor that has been applied on the base price for calculating " - "this component." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="base | surcharge | deduction | discount | tax | informational", - description="This code identifies the type of the component.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "base", - "surcharge", - "deduction", - "discount", - "tax", - "informational", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ChargeItemDefinitionPropertyGroupPriceComponent`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "code", - "factor", - "amount", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_5041( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/claim.py b/fhir/resources/claim.py deleted file mode 100644 index 21a7351b..00000000 --- a/fhir/resources/claim.py +++ /dev/null @@ -1,2779 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Claim -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Claim(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Claim, Pre-determination or Pre-authorization. - A provider issued list of professional services and products which have - been provided, or are to be provided, to a patient which is sent to an - insurer for reimbursement. - """ - - resource_type = Field("Claim", const=True) - - accident: fhirtypes.ClaimAccidentType = Field( - None, - alias="accident", - title="Details of the event", - description=( - "Details of an accident which resulted in injuries which required the " - "products and services listed in the claim." - ), - # if property is element of this resource. - element_property=True, - ) - - billablePeriod: fhirtypes.PeriodType = Field( - None, - alias="billablePeriod", - title="Relevant time frame for the claim", - description="The period for which charges are being submitted.", - # if property is element of this resource. - element_property=True, - ) - - careTeam: typing.List[fhirtypes.ClaimCareTeamType] = Field( - None, - alias="careTeam", - title="Members of the care team", - description="The members of the team who provided the products and services.", - # if property is element of this resource. - element_property=True, - ) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="Resource creation date", - description="The date this resource was created.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - diagnosis: typing.List[fhirtypes.ClaimDiagnosisType] = Field( - None, - alias="diagnosis", - title="Pertinent diagnosis information", - description="Information about diagnoses relevant to the claim items.", - # if property is element of this resource. - element_property=True, - ) - - enterer: fhirtypes.ReferenceType = Field( - None, - alias="enterer", - title="Author of the claim", - description=( - "Individual who created the claim, predetermination or " "preauthorization." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - facility: fhirtypes.ReferenceType = Field( - None, - alias="facility", - title="Servicing facility", - description="Facility where the services were provided.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - fundsReserve: fhirtypes.CodeableConceptType = Field( - None, - alias="fundsReserve", - title="For whom to reserve funds", - description=( - "A code to indicate whether and for whom funds are to be reserved for " - "future claims." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for claim", - description="A unique identifier assigned to this claim.", - # if property is element of this resource. - element_property=True, - ) - - insurance: typing.List[fhirtypes.ClaimInsuranceType] = Field( - ..., - alias="insurance", - title="Patient insurance information", - description=( - "Financial instruments for reimbursement for the health care products " - "and services specified on the claim." - ), - # if property is element of this resource. - element_property=True, - ) - - insurer: fhirtypes.ReferenceType = Field( - None, - alias="insurer", - title="Target", - description="The Insurer who is target of the request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - item: typing.List[fhirtypes.ClaimItemType] = Field( - None, - alias="item", - title="Product or service provided", - description=( - "A claim line. Either a simple product or service or a 'group' of " - "details which can each be a simple items or groups of sub-details." - ), - # if property is element of this resource. - element_property=True, - ) - - originalPrescription: fhirtypes.ReferenceType = Field( - None, - alias="originalPrescription", - title="Original prescription if superseded by fulfiller", - description=( - "Original prescription which has been superseded by this prescription " - "to support the dispensing of pharmacy services, medications or " - "products." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "DeviceRequest", - "MedicationRequest", - "VisionPrescription", - ], - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="The recipient of the products and services", - description=( - "The party to whom the professional services and/or products have been " - "supplied or are being considered and for whom actual or forecast " - "reimbursement is sought." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - payee: fhirtypes.ClaimPayeeType = Field( - None, - alias="payee", - title="Recipient of benefits payable", - description=( - "The party to be reimbursed for cost of the products and services " - "according to the terms of the policy." - ), - # if property is element of this resource. - element_property=True, - ) - - prescription: fhirtypes.ReferenceType = Field( - None, - alias="prescription", - title="Prescription authorizing services and products", - description=( - "Prescription to support the dispensing of pharmacy, device or vision " - "products." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "DeviceRequest", - "MedicationRequest", - "VisionPrescription", - ], - ) - - priority: fhirtypes.CodeableConceptType = Field( - ..., - alias="priority", - title="Desired processing ugency", - description=( - "The provider-required urgency of processing the request. Typical " - "values include: stat, routine deferred." - ), - # if property is element of this resource. - element_property=True, - ) - - procedure: typing.List[fhirtypes.ClaimProcedureType] = Field( - None, - alias="procedure", - title="Clinical procedures performed", - description=( - "Procedures performed on the patient relevant to the billing items with" - " the claim." - ), - # if property is element of this resource. - element_property=True, - ) - - provider: fhirtypes.ReferenceType = Field( - ..., - alias="provider", - title="Party responsible for the claim", - description=( - "The provider which is responsible for the claim, predetermination or " - "preauthorization." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - referral: fhirtypes.ReferenceType = Field( - None, - alias="referral", - title="Treatment referral", - description="A reference to a referral resource.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ServiceRequest"], - ) - - related: typing.List[fhirtypes.ClaimRelatedType] = Field( - None, - alias="related", - title="Prior or corollary claims", - description=( - "Other claims which are related to this claim such as prior submissions" - " or claims for related services or for the same event." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | cancelled | draft | entered-in-error", - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "cancelled", "draft", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subType: fhirtypes.CodeableConceptType = Field( - None, - alias="subType", - title="More granular claim type", - description=( - "A finer grained suite of claim type codes which may convey additional " - "information such as Inpatient vs Outpatient and/or a specialty " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - supportingInfo: typing.List[fhirtypes.ClaimSupportingInfoType] = Field( - None, - alias="supportingInfo", - title="Supporting information", - description=( - "Additional information codes regarding exceptions, special " - "considerations, the condition, situation, prior or concurrent issues." - ), - # if property is element of this resource. - element_property=True, - ) - - total: fhirtypes.MoneyType = Field( - None, - alias="total", - title="Total claim cost", - description="The total value of the all the items in the claim.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Category or discipline", - description=( - "The category of claim, e.g. oral, pharmacy, vision, institutional, " - "professional." - ), - # if property is element of this resource. - element_property=True, - ) - - use: fhirtypes.Code = Field( - None, - alias="use", - title="claim | preauthorization | predetermination", - description=( - "A code to indicate whether the nature of the request is: to request " - "adjudication of products and services previously rendered; or " - "requesting authorization and adjudication for provision in the future;" - " or requesting the non-binding adjudication of the listed products and" - " services which could be provided in the future." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["claim", "preauthorization", "predetermination"], - ) - use__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_use", title="Extension field for ``use``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Claim`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "type", - "subType", - "use", - "patient", - "billablePeriod", - "created", - "enterer", - "insurer", - "provider", - "priority", - "fundsReserve", - "related", - "prescription", - "originalPrescription", - "payee", - "referral", - "facility", - "careTeam", - "supportingInfo", - "diagnosis", - "procedure", - "insurance", - "accident", - "item", - "total", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_662( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("created", "created__ext"), - ("status", "status__ext"), - ("use", "use__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ClaimAccident(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Details of the event. - Details of an accident which resulted in injuries which required the - products and services listed in the claim. - """ - - resource_type = Field("ClaimAccident", const=True) - - date: fhirtypes.Date = Field( - None, - alias="date", - title="When the incident occurred", - description=( - "Date of an accident event related to the products and services " - "contained in the claim." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - locationAddress: fhirtypes.AddressType = Field( - None, - alias="locationAddress", - title="Where the event occurred", - description="The physical location of the accident event.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - ) - - locationReference: fhirtypes.ReferenceType = Field( - None, - alias="locationReference", - title="Where the event occurred", - description="The physical location of the accident event.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="The nature of the accident", - description=( - "The type or context of the accident event for the purposes of " - "selection of potential insurance coverages and determination of " - "coordination between insurers." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimAccident`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "date", - "type", - "locationAddress", - "locationReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1464( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("date", "date__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1464( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"location": ["locationAddress", "locationReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ClaimCareTeam(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Members of the care team. - The members of the team who provided the products and services. - """ - - resource_type = Field("ClaimCareTeam", const=True) - - provider: fhirtypes.ReferenceType = Field( - ..., - alias="provider", - title="Practitioner or organization", - description="Member of the team who provided the product or service.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - qualification: fhirtypes.CodeableConceptType = Field( - None, - alias="qualification", - title="Practitioner credential or specialization", - description=( - "The qualification of the practitioner which is applicable for this " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - responsible: bool = Field( - None, - alias="responsible", - title="Indicator of the lead practitioner", - description=( - "The party who is billing and/or responsible for the claimed products " - "or services." - ), - # if property is element of this resource. - element_property=True, - ) - responsible__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_responsible", title="Extension field for ``responsible``." - ) - - role: fhirtypes.CodeableConceptType = Field( - None, - alias="role", - title="Function within the team", - description=( - "The lead, assisting or supervising practitioner and their discipline " - "if a multidisciplinary team." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Order of care team", - description="A number to uniquely identify care team entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimCareTeam`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "provider", - "responsible", - "role", - "qualification", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1432( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ClaimDiagnosis(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Pertinent diagnosis information. - Information about diagnoses relevant to the claim items. - """ - - resource_type = Field("ClaimDiagnosis", const=True) - - diagnosisCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="diagnosisCodeableConcept", - title="Nature of illness or problem", - description=( - "The nature of illness or problem in a coded form or as a reference to " - "an external defined Condition." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e diagnosis[x] - one_of_many="diagnosis", - one_of_many_required=True, - ) - - diagnosisReference: fhirtypes.ReferenceType = Field( - None, - alias="diagnosisReference", - title="Nature of illness or problem", - description=( - "The nature of illness or problem in a coded form or as a reference to " - "an external defined Condition." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e diagnosis[x] - one_of_many="diagnosis", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition"], - ) - - onAdmission: fhirtypes.CodeableConceptType = Field( - None, - alias="onAdmission", - title="Present on admission", - description=( - "Indication of whether the diagnosis was present on admission to a " - "facility." - ), - # if property is element of this resource. - element_property=True, - ) - - packageCode: fhirtypes.CodeableConceptType = Field( - None, - alias="packageCode", - title="Package billing code", - description=( - "A package billing code or bundle code used to group products and " - "services to a particular health condition (such as heart attack) which" - " is based on a predetermined grouping code system." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Diagnosis instance identifier", - description="A number to uniquely identify diagnosis entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Timing or nature of the diagnosis", - description="When the condition was observed or the relative ranking.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimDiagnosis`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "diagnosisCodeableConcept", - "diagnosisReference", - "type", - "onAdmission", - "packageCode", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1597( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1597( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "diagnosis": ["diagnosisCodeableConcept", "diagnosisReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ClaimInsurance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Patient insurance information. - Financial instruments for reimbursement for the health care products and - services specified on the claim. - """ - - resource_type = Field("ClaimInsurance", const=True) - - businessArrangement: fhirtypes.String = Field( - None, - alias="businessArrangement", - title="Additional provider contract number", - description=( - "A business agreement number established between the provider and the " - "insurer for special business processing purposes." - ), - # if property is element of this resource. - element_property=True, - ) - businessArrangement__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_businessArrangement", - title="Extension field for ``businessArrangement``.", - ) - - claimResponse: fhirtypes.ReferenceType = Field( - None, - alias="claimResponse", - title="Adjudication results", - description=( - "The result of the adjudication of the line items for the Coverage " - "specified in this insurance." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ClaimResponse"], - ) - - coverage: fhirtypes.ReferenceType = Field( - ..., - alias="coverage", - title="Insurance information", - description=( - "Reference to the insurance card level information contained in the " - "Coverage resource. The coverage issuing insurer will use these details" - " to locate the patient's actual coverage within the insurer's " - "information system." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Coverage"], - ) - - focal: bool = Field( - None, - alias="focal", - title="Coverage to be used for adjudication", - description=( - "A flag to indicate that this Coverage is to be used for adjudication " - "of this claim when set to true." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - focal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_focal", title="Extension field for ``focal``." - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Pre-assigned Claim number", - description=( - "The business identifier to be used when the claim is sent for " - "adjudication against this insurance policy." - ), - # if property is element of this resource. - element_property=True, - ) - - preAuthRef: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="preAuthRef", - title="Prior authorization reference number", - description=( - "Reference numbers previously provided by the insurer to the provider " - "to be quoted on subsequent claims containing services or products " - "related to the prior authorization." - ), - # if property is element of this resource. - element_property=True, - ) - preAuthRef__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_preAuthRef", title="Extension field for ``preAuthRef``.") - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Insurance instance identifier", - description=( - "A number to uniquely identify insurance entries and provide a sequence" - " of coverages to convey coordination of benefit order." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimInsurance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "focal", - "identifier", - "coverage", - "businessArrangement", - "preAuthRef", - "claimResponse", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1590( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("focal", "focal__ext"), ("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ClaimItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Product or service provided. - A claim line. Either a simple product or service or a 'group' of details - which can each be a simple items or groups of sub-details. - """ - - resource_type = Field("ClaimItem", const=True) - - bodySite: fhirtypes.CodeableConceptType = Field( - None, - alias="bodySite", - title="Anatomical location", - description="Physical service site on the patient (limb, tooth, etc.).", - # if property is element of this resource. - element_property=True, - ) - - careTeamSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="careTeamSequence", - title="Applicable careTeam members", - description="CareTeam members related to this service or product.", - # if property is element of this resource. - element_property=True, - ) - careTeamSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_careTeamSequence", - title="Extension field for ``careTeamSequence``.", - ) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Benefit classification", - description=( - "Code to identify the general type of benefits under which products and" - " services are provided." - ), - # if property is element of this resource. - element_property=True, - ) - - detail: typing.List[fhirtypes.ClaimItemDetailType] = Field( - None, - alias="detail", - title="Product or service provided", - description=( - "A claim detail line. Either a simple (a product or service) or a " - "'group' of sub-details which are simple items." - ), - # if property is element of this resource. - element_property=True, - ) - - diagnosisSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="diagnosisSequence", - title="Applicable diagnoses", - description="Diagnosis applicable for this service or product.", - # if property is element of this resource. - element_property=True, - ) - diagnosisSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_diagnosisSequence", - title="Extension field for ``diagnosisSequence``.", - ) - - encounter: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="encounter", - title="Encounters related to this billed item", - description=( - "The Encounters during which this Claim was created or to which the " - "creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - informationSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="informationSequence", - title="Applicable exception and supporting information", - description=( - "Exceptions, special conditions and supporting information applicable " - "for this service or product." - ), - # if property is element of this resource. - element_property=True, - ) - informationSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_informationSequence", - title="Extension field for ``informationSequence``.", - ) - - locationAddress: fhirtypes.AddressType = Field( - None, - alias="locationAddress", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - ) - - locationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="locationCodeableConcept", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - ) - - locationReference: fhirtypes.ReferenceType = Field( - None, - alias="locationReference", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Product or service billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - procedureSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="procedureSequence", - title="Applicable procedures", - description="Procedures applicable for this service or product.", - # if property is element of this resource. - element_property=True, - ) - procedureSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_procedureSequence", - title="Extension field for ``procedureSequence``.", - ) - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - programCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="programCode", - title="Program the product or service is provided under", - description="Identifies the program under which this may be recovered.", - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - revenue: fhirtypes.CodeableConceptType = Field( - None, - alias="revenue", - title="Revenue or cost center code", - description=( - "The type of revenue or cost center providing the product and/or " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Item instance identifier", - description="A number to uniquely identify item entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - servicedDate: fhirtypes.Date = Field( - None, - alias="servicedDate", - title="Date or dates of service or product delivery", - description=( - "The date or dates when the service or product was supplied, performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - servicedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_servicedDate", title="Extension field for ``servicedDate``." - ) - - servicedPeriod: fhirtypes.PeriodType = Field( - None, - alias="servicedPeriod", - title="Date or dates of service or product delivery", - description=( - "The date or dates when the service or product was supplied, performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - - subSite: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="subSite", - title="Anatomical sub-location", - description=( - "A region or surface of the bodySite, e.g. limb region or tooth " - "surface(s)." - ), - # if property is element of this resource. - element_property=True, - ) - - udi: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="udi", - title="Unique device identifier", - description="Unique Device Identifiers associated with this line item.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "careTeamSequence", - "diagnosisSequence", - "procedureSequence", - "informationSequence", - "revenue", - "category", - "productOrService", - "modifier", - "programCode", - "servicedDate", - "servicedPeriod", - "locationCodeableConcept", - "locationAddress", - "locationReference", - "quantity", - "unitPrice", - "factor", - "net", - "udi", - "bodySite", - "subSite", - "encounter", - "detail", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1061( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1061( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "location": [ - "locationAddress", - "locationCodeableConcept", - "locationReference", - ], - "serviced": ["servicedDate", "servicedPeriod"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ClaimItemDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Product or service provided. - A claim detail line. Either a simple (a product or service) or a 'group' of - sub-details which are simple items. - """ - - resource_type = Field("ClaimItemDetail", const=True) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Benefit classification", - description=( - "Code to identify the general type of benefits under which products and" - " services are provided." - ), - # if property is element of this resource. - element_property=True, - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Service/Product billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - programCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="programCode", - title="Program the product or service is provided under", - description="Identifies the program under which this may be recovered.", - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - revenue: fhirtypes.CodeableConceptType = Field( - None, - alias="revenue", - title="Revenue or cost center code", - description=( - "The type of revenue or cost center providing the product and/or " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Item instance identifier", - description="A number to uniquely identify item entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - subDetail: typing.List[fhirtypes.ClaimItemDetailSubDetailType] = Field( - None, - alias="subDetail", - title="Product or service provided", - description=( - "A claim detail line. Either a simple (a product or service) or a " - "'group' of sub-details which are simple items." - ), - # if property is element of this resource. - element_property=True, - ) - - udi: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="udi", - title="Unique device identifier", - description="Unique Device Identifiers associated with this line item.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimItemDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "revenue", - "category", - "productOrService", - "modifier", - "programCode", - "quantity", - "unitPrice", - "factor", - "net", - "udi", - "subDetail", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1655( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ClaimItemDetailSubDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Product or service provided. - A claim detail line. Either a simple (a product or service) or a 'group' of - sub-details which are simple items. - """ - - resource_type = Field("ClaimItemDetailSubDetail", const=True) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Benefit classification", - description=( - "Code to identify the general type of benefits under which products and" - " services are provided." - ), - # if property is element of this resource. - element_property=True, - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Service/Product billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - programCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="programCode", - title="Program the product or service is provided under", - description="Identifies the program under which this may be recovered.", - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - revenue: fhirtypes.CodeableConceptType = Field( - None, - alias="revenue", - title="Revenue or cost center code", - description=( - "The type of revenue or cost center providing the product and/or " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Item instance identifier", - description="A number to uniquely identify item entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - udi: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="udi", - title="Unique device identifier", - description="Unique Device Identifiers associated with this line item.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimItemDetailSubDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "revenue", - "category", - "productOrService", - "modifier", - "programCode", - "quantity", - "unitPrice", - "factor", - "net", - "udi", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2548( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ClaimPayee(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Recipient of benefits payable. - The party to be reimbursed for cost of the products and services according - to the terms of the policy. - """ - - resource_type = Field("ClaimPayee", const=True) - - party: fhirtypes.ReferenceType = Field( - None, - alias="party", - title="Recipient reference", - description=( - "Reference to the individual or organization to whom any payment will " - "be made." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Patient", - "RelatedPerson", - ], - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Category of recipient", - description="Type of Party to be reimbursed: subscriber, provider, other.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimPayee`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "party"] - - -class ClaimProcedure(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Clinical procedures performed. - Procedures performed on the patient relevant to the billing items with the - claim. - """ - - resource_type = Field("ClaimProcedure", const=True) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="When the procedure was performed", - description="Date and optionally time the procedure was performed.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - procedureCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="procedureCodeableConcept", - title="Specific clinical procedure", - description=( - "The code or reference to a Procedure resource which identifies the " - "clinical intervention performed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e procedure[x] - one_of_many="procedure", - one_of_many_required=True, - ) - - procedureReference: fhirtypes.ReferenceType = Field( - None, - alias="procedureReference", - title="Specific clinical procedure", - description=( - "The code or reference to a Procedure resource which identifies the " - "clinical intervention performed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e procedure[x] - one_of_many="procedure", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Procedure"], - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Procedure instance identifier", - description="A number to uniquely identify procedure entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Category of Procedure", - description="When the condition was observed or the relative ranking.", - # if property is element of this resource. - element_property=True, - ) - - udi: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="udi", - title="Unique device identifier", - description="Unique Device Identifiers associated with this line item.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimProcedure`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "type", - "date", - "procedureCodeableConcept", - "procedureReference", - "udi", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1591( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1591( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "procedure": ["procedureCodeableConcept", "procedureReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ClaimRelated(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Prior or corollary claims. - Other claims which are related to this claim such as prior submissions or - claims for related services or for the same event. - """ - - resource_type = Field("ClaimRelated", const=True) - - claim: fhirtypes.ReferenceType = Field( - None, - alias="claim", - title="Reference to the related claim", - description="Reference to a related claim.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Claim"], - ) - - reference: fhirtypes.IdentifierType = Field( - None, - alias="reference", - title="File or case reference", - description=( - "An alternate organizational reference to the case or file to which " - "this particular claim pertains." - ), - # if property is element of this resource. - element_property=True, - ) - - relationship: fhirtypes.CodeableConceptType = Field( - None, - alias="relationship", - title="How the reference claim is related", - description="A code to convey how the claims are related.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimRelated`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "claim", - "relationship", - "reference", - ] - - -class ClaimSupportingInfo(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Supporting information. - Additional information codes regarding exceptions, special considerations, - the condition, situation, prior or concurrent issues. - """ - - resource_type = Field("ClaimSupportingInfo", const=True) - - category: fhirtypes.CodeableConceptType = Field( - ..., - alias="category", - title="Classification of the supplied information", - description=( - "The general class of the information supplied: information; exception;" - " accident, employment; onset, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Type of information", - description=( - "System and code pertaining to the specific information regarding " - "special conditions relating to the setting, treatment or patient for " - "which care is sought." - ), - # if property is element of this resource. - element_property=True, - ) - - reason: fhirtypes.CodeableConceptType = Field( - None, - alias="reason", - title="Explanation for the information", - description=( - "Provides the reason in the situation where a reason code is required " - "in addition to the content." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Information instance identifier", - description="A number to uniquely identify supporting information entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - timingDate: fhirtypes.Date = Field( - None, - alias="timingDate", - title="When it occurred", - description="The date when or period to which this information refers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - timingDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timingDate", title="Extension field for ``timingDate``." - ) - - timingPeriod: fhirtypes.PeriodType = Field( - None, - alias="timingPeriod", - title="When it occurred", - description="The date when or period to which this information refers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - valueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="valueAttachment", - title="Data to be provided", - description=( - "Additional data or information such as resources, documents, images " - "etc. including references to the data or the actual inclusion of the " - "data." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Data to be provided", - description=( - "Additional data or information such as resources, documents, images " - "etc. including references to the data or the actual inclusion of the " - "data." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Data to be provided", - description=( - "Additional data or information such as resources, documents, images " - "etc. including references to the data or the actual inclusion of the " - "data." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="Data to be provided", - description=( - "Additional data or information such as resources, documents, images " - "etc. including references to the data or the actual inclusion of the " - "data." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Data to be provided", - description=( - "Additional data or information such as resources, documents, images " - "etc. including references to the data or the actual inclusion of the " - "data." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimSupportingInfo`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "category", - "code", - "timingDate", - "timingPeriod", - "valueBoolean", - "valueString", - "valueQuantity", - "valueAttachment", - "valueReference", - "reason", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2143( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2143( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "timing": ["timingDate", "timingPeriod"], - "value": [ - "valueAttachment", - "valueBoolean", - "valueQuantity", - "valueReference", - "valueString", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/claimresponse.py b/fhir/resources/claimresponse.py deleted file mode 100644 index df388401..00000000 --- a/fhir/resources/claimresponse.py +++ /dev/null @@ -1,2128 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ClaimResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ClaimResponse(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Response to a claim predetermination or preauthorization. - This resource provides the adjudication details from the processing of a - Claim resource. - """ - - resource_type = Field("ClaimResponse", const=True) - - addItem: typing.List[fhirtypes.ClaimResponseAddItemType] = Field( - None, - alias="addItem", - title="Insurer added line items", - description=( - "The first-tier service adjudications for payor added product or " - "service lines." - ), - # if property is element of this resource. - element_property=True, - ) - - adjudication: typing.List[fhirtypes.ClaimResponseItemAdjudicationType] = Field( - None, - alias="adjudication", - title="Header-level adjudication", - description=( - "The adjudication results which are presented at the header level " - "rather than at the line-item or add-item levels." - ), - # if property is element of this resource. - element_property=True, - ) - - communicationRequest: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="communicationRequest", - title="Request for additional information", - description="Request for additional supporting or authorizing information.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CommunicationRequest"], - ) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="Response creation date", - description="The date this resource was created.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - disposition: fhirtypes.String = Field( - None, - alias="disposition", - title="Disposition Message", - description="A human readable description of the status of the adjudication.", - # if property is element of this resource. - element_property=True, - ) - disposition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_disposition", title="Extension field for ``disposition``." - ) - - error: typing.List[fhirtypes.ClaimResponseErrorType] = Field( - None, - alias="error", - title="Processing errors", - description="Errors encountered during the processing of the adjudication.", - # if property is element of this resource. - element_property=True, - ) - - form: fhirtypes.AttachmentType = Field( - None, - alias="form", - title="Printed reference or actual form", - description=( - "The actual form, by reference or inclusion, for printing the content " - "or an EOB." - ), - # if property is element of this resource. - element_property=True, - ) - - formCode: fhirtypes.CodeableConceptType = Field( - None, - alias="formCode", - title="Printed form identifier", - description="A code for the form to be used for printing the content.", - # if property is element of this resource. - element_property=True, - ) - - fundsReserve: fhirtypes.CodeableConceptType = Field( - None, - alias="fundsReserve", - title="Funds reserved status", - description=( - "A code, used only on a response to a preauthorization, to indicate " - "whether the benefits payable have been reserved and for whom." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for a claim response", - description="A unique identifier assigned to this claim response.", - # if property is element of this resource. - element_property=True, - ) - - insurance: typing.List[fhirtypes.ClaimResponseInsuranceType] = Field( - None, - alias="insurance", - title="Patient insurance information", - description=( - "Financial instruments for reimbursement for the health care products " - "and services specified on the claim." - ), - # if property is element of this resource. - element_property=True, - ) - - insurer: fhirtypes.ReferenceType = Field( - ..., - alias="insurer", - title="Party responsible for reimbursement", - description=( - "The party responsible for authorization, adjudication and " - "reimbursement." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - item: typing.List[fhirtypes.ClaimResponseItemType] = Field( - None, - alias="item", - title="Adjudication for claim line items", - description=( - "A claim line. Either a simple (a product or service) or a 'group' of " - "details which can also be a simple items or groups of sub-details." - ), - # if property is element of this resource. - element_property=True, - ) - - outcome: fhirtypes.Code = Field( - None, - alias="outcome", - title="queued | complete | error | partial", - description=( - "The outcome of the claim, predetermination, or preauthorization " - "processing." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["queued", "complete", "error", "partial"], - ) - outcome__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_outcome", title="Extension field for ``outcome``." - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="The recipient of the products and services", - description=( - "The party to whom the professional services and/or products have been " - "supplied or are being considered and for whom actual for facast " - "reimbursement is sought." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - payeeType: fhirtypes.CodeableConceptType = Field( - None, - alias="payeeType", - title="Party to be paid any benefits payable", - description="Type of Party to be reimbursed: subscriber, provider, other.", - # if property is element of this resource. - element_property=True, - ) - - payment: fhirtypes.ClaimResponsePaymentType = Field( - None, - alias="payment", - title="Payment Details", - description="Payment details for the adjudication of the claim.", - # if property is element of this resource. - element_property=True, - ) - - preAuthPeriod: fhirtypes.PeriodType = Field( - None, - alias="preAuthPeriod", - title="Preauthorization reference effective period", - description="The time frame during which this authorization is effective.", - # if property is element of this resource. - element_property=True, - ) - - preAuthRef: fhirtypes.String = Field( - None, - alias="preAuthRef", - title="Preauthorization reference", - description=( - "Reference from the Insurer which is used in later communications which" - " refers to this adjudication." - ), - # if property is element of this resource. - element_property=True, - ) - preAuthRef__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_preAuthRef", title="Extension field for ``preAuthRef``." - ) - - processNote: typing.List[fhirtypes.ClaimResponseProcessNoteType] = Field( - None, - alias="processNote", - title="Note concerning adjudication", - description=( - "A note that describes or explains adjudication results in a human " - "readable form." - ), - # if property is element of this resource. - element_property=True, - ) - - request: fhirtypes.ReferenceType = Field( - None, - alias="request", - title="Id of resource triggering adjudication", - description="Original request resource reference.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Claim"], - ) - - requestor: fhirtypes.ReferenceType = Field( - None, - alias="requestor", - title="Party responsible for the claim", - description=( - "The provider which is responsible for the claim, predetermination or " - "preauthorization." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | cancelled | draft | entered-in-error", - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "cancelled", "draft", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subType: fhirtypes.CodeableConceptType = Field( - None, - alias="subType", - title="More granular claim type", - description=( - "A finer grained suite of claim type codes which may convey additional " - "information such as Inpatient vs Outpatient and/or a specialty " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - total: typing.List[fhirtypes.ClaimResponseTotalType] = Field( - None, - alias="total", - title="Adjudication totals", - description="Categorized monetary totals for the adjudication.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="More granular claim type", - description=( - "A finer grained suite of claim type codes which may convey additional " - "information such as Inpatient vs Outpatient and/or a specialty " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - use: fhirtypes.Code = Field( - None, - alias="use", - title="claim | preauthorization | predetermination", - description=( - "A code to indicate whether the nature of the request is: to request " - "adjudication of products and services previously rendered; or " - "requesting authorization and adjudication for provision in the future;" - " or requesting the non-binding adjudication of the listed products and" - " services which could be provided in the future." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["claim", "preauthorization", "predetermination"], - ) - use__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_use", title="Extension field for ``use``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponse`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "type", - "subType", - "use", - "patient", - "created", - "insurer", - "requestor", - "request", - "outcome", - "disposition", - "preAuthRef", - "preAuthPeriod", - "payeeType", - "item", - "addItem", - "adjudication", - "total", - "payment", - "fundsReserve", - "formCode", - "form", - "processNote", - "communicationRequest", - "insurance", - "error", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1501( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("created", "created__ext"), - ("outcome", "outcome__ext"), - ("status", "status__ext"), - ("use", "use__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ClaimResponseAddItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Insurer added line items. - The first-tier service adjudications for payor added product or service - lines. - """ - - resource_type = Field("ClaimResponseAddItem", const=True) - - adjudication: typing.List[fhirtypes.ClaimResponseItemAdjudicationType] = Field( - ..., - alias="adjudication", - title="Added items adjudication", - description="The adjudication results.", - # if property is element of this resource. - element_property=True, - ) - - bodySite: fhirtypes.CodeableConceptType = Field( - None, - alias="bodySite", - title="Anatomical location", - description="Physical service site on the patient (limb, tooth, etc.).", - # if property is element of this resource. - element_property=True, - ) - - detail: typing.List[fhirtypes.ClaimResponseAddItemDetailType] = Field( - None, - alias="detail", - title="Insurer added line details", - description="The second-tier service adjudications for payor added services.", - # if property is element of this resource. - element_property=True, - ) - - detailSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="detailSequence", - title="Detail sequence number", - description=( - "The sequence number of the details within the claim item which this " - "line is intended to replace." - ), - # if property is element of this resource. - element_property=True, - ) - detailSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_detailSequence", title="Extension field for ``detailSequence``." - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - itemSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="itemSequence", - title="Item sequence number", - description="Claim items which this service line is intended to replace.", - # if property is element of this resource. - element_property=True, - ) - itemSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_itemSequence", title="Extension field for ``itemSequence``." - ) - - locationAddress: fhirtypes.AddressType = Field( - None, - alias="locationAddress", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - ) - - locationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="locationCodeableConcept", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - ) - - locationReference: fhirtypes.ReferenceType = Field( - None, - alias="locationReference", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Service/Product billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - programCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="programCode", - title="Program the product or service is provided under", - description="Identifies the program under which this may be recovered.", - # if property is element of this resource. - element_property=True, - ) - - provider: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="provider", - title="Authorized providers", - description=( - "The providers who are authorized for the services rendered to the " - "patient." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - servicedDate: fhirtypes.Date = Field( - None, - alias="servicedDate", - title="Date or dates of service or product delivery", - description=( - "The date or dates when the service or product was supplied, performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - servicedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_servicedDate", title="Extension field for ``servicedDate``." - ) - - servicedPeriod: fhirtypes.PeriodType = Field( - None, - alias="servicedPeriod", - title="Date or dates of service or product delivery", - description=( - "The date or dates when the service or product was supplied, performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - - subSite: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="subSite", - title="Anatomical sub-location", - description=( - "A region or surface of the bodySite, e.g. limb region or tooth " - "surface(s)." - ), - # if property is element of this resource. - element_property=True, - ) - - subdetailSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="subdetailSequence", - title="Subdetail sequence number", - description=( - "The sequence number of the sub-details within the details within the " - "claim item which this line is intended to replace." - ), - # if property is element of this resource. - element_property=True, - ) - subdetailSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_subdetailSequence", - title="Extension field for ``subdetailSequence``.", - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponseAddItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "itemSequence", - "detailSequence", - "subdetailSequence", - "provider", - "productOrService", - "modifier", - "programCode", - "servicedDate", - "servicedPeriod", - "locationCodeableConcept", - "locationAddress", - "locationReference", - "quantity", - "unitPrice", - "factor", - "net", - "bodySite", - "subSite", - "noteNumber", - "adjudication", - "detail", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2173( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "location": [ - "locationAddress", - "locationCodeableConcept", - "locationReference", - ], - "serviced": ["servicedDate", "servicedPeriod"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ClaimResponseAddItemDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Insurer added line details. - The second-tier service adjudications for payor added services. - """ - - resource_type = Field("ClaimResponseAddItemDetail", const=True) - - adjudication: typing.List[fhirtypes.ClaimResponseItemAdjudicationType] = Field( - ..., - alias="adjudication", - title="Added items detail adjudication", - description="The adjudication results.", - # if property is element of this resource. - element_property=True, - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Service/Product billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - subDetail: typing.List[fhirtypes.ClaimResponseAddItemDetailSubDetailType] = Field( - None, - alias="subDetail", - title="Insurer added line items", - description="The third-tier service adjudications for payor added services.", - # if property is element of this resource. - element_property=True, - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponseAddItemDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "productOrService", - "modifier", - "quantity", - "unitPrice", - "factor", - "net", - "noteNumber", - "adjudication", - "subDetail", - ] - - -class ClaimResponseAddItemDetailSubDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Insurer added line items. - The third-tier service adjudications for payor added services. - """ - - resource_type = Field("ClaimResponseAddItemDetailSubDetail", const=True) - - adjudication: typing.List[fhirtypes.ClaimResponseItemAdjudicationType] = Field( - ..., - alias="adjudication", - title="Added items detail adjudication", - description="The adjudication results.", - # if property is element of this resource. - element_property=True, - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Service/Product billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponseAddItemDetailSubDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "productOrService", - "modifier", - "quantity", - "unitPrice", - "factor", - "net", - "noteNumber", - "adjudication", - ] - - -class ClaimResponseError(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Processing errors. - Errors encountered during the processing of the adjudication. - """ - - resource_type = Field("ClaimResponseError", const=True) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Error code detailing processing issues", - description=( - "An error code, from a specified code system, which details why the " - "claim could not be adjudicated." - ), - # if property is element of this resource. - element_property=True, - ) - - detailSequence: fhirtypes.PositiveInt = Field( - None, - alias="detailSequence", - title="Detail sequence number", - description=( - "The sequence number of the detail within the line item submitted which" - " contains the error. This value is omitted when the error occurs " - "outside of the item structure." - ), - # if property is element of this resource. - element_property=True, - ) - detailSequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_detailSequence", title="Extension field for ``detailSequence``." - ) - - itemSequence: fhirtypes.PositiveInt = Field( - None, - alias="itemSequence", - title="Item sequence number", - description=( - "The sequence number of the line item submitted which contains the " - "error. This value is omitted when the error occurs outside of the item" - " structure." - ), - # if property is element of this resource. - element_property=True, - ) - itemSequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_itemSequence", title="Extension field for ``itemSequence``." - ) - - subDetailSequence: fhirtypes.PositiveInt = Field( - None, - alias="subDetailSequence", - title="Subdetail sequence number", - description=( - "The sequence number of the sub-detail within the detail within the " - "line item submitted which contains the error. This value is omitted " - "when the error occurs outside of the item structure." - ), - # if property is element of this resource. - element_property=True, - ) - subDetailSequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_subDetailSequence", - title="Extension field for ``subDetailSequence``.", - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponseError`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "itemSequence", - "detailSequence", - "subDetailSequence", - "code", - ] - - -class ClaimResponseInsurance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Patient insurance information. - Financial instruments for reimbursement for the health care products and - services specified on the claim. - """ - - resource_type = Field("ClaimResponseInsurance", const=True) - - businessArrangement: fhirtypes.String = Field( - None, - alias="businessArrangement", - title="Additional provider contract number", - description=( - "A business agreement number established between the provider and the " - "insurer for special business processing purposes." - ), - # if property is element of this resource. - element_property=True, - ) - businessArrangement__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_businessArrangement", - title="Extension field for ``businessArrangement``.", - ) - - claimResponse: fhirtypes.ReferenceType = Field( - None, - alias="claimResponse", - title="Adjudication results", - description=( - "The result of the adjudication of the line items for the Coverage " - "specified in this insurance." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ClaimResponse"], - ) - - coverage: fhirtypes.ReferenceType = Field( - ..., - alias="coverage", - title="Insurance information", - description=( - "Reference to the insurance card level information contained in the " - "Coverage resource. The coverage issuing insurer will use these details" - " to locate the patient's actual coverage within the insurer's " - "information system." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Coverage"], - ) - - focal: bool = Field( - None, - alias="focal", - title="Coverage to be used for adjudication", - description=( - "A flag to indicate that this Coverage is to be used for adjudication " - "of this claim when set to true." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - focal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_focal", title="Extension field for ``focal``." - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Insurance instance identifier", - description=( - "A number to uniquely identify insurance entries and provide a sequence" - " of coverages to convey coordination of benefit order." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponseInsurance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "focal", - "coverage", - "businessArrangement", - "claimResponse", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2437( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("focal", "focal__ext"), ("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ClaimResponseItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Adjudication for claim line items. - A claim line. Either a simple (a product or service) or a 'group' of - details which can also be a simple items or groups of sub-details. - """ - - resource_type = Field("ClaimResponseItem", const=True) - - adjudication: typing.List[fhirtypes.ClaimResponseItemAdjudicationType] = Field( - ..., - alias="adjudication", - title="Adjudication details", - description=( - "If this item is a group then the values here are a summary of the " - "adjudication of the detail items. If this item is a simple product or " - "service then this is the result of the adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - - detail: typing.List[fhirtypes.ClaimResponseItemDetailType] = Field( - None, - alias="detail", - title="Adjudication for claim details", - description=( - "A claim detail. Either a simple (a product or service) or a 'group' of" - " sub-details which are simple items." - ), - # if property is element of this resource. - element_property=True, - ) - - itemSequence: fhirtypes.PositiveInt = Field( - None, - alias="itemSequence", - title="Claim item instance identifier", - description="A number to uniquely reference the claim item entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - itemSequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_itemSequence", title="Extension field for ``itemSequence``." - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponseItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "itemSequence", - "noteNumber", - "adjudication", - "detail", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1908( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("itemSequence", "itemSequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ClaimResponseItemAdjudication(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Adjudication details. - If this item is a group then the values here are a summary of the - adjudication of the detail items. If this item is a simple product or - service then this is the result of the adjudication of this item. - """ - - resource_type = Field("ClaimResponseItemAdjudication", const=True) - - amount: fhirtypes.MoneyType = Field( - None, - alias="amount", - title="Monetary amount", - description="Monetary amount associated with the category.", - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.CodeableConceptType = Field( - ..., - alias="category", - title="Type of adjudication information", - description=( - "A code to indicate the information type of this adjudication record. " - "Information types may include the value submitted, maximum values or " - "percentages allowed or payable under the plan, amounts that: the " - "patient is responsible for in aggregate or pertaining to this item; " - "amounts paid by other coverages; and, the benefit payable for this " - "item." - ), - # if property is element of this resource. - element_property=True, - ) - - reason: fhirtypes.CodeableConceptType = Field( - None, - alias="reason", - title="Explanation of adjudication outcome", - description=( - "A code supporting the understanding of the adjudication result and " - "explaining variance from expected amount." - ), - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.Decimal = Field( - None, - alias="value", - title="Non-monetary value", - description=( - "A non-monetary value associated with the category. Mutually exclusive " - "to the amount element above." - ), - # if property is element of this resource. - element_property=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponseItemAdjudication`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "category", - "reason", - "amount", - "value", - ] - - -class ClaimResponseItemDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Adjudication for claim details. - A claim detail. Either a simple (a product or service) or a 'group' of sub- - details which are simple items. - """ - - resource_type = Field("ClaimResponseItemDetail", const=True) - - adjudication: typing.List[fhirtypes.ClaimResponseItemAdjudicationType] = Field( - ..., - alias="adjudication", - title="Detail level adjudication details", - description="The adjudication results.", - # if property is element of this resource. - element_property=True, - ) - - detailSequence: fhirtypes.PositiveInt = Field( - None, - alias="detailSequence", - title="Claim detail instance identifier", - description="A number to uniquely reference the claim detail entry.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - detailSequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_detailSequence", title="Extension field for ``detailSequence``." - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - subDetail: typing.List[fhirtypes.ClaimResponseItemDetailSubDetailType] = Field( - None, - alias="subDetail", - title="Adjudication for claim sub-details", - description="A sub-detail adjudication of a simple product or service.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponseItemDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "detailSequence", - "noteNumber", - "adjudication", - "subDetail", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2502( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("detailSequence", "detailSequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ClaimResponseItemDetailSubDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Adjudication for claim sub-details. - A sub-detail adjudication of a simple product or service. - """ - - resource_type = Field("ClaimResponseItemDetailSubDetail", const=True) - - adjudication: typing.List[fhirtypes.ClaimResponseItemAdjudicationType] = Field( - None, - alias="adjudication", - title="Subdetail level adjudication details", - description="The adjudication results.", - # if property is element of this resource. - element_property=True, - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - subDetailSequence: fhirtypes.PositiveInt = Field( - None, - alias="subDetailSequence", - title="Claim sub-detail instance identifier", - description="A number to uniquely reference the claim sub-detail entry.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - subDetailSequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_subDetailSequence", - title="Extension field for ``subDetailSequence``.", - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponseItemDetailSubDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "subDetailSequence", - "noteNumber", - "adjudication", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3395( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("subDetailSequence", "subDetailSequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ClaimResponsePayment(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Payment Details. - Payment details for the adjudication of the claim. - """ - - resource_type = Field("ClaimResponsePayment", const=True) - - adjustment: fhirtypes.MoneyType = Field( - None, - alias="adjustment", - title="Payment adjustment for non-claim issues", - description=( - "Total amount of all adjustments to this payment included in this " - "transaction which are not related to this claim's adjudication." - ), - # if property is element of this resource. - element_property=True, - ) - - adjustmentReason: fhirtypes.CodeableConceptType = Field( - None, - alias="adjustmentReason", - title="Explanation for the adjustment", - description="Reason for the payment adjustment.", - # if property is element of this resource. - element_property=True, - ) - - amount: fhirtypes.MoneyType = Field( - ..., - alias="amount", - title="Payable amount after adjustment", - description="Benefits payable less any payment adjustment.", - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.Date = Field( - None, - alias="date", - title="Expected date of payment", - description=( - "Estimated date the payment will be issued or the actual issue date of " - "payment." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Business identifier for the payment", - description="Issuer's unique identifier for the payment instrument.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Partial or complete payment", - description=( - "Whether this represents partial or complete payment of the benefits " - "payable." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponsePayment`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "adjustment", - "adjustmentReason", - "date", - "amount", - "identifier", - ] - - -class ClaimResponseProcessNote(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Note concerning adjudication. - A note that describes or explains adjudication results in a human readable - form. - """ - - resource_type = Field("ClaimResponseProcessNote", const=True) - - language: fhirtypes.CodeableConceptType = Field( - None, - alias="language", - title="Language of the text", - description="A code to define the language used in the text of the note.", - # if property is element of this resource. - element_property=True, - ) - - number: fhirtypes.PositiveInt = Field( - None, - alias="number", - title="Note instance identifier", - description="A number to uniquely identify a note entry.", - # if property is element of this resource. - element_property=True, - ) - number__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_number", title="Extension field for ``number``." - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Note explanatory text", - description="The explanation or description associated with the processing.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="display | print | printoper", - description="The business purpose of the note text.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["display", "print", "printoper"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponseProcessNote`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "number", - "type", - "text", - "language", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2642( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("text", "text__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ClaimResponseTotal(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Adjudication totals. - Categorized monetary totals for the adjudication. - """ - - resource_type = Field("ClaimResponseTotal", const=True) - - amount: fhirtypes.MoneyType = Field( - ..., - alias="amount", - title="Financial total for the category", - description="Monetary total amount associated with the category.", - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.CodeableConceptType = Field( - ..., - alias="category", - title="Type of adjudication information", - description=( - "A code to indicate the information type of this adjudication record. " - "Information types may include: the value submitted, maximum values or " - "percentages allowed or payable under the plan, amounts that the " - "patient is responsible for in aggregate or pertaining to this item, " - "amounts paid by other coverages, and the benefit payable for this " - "item." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClaimResponseTotal`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "category", "amount"] diff --git a/fhir/resources/clinicalimpression.py b/fhir/resources/clinicalimpression.py deleted file mode 100644 index f9a709c8..00000000 --- a/fhir/resources/clinicalimpression.py +++ /dev/null @@ -1,557 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ClinicalImpression -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ClinicalImpression(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A clinical assessment performed when planning treatments and management - strategies for a patient. - A record of a clinical assessment performed to determine what problem(s) - may affect the patient and before planning the treatments or management - strategies that are best to manage a patient's condition. Assessments are - often 1:1 with a clinical consultation / encounter, but this varies - greatly depending on the clinical workflow. This resource is called - "ClinicalImpression" rather than "ClinicalAssessment" to avoid confusion - with the recording of assessment tools such as Apgar score. - """ - - resource_type = Field("ClinicalImpression", const=True) - - assessor: fhirtypes.ReferenceType = Field( - None, - alias="assessor", - title="The clinician performing the assessment", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Kind of assessment performed", - description="Categorizes the type of clinical assessment performed.", - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="When the assessment was documented", - description="Indicates when the documentation of the assessment was complete.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Why/how the assessment was performed", - description=( - "A summary of the context and/or cause of the assessment - why / where " - "it was performed, and what patient events/status prompted it." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - effectiveDateTime: fhirtypes.DateTime = Field( - None, - alias="effectiveDateTime", - title="Time of assessment", - description="The point in time or period over which the subject was assessed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=False, - ) - effectiveDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_effectiveDateTime", - title="Extension field for ``effectiveDateTime``.", - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="Time of assessment", - description="The point in time or period over which the subject was assessed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=False, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter created as part of", - description=( - "The Encounter during which this ClinicalImpression was created or to " - "which the creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - finding: typing.List[fhirtypes.ClinicalImpressionFindingType] = Field( - None, - alias="finding", - title="Possible or likely findings and diagnoses", - description=( - "Specific findings or diagnoses that were considered likely or relevant" - " to ongoing treatment." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier", - description=( - "Business identifiers assigned to this clinical impression by the " - "performer or other systems which remain constant as the resource is " - "updated and propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - investigation: typing.List[fhirtypes.ClinicalImpressionInvestigationType] = Field( - None, - alias="investigation", - title="One or more sets of investigations (signs, symptoms, etc.)", - description=( - "One or more sets of investigations (signs, symptoms, etc.). The actual" - " grouping of investigations varies greatly depending on the type and " - "context of the assessment. These investigations may include data " - "generated during the assessment process, or data previously generated " - "and recorded that is pertinent to the outcomes." - ), - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments made about the ClinicalImpression", - description=( - "Commentary about the impression, typically recorded after the " - "impression itself was made, though supplemental notes by the original " - "author could also appear." - ), - # if property is element of this resource. - element_property=True, - ) - - previous: fhirtypes.ReferenceType = Field( - None, - alias="previous", - title="Reference to last assessment", - description=( - "A reference to the last assessment that was conducted on this patient." - " Assessments are often/usually ongoing in nature; a care provider " - "(practitioner or team) will make new assessments on an ongoing basis " - "as new data arises or the patient's conditions changes." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ClinicalImpression"], - ) - - problem: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="problem", - title="Relevant impressions of patient state", - description="A list of the relevant problems/conditions for a patient.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition", "AllergyIntolerance"], - ) - - prognosisCodeableConcept: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="prognosisCodeableConcept", - title="Estimate of likely outcome", - description=None, - # if property is element of this resource. - element_property=True, - ) - - prognosisReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="prognosisReference", - title="RiskAssessment expressing likely outcome", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["RiskAssessment"], - ) - - protocol: typing.List[fhirtypes.Uri] = Field( - None, - alias="protocol", - title="Clinical Protocol followed", - description=( - "Reference to a specific published clinical protocol that was followed " - "during this assessment, and/or that provides evidence in support of " - "the diagnosis." - ), - # if property is element of this resource. - element_property=True, - ) - protocol__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_protocol", title="Extension field for ``protocol``.") - - status: fhirtypes.Code = Field( - None, - alias="status", - title="in-progress | completed | entered-in-error", - description="Identifies the workflow status of the assessment.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["in-progress", "completed", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReason: fhirtypes.CodeableConceptType = Field( - None, - alias="statusReason", - title="Reason for current status", - description="Captures the reason for the current state of the ClinicalImpression.", - # if property is element of this resource. - element_property=True, - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Patient or group assessed", - description="The patient or group of individuals assessed as part of this record.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - summary: fhirtypes.String = Field( - None, - alias="summary", - title="Summary of the assessment", - description="A text summary of the investigations and the diagnosis.", - # if property is element of this resource. - element_property=True, - ) - summary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_summary", title="Extension field for ``summary``." - ) - - supportingInfo: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingInfo", - title="Information supporting the clinical impression", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClinicalImpression`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "statusReason", - "code", - "description", - "subject", - "encounter", - "effectiveDateTime", - "effectivePeriod", - "date", - "assessor", - "previous", - "problem", - "investigation", - "protocol", - "summary", - "finding", - "prognosisCodeableConcept", - "prognosisReference", - "supportingInfo", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2041( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2041( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"effective": ["effectiveDateTime", "effectivePeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ClinicalImpressionFinding(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Possible or likely findings and diagnoses. - Specific findings or diagnoses that were considered likely or relevant to - ongoing treatment. - """ - - resource_type = Field("ClinicalImpressionFinding", const=True) - - basis: fhirtypes.String = Field( - None, - alias="basis", - title="Which investigations support finding", - description="Which investigations support finding or diagnosis.", - # if property is element of this resource. - element_property=True, - ) - basis__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_basis", title="Extension field for ``basis``." - ) - - itemCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="itemCodeableConcept", - title="What was found", - description=( - "Specific text or code for finding or diagnosis, which may include " - "ruled-out or resolved conditions." - ), - # if property is element of this resource. - element_property=True, - ) - - itemReference: fhirtypes.ReferenceType = Field( - None, - alias="itemReference", - title="What was found", - description=( - "Specific reference for finding or diagnosis, which may include ruled-" - "out or resolved conditions." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition", "Observation", "Media"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClinicalImpressionFinding`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "itemCodeableConcept", - "itemReference", - "basis", - ] - - -class ClinicalImpressionInvestigation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - One or more sets of investigations (signs, symptoms, etc.). - One or more sets of investigations (signs, symptoms, etc.). The actual - grouping of investigations varies greatly depending on the type and context - of the assessment. These investigations may include data generated during - the assessment process, or data previously generated and recorded that is - pertinent to the outcomes. - """ - - resource_type = Field("ClinicalImpressionInvestigation", const=True) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="A name/code for the set", - description=( - 'A name/code for the group ("set") of investigations. Typically, this ' - 'will be something like "signs", "symptoms", "clinical", "diagnostic", ' - "but the list is not constrained, and others such groups such as " - "(exposure|family|travel|nutritional) history may be used." - ), - # if property is element of this resource. - element_property=True, - ) - - item: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="item", - title="Record of a specific investigation", - description="A record of a specific investigation that was undertaken.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Observation", - "QuestionnaireResponse", - "FamilyMemberHistory", - "DiagnosticReport", - "RiskAssessment", - "ImagingStudy", - "Media", - ], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ClinicalImpressionInvestigation`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "item"] diff --git a/fhir/resources/codeableconcept.py b/fhir/resources/codeableconcept.py deleted file mode 100644 index a2de4fc0..00000000 --- a/fhir/resources/codeableconcept.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CodeableConcept -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import element, fhirtypes - - -class CodeableConcept(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Concept - reference to a terminology or just text. - A concept that may be defined by a formal reference to a terminology or - ontology or may be provided by text. - """ - - resource_type = Field("CodeableConcept", const=True) - - coding: typing.List[fhirtypes.CodingType] = Field( - None, - alias="coding", - title="Code defined by a terminology system", - description="A reference to a code defined by a terminology system.", - # if property is element of this resource. - element_property=True, - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Plain text representation of the concept", - description=( - "A human language representation of the concept as " - "seen/selected/uttered by the user who entered the data and/or which " - "represents the intended meaning of the user." - ), - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CodeableConcept`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "coding", "text"] diff --git a/fhir/resources/codesystem.py b/fhir/resources/codesystem.py deleted file mode 100644 index 381e0520..00000000 --- a/fhir/resources/codesystem.py +++ /dev/null @@ -1,1409 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CodeSystem -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class CodeSystem(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Declares the existence of and describes a code system or code system - supplement. - The CodeSystem resource is used to declare the existence of and describe a - code system or code system supplement and its key properties, and - optionally define a part or all of its content. - """ - - resource_type = Field("CodeSystem", const=True) - - caseSensitive: bool = Field( - None, - alias="caseSensitive", - title="If code comparison is case sensitive", - description=( - "If code comparison is case sensitive when codes within this system are" - " compared to each other." - ), - # if property is element of this resource. - element_property=True, - ) - caseSensitive__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_caseSensitive", title="Extension field for ``caseSensitive``." - ) - - compositional: bool = Field( - None, - alias="compositional", - title="If code system defines a compositional grammar", - description="The code system defines a compositional (post-coordination) grammar.", - # if property is element of this resource. - element_property=True, - ) - compositional__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_compositional", title="Extension field for ``compositional``." - ) - - concept: typing.List[fhirtypes.CodeSystemConceptType] = Field( - None, - alias="concept", - title="Concepts in the code system", - description=( - "Concepts that are in the code system. The concept definitions are " - "inherently hierarchical, but the definitions must be consulted to " - "determine what the meanings of the hierarchical relationships are." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - content: fhirtypes.Code = Field( - None, - alias="content", - title="not-present | example | fragment | complete | supplement", - description=( - "The extent of the content of the code system (the concepts and codes " - "it defines) are represented in this resource instance." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["not-present", "example", "fragment", "complete", "supplement"], - ) - content__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_content", title="Extension field for ``content``." - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the code system and/or its contents." - " Copyright statements are generally legal restrictions on the use and " - "publishing of the code system." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - count: fhirtypes.UnsignedInt = Field( - None, - alias="count", - title="Total concepts in the code system", - description=( - "The total number of concepts defined by the code system. Where the " - "code system has a compositional grammar, the basis of this count is " - "defined by the system steward." - ), - # if property is element of this resource. - element_property=True, - ) - count__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_count", title="Extension field for ``count``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the code system was published. " - "The date must change when the business version changes and it must " - "change if the status code changes. In addition, it should change when " - "the substantive content of the code system changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the code system", - description=( - "A free text natural language description of the code system from a " - "consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this code system is authored for " - "testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - filter: typing.List[fhirtypes.CodeSystemFilterType] = Field( - None, - alias="filter", - title="Filter that can be used in a value set", - description=( - "A filter that can be used in a value set compose statement when " - "selecting concepts using a filter." - ), - # if property is element of this resource. - element_property=True, - ) - - hierarchyMeaning: fhirtypes.Code = Field( - None, - alias="hierarchyMeaning", - title="grouped-by | is-a | part-of | classified-with", - description=( - "The meaning of the hierarchy of concepts as represented in this " - "resource." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["grouped-by", "is-a", "part-of", "classified-with"], - ) - hierarchyMeaning__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_hierarchyMeaning", - title="Extension field for ``hierarchyMeaning``.", - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the code system (business identifier)", - description=( - "A formal identifier that is used to identify this code system when it " - "is represented in other formats, or referenced in a specification, " - "model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for code system (if applicable)", - description=( - "A legal or geographic region in which the code system is intended to " - "be used." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this code system (computer friendly)", - description=( - "A natural language name identifying the code system. This name should " - "be usable as an identifier for the module by machine processing " - "applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - property: typing.List[fhirtypes.CodeSystemPropertyType] = Field( - None, - alias="property", - title="Additional information supplied about each concept", - description=( - "A property defines an additional slot through which additional " - "information can be provided about a concept." - ), - # if property is element of this resource. - element_property=True, - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the code " - "system." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this code system is defined", - description=( - "Explanation of why this code system is needed and why it has been " - "designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The date (and optionally time) when the code system resource was " - "created or revised." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - supplements: fhirtypes.Canonical = Field( - None, - alias="supplements", - title="Canonical URL of Code System this adds designations and properties to", - description=( - "The canonical URL of the code system that this code system supplement " - "is adding designations and properties to." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CodeSystem"], - ) - supplements__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_supplements", title="Extension field for ``supplements``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this code system (human friendly)", - description="A short, descriptive, user-friendly title for the code system.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this code system, represented as a URI " - "(globally unique) (Coding.system)" - ), - description=( - "An absolute URI that is used to identify this code system when it is " - "referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this code system is (or will be) published. This URL can " - "be the target of a canonical reference. It SHALL remain the same when " - "the code system is stored on different servers. This is used in " - "[Coding](datatypes.html#Coding).system." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate code system instances." - ), - # if property is element of this resource. - element_property=True, - ) - - valueSet: fhirtypes.Canonical = Field( - None, - alias="valueSet", - title="Canonical reference to the value set with entire code system", - description=( - "Canonical reference to the value set that contains the entire code " - "system." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - valueSet__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueSet", title="Extension field for ``valueSet``." - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the code system (Coding.version)", - description=( - "The identifier that is used to identify this version of the code " - "system when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the code system author" - " and is not expected to be globally unique. For example, it might be a" - " timestamp (e.g. yyyymmdd) if a managed version is not available. " - "There is also no expectation that versions can be placed in a " - "lexicographical sequence. This is used in " - "[Coding](datatypes.html#Coding).version." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - versionNeeded: bool = Field( - None, - alias="versionNeeded", - title="If definitions are not stable", - description=( - "This flag is used to signify that the code system does not commit to " - "concept permanence across versions. If true, a version must be " - "specified when referencing this code system." - ), - # if property is element of this resource. - element_property=True, - ) - versionNeeded__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_versionNeeded", title="Extension field for ``versionNeeded``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CodeSystem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "copyright", - "caseSensitive", - "valueSet", - "hierarchyMeaning", - "compositional", - "versionNeeded", - "content", - "supplements", - "count", - "filter", - "property", - "concept", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1200( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("content", "content__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CodeSystemConcept(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Concepts in the code system. - Concepts that are in the code system. The concept definitions are - inherently hierarchical, but the definitions must be consulted to determine - what the meanings of the hierarchical relationships are. - """ - - resource_type = Field("CodeSystemConcept", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Code that identifies concept", - description=( - "A code - a text symbol - that uniquely identifies the concept within " - "the code system." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - concept: typing.List[fhirtypes.CodeSystemConceptType] = Field( - None, - alias="concept", - title="Child Concepts (is-a/contains/categorizes)", - description=( - "Defines children of a concept to produce a hierarchy of concepts. The " - "nature of the relationships is variable (is-a/contains/categorizes) - " - "see hierarchyMeaning." - ), - # if property is element of this resource. - element_property=True, - ) - - definition: fhirtypes.String = Field( - None, - alias="definition", - title="Formal definition", - description=( - "The formal definition of the concept. The code system resource does " - "not make formal definitions required, because of the prevalence of " - "legacy systems. However, they are highly recommended, as without them " - "there is no formal meaning associated with the concept." - ), - # if property is element of this resource. - element_property=True, - ) - definition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_definition", title="Extension field for ``definition``." - ) - - designation: typing.List[fhirtypes.CodeSystemConceptDesignationType] = Field( - None, - alias="designation", - title="Additional representations for the concept", - description=( - "Additional representations for the concept - other languages, aliases," - " specialized purposes, used for particular purposes, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - display: fhirtypes.String = Field( - None, - alias="display", - title="Text to display to the user", - description=( - "A human readable string that is the recommended default way to present" - " this concept to a user." - ), - # if property is element of this resource. - element_property=True, - ) - display__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_display", title="Extension field for ``display``." - ) - - property: typing.List[fhirtypes.CodeSystemConceptPropertyType] = Field( - None, - alias="property", - title="Property value for the concept", - description="A property value for this concept.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CodeSystemConcept`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "display", - "definition", - "designation", - "property", - "concept", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1923( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CodeSystemConceptDesignation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Additional representations for the concept. - Additional representations for the concept - other languages, aliases, - specialized purposes, used for particular purposes, etc. - """ - - resource_type = Field("CodeSystemConceptDesignation", const=True) - - language: fhirtypes.Code = Field( - None, - alias="language", - title="Human language of the designation", - description="The language this designation is defined for.", - # if property is element of this resource. - element_property=True, - ) - language__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_language", title="Extension field for ``language``." - ) - - use: fhirtypes.CodingType = Field( - None, - alias="use", - title="Details how this designation would be used", - description="A code that details how this designation would be used.", - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="The text value for this designation", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CodeSystemConceptDesignation`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "language", "use", "value"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3058( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("value", "value__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CodeSystemConceptProperty(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Property value for the concept. - A property value for this concept. - """ - - resource_type = Field("CodeSystemConceptProperty", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Reference to CodeSystem.property.code", - description="A code that is a reference to CodeSystem.property.code.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Value of the property for this concept", - description="The value of this property.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCode: fhirtypes.Code = Field( - None, - alias="valueCode", - title="Value of the property for this concept", - description="The value of this property.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueCode", title="Extension field for ``valueCode``." - ) - - valueCoding: fhirtypes.CodingType = Field( - None, - alias="valueCoding", - title="Value of the property for this concept", - description="The value of this property.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="Value of the property for this concept", - description="The value of this property.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueDecimal: fhirtypes.Decimal = Field( - None, - alias="valueDecimal", - title="Value of the property for this concept", - description="The value of this property.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDecimal", title="Extension field for ``valueDecimal``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Value of the property for this concept", - description="The value of this property.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Value of the property for this concept", - description="The value of this property.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CodeSystemConceptProperty`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "valueCode", - "valueCoding", - "valueString", - "valueInteger", - "valueBoolean", - "valueDateTime", - "valueDecimal", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2797( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2797( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueBoolean", - "valueCode", - "valueCoding", - "valueDateTime", - "valueDecimal", - "valueInteger", - "valueString", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class CodeSystemFilter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Filter that can be used in a value set. - A filter that can be used in a value set compose statement when selecting - concepts using a filter. - """ - - resource_type = Field("CodeSystemFilter", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Code that identifies the filter", - description=( - "The code that identifies this filter when it is used as a filter in " - "[ValueSet](valueset.html#).compose.include.filter." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="How or why the filter is used", - description="A description of how or why the filter is used.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - operator: typing.List[fhirtypes.Code] = Field( - None, - alias="operator", - title=( - "= | is-a | descendent-of | is-not-a | regex | in | not-in | " - "generalizes | exists" - ), - description="A list of operators that can be used with the filter.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "=", - "is-a", - "descendent-of", - "is-not-a", - "regex", - "in", - "not-in", - "generalizes", - "exists", - ], - ) - operator__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_operator", title="Extension field for ``operator``.") - - value: fhirtypes.String = Field( - None, - alias="value", - title="What to use for the value", - description="A description of what the value for the filter should be.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CodeSystemFilter`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "description", - "operator", - "value", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1819( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("code", "code__ext"), - ("operator", "operator__ext"), - ("value", "value__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CodeSystemProperty(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Additional information supplied about each concept. - A property defines an additional slot through which additional information - can be provided about a concept. - """ - - resource_type = Field("CodeSystemProperty", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title=( - "Identifies the property on the concepts, and when referred to in " - "operations" - ), - description=( - "A code that is used to identify the property. The code is used " - "internally (in CodeSystem.concept.property.code) and also externally, " - "such as in property filters." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Why the property is defined, and/or what it conveys", - description=( - "A description of the property- why it is defined, and how its value " - "might be used." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="code | Coding | string | integer | boolean | dateTime | decimal", - description=( - 'The type of the property value. Properties of type "code" contain a ' - "code defined by the code system (e.g. a reference to another defined " - "concept)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "code", - "Coding", - "string", - "integer", - "boolean", - "dateTime", - "decimal", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - uri: fhirtypes.Uri = Field( - None, - alias="uri", - title="Formal identifier for the property", - description=( - "Reference to the formal meaning of the property. One possible source " - "of meaning is the [Concept Properties](codesystem-concept-" - "properties.html) code system." - ), - # if property is element of this resource. - element_property=True, - ) - uri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_uri", title="Extension field for ``uri``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CodeSystemProperty`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "uri", - "description", - "type", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2081( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/coding.py b/fhir/resources/coding.py deleted file mode 100644 index 969f0a34..00000000 --- a/fhir/resources/coding.py +++ /dev/null @@ -1,117 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Coding -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import element, fhirtypes - - -class Coding(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A reference to a code defined by a terminology system. - """ - - resource_type = Field("Coding", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Symbol in syntax defined by the system", - description=( - "A symbol in syntax defined by the system. The symbol may be a " - "predefined code or an expression in a syntax defined by the coding " - "system (e.g. post-coordination)." - ), - # if property is element of this resource. - element_property=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - display: fhirtypes.String = Field( - None, - alias="display", - title="Representation defined by the system", - description=( - "A representation of the meaning of the code in the system, following " - "the rules of the system." - ), - # if property is element of this resource. - element_property=True, - ) - display__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_display", title="Extension field for ``display``." - ) - - system: fhirtypes.Uri = Field( - None, - alias="system", - title="Identity of the terminology system", - description=( - "The identification of the code system that defines the meaning of the " - "symbol in the code." - ), - # if property is element of this resource. - element_property=True, - ) - system__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_system", title="Extension field for ``system``." - ) - - userSelected: bool = Field( - None, - alias="userSelected", - title="If this coding was chosen directly by the user", - description=( - "Indicates that this coding was chosen by a user directly - e.g. off a " - "pick list of available items (codes or displays)." - ), - # if property is element of this resource. - element_property=True, - ) - userSelected__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_userSelected", title="Extension field for ``userSelected``." - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Version of the system - if relevant", - description=( - "The version of the code system which was used when choosing this code." - " Note that a well-maintained code system does not need the version " - "reported, because the meaning of codes is consistent across versions. " - "However this cannot consistently be assured, and when the meaning is " - "not guaranteed to be consistent, the version SHOULD be exchanged." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Coding`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "system", - "version", - "code", - "display", - "userSelected", - ] diff --git a/fhir/resources/communication.py b/fhir/resources/communication.py deleted file mode 100644 index ca837a9f..00000000 --- a/fhir/resources/communication.py +++ /dev/null @@ -1,594 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Communication -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Communication(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A record of information transmitted from a sender to a receiver. - An occurrence of information being transmitted; e.g. an alert that was sent - to a responsible provider, a public health agency that was notified about a - reportable condition. - """ - - resource_type = Field("Communication", const=True) - - about: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="about", - title="Resources that pertain to this communication", - description=( - "Other resources that pertain to this communication and to which this " - "communication should be associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Request fulfilled by this communication", - description=( - "An order, proposal or plan fulfilled in whole or in part by this " - "Communication." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Message category", - description=( - "The type of message conveyed such as alert, notification, reminder, " - "instruction, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter created as part of", - description=( - "The Encounter during which this Communication was created or to which " - "the creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Unique identifier", - description=( - "Business identifiers assigned to this communication by the performer " - "or other systems which remain constant as the resource is updated and " - "propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - inResponseTo: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="inResponseTo", - title="Reply to", - description="Prior communication that this communication is in response to.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Communication"], - ) - - instantiatesCanonical: typing.List[fhirtypes.Canonical] = Field( - None, - alias="instantiatesCanonical", - title="Instantiates FHIR protocol or definition", - description=( - "The URL pointing to a FHIR-defined protocol, guideline, orderset or " - "other definition that is adhered to in whole or in part by this " - "Communication." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "PlanDefinition", - "ActivityDefinition", - "Measure", - "OperationDefinition", - "Questionnaire", - ], - ) - instantiatesCanonical__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_instantiatesCanonical", - title="Extension field for ``instantiatesCanonical``.", - ) - - instantiatesUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiatesUri", - title="Instantiates external protocol or definition", - description=( - "The URL pointing to an externally maintained protocol, guideline, " - "orderset or other definition that is adhered to in whole or in part by" - " this Communication." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - medium: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="medium", - title="A channel of communication", - description="A channel that was used for this communication (e.g. email, fax).", - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments made about the communication", - description=( - "Additional notes or commentary about the communication by the sender, " - "receiver or other interested parties." - ), - # if property is element of this resource. - element_property=True, - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Part of this action", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - payload: typing.List[fhirtypes.CommunicationPayloadType] = Field( - None, - alias="payload", - title="Message payload", - description=( - "Text, attachment(s), or resource(s) that was communicated to the " - "recipient." - ), - # if property is element of this resource. - element_property=True, - ) - - priority: fhirtypes.Code = Field( - None, - alias="priority", - title="routine | urgent | asap | stat", - description=( - "Characterizes how quickly the planned or in progress communication " - "must be addressed. Includes concepts such as stat, urgent, routine." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["routine", "urgent", "asap", "stat"], - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Indication for message", - description="The reason or justification for the communication.", - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why was communication done?", - description=( - "Indicates another resource whose existence justifies this " - "communication." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "DiagnosticReport", - "DocumentReference", - ], - ) - - received: fhirtypes.DateTime = Field( - None, - alias="received", - title="When received", - description="The time when this communication arrived at the destination.", - # if property is element of this resource. - element_property=True, - ) - received__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_received", title="Extension field for ``received``." - ) - - recipient: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="recipient", - title="Message recipient", - description=( - "The entity (e.g. person, organization, clinical information system, " - "care team or device) which was the target of the communication. If " - "receipts need to be tracked by an individual, a separate resource " - "instance will need to be created for each recipient. Multiple " - "recipient communications are intended where either receipts are not " - "tracked (e.g. a mass mail-out) or a receipt is captured in aggregate " - "(all emails confirmed received by a particular time)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Device", - "Organization", - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Group", - "CareTeam", - "HealthcareService", - ], - ) - - sender: fhirtypes.ReferenceType = Field( - None, - alias="sender", - title="Message sender", - description=( - "The entity (e.g. person, organization, clinical information system, or" - " device) which was the source of the communication." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Device", - "Organization", - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "HealthcareService", - ], - ) - - sent: fhirtypes.DateTime = Field( - None, - alias="sent", - title="When sent", - description="The time when this communication was sent.", - # if property is element of this resource. - element_property=True, - ) - sent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sent", title="Extension field for ``sent``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "preparation | in-progress | not-done | on-hold | stopped | completed |" - " entered-in-error | unknown" - ), - description="The status of the transmission.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "preparation", - "in-progress", - "not-done", - "on-hold", - "stopped", - "completed", - "entered-in-error", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReason: fhirtypes.CodeableConceptType = Field( - None, - alias="statusReason", - title="Reason for current status", - description="Captures the reason for the current state of the Communication.", - # if property is element of this resource. - element_property=True, - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Focus of message", - description="The patient or group that was the focus of this communication.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - topic: fhirtypes.CodeableConceptType = Field( - None, - alias="topic", - title="Description of the purpose/content", - description=( - "Description of the purpose/content, similar to a subject line in an " - "email." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Communication`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "instantiatesCanonical", - "instantiatesUri", - "basedOn", - "partOf", - "inResponseTo", - "status", - "statusReason", - "category", - "priority", - "medium", - "subject", - "topic", - "about", - "encounter", - "sent", - "received", - "recipient", - "sender", - "reasonCode", - "reasonReference", - "payload", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1543( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CommunicationPayload(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Message payload. - Text, attachment(s), or resource(s) that was communicated to the recipient. - """ - - resource_type = Field("CommunicationPayload", const=True) - - contentAttachment: fhirtypes.AttachmentType = Field( - None, - alias="contentAttachment", - title="Message part content", - description=( - "A communicated content (or for multi-part communications, one portion " - "of the communication)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - ) - - contentReference: fhirtypes.ReferenceType = Field( - None, - alias="contentReference", - title="Message part content", - description=( - "A communicated content (or for multi-part communications, one portion " - "of the communication)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - contentString: fhirtypes.String = Field( - None, - alias="contentString", - title="Message part content", - description=( - "A communicated content (or for multi-part communications, one portion " - "of the communication)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - ) - contentString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_contentString", title="Extension field for ``contentString``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CommunicationPayload`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "contentString", - "contentAttachment", - "contentReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2247( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "content": ["contentAttachment", "contentReference", "contentString"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/communicationrequest.py b/fhir/resources/communicationrequest.py deleted file mode 100644 index f4aa5d67..00000000 --- a/fhir/resources/communicationrequest.py +++ /dev/null @@ -1,627 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CommunicationRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class CommunicationRequest(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A request for information to be sent to a receiver. - A request to convey information; e.g. the CDS system proposes that an alert - be sent to a responsible provider, the CDS system proposes that the public - health agency be notified about a reportable condition. - """ - - resource_type = Field("CommunicationRequest", const=True) - - about: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="about", - title="Resources that pertain to this communication request", - description=( - "Other resources that pertain to this communication request and to " - "which this communication request should be associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - authoredOn: fhirtypes.DateTime = Field( - None, - alias="authoredOn", - title="When request transitioned to being actionable", - description=( - "For draft requests, indicates the date of initial creation. For " - "requests with other statuses, indicates the date of activation." - ), - # if property is element of this resource. - element_property=True, - ) - authoredOn__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_authoredOn", title="Extension field for ``authoredOn``." - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Fulfills plan or proposal", - description=( - "A plan or proposal that is fulfilled in whole or in part by this " - "request." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Message category", - description=( - "The type of message to be sent such as alert, notification, reminder, " - "instruction, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - doNotPerform: bool = Field( - None, - alias="doNotPerform", - title="True if request is prohibiting action", - description=( - "If true indicates that the CommunicationRequest is asking for the " - "specified action to *not* occur." - ), - # if property is element of this resource. - element_property=True, - ) - doNotPerform__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_doNotPerform", title="Extension field for ``doNotPerform``." - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter created as part of", - description=( - "The Encounter during which this CommunicationRequest was created or to" - " which the creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - groupIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="groupIdentifier", - title="Composite request this is part of", - description=( - "A shared identifier common to all requests that were authorized more " - "or less simultaneously by a single author, representing the identifier" - " of the requisition, prescription or similar form." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Unique identifier", - description=( - "Business identifiers assigned to this communication request by the " - "performer or other systems which remain constant as the resource is " - "updated and propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - medium: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="medium", - title="A channel of communication", - description="A channel that was used for this communication (e.g. email, fax).", - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments made about communication request", - description=( - "Comments made about the request by the requester, sender, recipient, " - "subject or other participants." - ), - # if property is element of this resource. - element_property=True, - ) - - occurrenceDateTime: fhirtypes.DateTime = Field( - None, - alias="occurrenceDateTime", - title="When scheduled", - description="The time when this communication is to occur.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - occurrenceDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurrenceDateTime", - title="Extension field for ``occurrenceDateTime``.", - ) - - occurrencePeriod: fhirtypes.PeriodType = Field( - None, - alias="occurrencePeriod", - title="When scheduled", - description="The time when this communication is to occur.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - payload: typing.List[fhirtypes.CommunicationRequestPayloadType] = Field( - None, - alias="payload", - title="Message payload", - description=( - "Text, attachment(s), or resource(s) to be communicated to the " - "recipient." - ), - # if property is element of this resource. - element_property=True, - ) - - priority: fhirtypes.Code = Field( - None, - alias="priority", - title="routine | urgent | asap | stat", - description=( - "Characterizes how quickly the proposed act must be initiated. Includes" - " concepts such as stat, urgent, routine." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["routine", "urgent", "asap", "stat"], - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why is communication needed?", - description="Describes why the request is being made in coded or textual form.", - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why is communication needed?", - description="Indicates another resource whose existence justifies this request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "DiagnosticReport", - "DocumentReference", - ], - ) - - recipient: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="recipient", - title="Message recipient", - description=( - "The entity (e.g. person, organization, clinical information system, " - "device, group, or care team) which is the intended target of the " - "communication." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Device", - "Organization", - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Group", - "CareTeam", - "HealthcareService", - ], - ) - - replaces: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="replaces", - title="Request(s) replaced by this request", - description=( - "Completed or terminated request(s) whose function is taken by this new" - " request." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CommunicationRequest"], - ) - - requester: fhirtypes.ReferenceType = Field( - None, - alias="requester", - title="Who/what is requesting service", - description=( - "The device, individual, or organization who initiated the request and " - "has responsibility for its activation." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Patient", - "RelatedPerson", - "Device", - ], - ) - - sender: fhirtypes.ReferenceType = Field( - None, - alias="sender", - title="Message sender", - description=( - "The entity (e.g. person, organization, clinical information system, or" - " device) which is to be the source of the communication." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Device", - "Organization", - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "HealthcareService", - ], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "draft | active | on-hold | revoked | completed | entered-in-error | " - "unknown" - ), - description="The status of the proposal or order.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "draft", - "active", - "on-hold", - "revoked", - "completed", - "entered-in-error", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReason: fhirtypes.CodeableConceptType = Field( - None, - alias="statusReason", - title="Reason for current status", - description="Captures the reason for the current state of the CommunicationRequest.", - # if property is element of this resource. - element_property=True, - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Focus of message", - description="The patient or group that is the focus of this communication request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CommunicationRequest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "basedOn", - "replaces", - "groupIdentifier", - "status", - "statusReason", - "category", - "priority", - "doNotPerform", - "medium", - "subject", - "about", - "encounter", - "payload", - "occurrenceDateTime", - "occurrencePeriod", - "authoredOn", - "requester", - "recipient", - "sender", - "reasonCode", - "reasonReference", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2294( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2294( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"occurrence": ["occurrenceDateTime", "occurrencePeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class CommunicationRequestPayload(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Message payload. - Text, attachment(s), or resource(s) to be communicated to the recipient. - """ - - resource_type = Field("CommunicationRequestPayload", const=True) - - contentAttachment: fhirtypes.AttachmentType = Field( - None, - alias="contentAttachment", - title="Message part content", - description=( - "The communicated content (or for multi-part communications, one " - "portion of the communication)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - ) - - contentReference: fhirtypes.ReferenceType = Field( - None, - alias="contentReference", - title="Message part content", - description=( - "The communicated content (or for multi-part communications, one " - "portion of the communication)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - contentString: fhirtypes.String = Field( - None, - alias="contentString", - title="Message part content", - description=( - "The communicated content (or for multi-part communications, one " - "portion of the communication)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - ) - contentString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_contentString", title="Extension field for ``contentString``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CommunicationRequestPayload`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "contentString", - "contentAttachment", - "contentReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2992( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "content": ["contentAttachment", "contentReference", "contentString"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/compartmentdefinition.py b/fhir/resources/compartmentdefinition.py deleted file mode 100644 index 4fd390b4..00000000 --- a/fhir/resources/compartmentdefinition.py +++ /dev/null @@ -1,477 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CompartmentDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class CompartmentDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Compartment Definition for a resource. - A compartment definition that defines how resources are accessed on a - server. - """ - - resource_type = Field("CompartmentDefinition", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Patient | Encounter | RelatedPerson | Practitioner | Device", - description="Which compartment this definition describes.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["Patient", "Encounter", "RelatedPerson", "Practitioner", "Device"], - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the compartment definition was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the compartment definition " - "changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the compartment definition", - description=( - "A free text natural language description of the compartment definition" - " from a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this compartment definition is " - "authored for testing purposes (or education/evaluation/marketing) and " - "is not intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this compartment definition (computer friendly)", - description=( - "A natural language name identifying the compartment definition. This " - "name should be usable as an identifier for the module by machine " - "processing applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the " - "compartment definition." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this compartment definition is defined", - description=( - "Explanation of why this compartment definition is needed and why it " - "has been designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - resource: typing.List[fhirtypes.CompartmentDefinitionResourceType] = Field( - None, - alias="resource", - title="How a resource is related to the compartment", - description="Information about how a resource is related to the compartment.", - # if property is element of this resource. - element_property=True, - ) - - search: bool = Field( - None, - alias="search", - title="Whether the search syntax is supported", - description="Whether the search syntax is supported,.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - search__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_search", title="Extension field for ``search``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this compartment definition. Enables tracking the life-" - "cycle of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this compartment definition, represented as a" - " URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this compartment definition " - "when it is referenced in a specification, model, design or an " - "instance; also called its canonical identifier. This SHOULD be " - "globally unique and SHOULD be a literal address at which at which an " - "authoritative instance of this compartment definition is (or will be) " - "published. This URL can be the target of a canonical reference. It " - "SHALL remain the same when the compartment definition is stored on " - "different servers." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate compartment definition " - "instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the compartment definition", - description=( - "The identifier that is used to identify this version of the " - "compartment definition when it is referenced in a specification, " - "model, design or instance. This is an arbitrary value managed by the " - "compartment definition author and is not expected to be globally " - "unique. For example, it might be a timestamp (e.g. yyyymmdd) if a " - "managed version is not available. There is also no expectation that " - "versions can be placed in a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CompartmentDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "version", - "name", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "purpose", - "code", - "search", - "resource", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2372( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("code", "code__ext"), - ("name", "name__ext"), - ("search", "search__ext"), - ("status", "status__ext"), - ("url", "url__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CompartmentDefinitionResource(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - How a resource is related to the compartment. - Information about how a resource is related to the compartment. - """ - - resource_type = Field("CompartmentDefinitionResource", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Name of resource type", - description="The name of a resource supported by the server.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - documentation: fhirtypes.String = Field( - None, - alias="documentation", - title="Additional documentation about the resource and compartment", - description=None, - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - param: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="param", - title="Search Parameter Name, or chained parameters", - description=( - "The name of a search parameter that represents the link to the " - "compartment. More than one may be listed because a resource may be " - "linked to a compartment in more than one way,." - ), - # if property is element of this resource. - element_property=True, - ) - param__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_param", title="Extension field for ``param``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CompartmentDefinitionResource`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "param", - "documentation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3203( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/composition.py b/fhir/resources/composition.py deleted file mode 100644 index 7278160f..00000000 --- a/fhir/resources/composition.py +++ /dev/null @@ -1,884 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Composition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Composition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A set of resources composed into a single coherent clinical statement with - clinical attestation. - A set of healthcare-related information that is assembled together into a - single logical package that provides a single coherent statement of - meaning, establishes its own context and that has clinical attestation with - regard to who is making the statement. A Composition defines the structure - and narrative content necessary for a document. However, a Composition - alone does not constitute a document. Rather, the Composition must be the - first entry in a Bundle where Bundle.type=document, and any other resources - referenced from Composition must be included as subsequent entries in the - Bundle (for example Patient, Practitioner, Encounter, etc.). - """ - - resource_type = Field("Composition", const=True) - - attester: typing.List[fhirtypes.CompositionAttesterType] = Field( - None, - alias="attester", - title="Attests to accuracy of composition", - description=( - "A participant who has attested to the accuracy of the " - "composition/document." - ), - # if property is element of this resource. - element_property=True, - ) - - author: typing.List[fhirtypes.ReferenceType] = Field( - ..., - alias="author", - title="Who and/or what authored the composition", - description=( - "Identifies who is responsible for the information in the composition, " - "not necessarily who typed it in." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Device", - "Patient", - "RelatedPerson", - "Organization", - ], - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Categorization of Composition", - description=( - "A categorization for the type of the composition - helps for indexing " - "and searching. This may be implied by or derived from the code " - "specified in the Composition Type." - ), - # if property is element of this resource. - element_property=True, - ) - - confidentiality: fhirtypes.Code = Field( - None, - alias="confidentiality", - title="As defined by affinity domain", - description="The code specifying the level of confidentiality of the Composition.", - # if property is element of this resource. - element_property=True, - ) - confidentiality__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_confidentiality", title="Extension field for ``confidentiality``." - ) - - custodian: fhirtypes.ReferenceType = Field( - None, - alias="custodian", - title="Organization which maintains the composition", - description=( - "Identifies the organization or group who is responsible for ongoing " - "maintenance of and access to the composition/document information." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Composition editing time", - description=( - "The composition editing time, when the composition was last logically " - "changed by the author." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Context of the Composition", - description=( - "Describes the clinical encounter or type of care this documentation is" - " associated with." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - event: typing.List[fhirtypes.CompositionEventType] = Field( - None, - alias="event", - title="The clinical service(s) being documented", - description=( - "The clinical service, such as a colonoscopy or an appendectomy, being " - "documented." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Version-independent identifier for the Composition", - description=( - "A version-independent identifier for the Composition. This identifier " - "stays constant as the composition is changed over time." - ), - # if property is element of this resource. - element_property=True, - ) - - relatesTo: typing.List[fhirtypes.CompositionRelatesToType] = Field( - None, - alias="relatesTo", - title="Relationships to other compositions/documents", - description=( - "Relationships that this composition has with other compositions or " - "documents that already exist." - ), - # if property is element of this resource. - element_property=True, - ) - - section: typing.List[fhirtypes.CompositionSectionType] = Field( - None, - alias="section", - title="Composition is broken into sections", - description="The root of the sections that make up the composition.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="preliminary | final | amended | entered-in-error", - description=( - "The workflow/clinical status of this composition. The status is a " - "marker for the clinical standing of the document." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["preliminary", "final", "amended", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Who and/or what the composition is about", - description=( - "Who or what the composition is about. The composition can be about a " - "person, (patient or healthcare practitioner), a device (e.g. a " - "machine) or even a group of subjects (such as a document about a herd " - "of livestock, or a set of patients that share a common exposure)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Human Readable name/title", - description="Official human-readable label for the composition.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Kind of composition (LOINC if possible)", - description=( - "Specifies the particular kind of composition (e.g. History and " - "Physical, Discharge Summary, Progress Note). This usually equates to " - "the purpose of making the composition." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Composition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "type", - "category", - "subject", - "encounter", - "date", - "author", - "title", - "confidentiality", - "attester", - "custodian", - "relatesTo", - "event", - "section", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1349( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("date", "date__ext"), - ("status", "status__ext"), - ("title", "title__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CompositionAttester(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Attests to accuracy of composition. - A participant who has attested to the accuracy of the composition/document. - """ - - resource_type = Field("CompositionAttester", const=True) - - mode: fhirtypes.Code = Field( - None, - alias="mode", - title="personal | professional | legal | official", - description="The type of attestation the authenticator offers.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["personal", "professional", "legal", "official"], - ) - mode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mode", title="Extension field for ``mode``." - ) - - party: fhirtypes.ReferenceType = Field( - None, - alias="party", - title="Who attested the composition", - description="Who attested the composition in the specified way.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "RelatedPerson", - "Practitioner", - "PractitionerRole", - "Organization", - ], - ) - - time: fhirtypes.DateTime = Field( - None, - alias="time", - title="When the composition was attested", - description="When the composition was attested by the party.", - # if property is element of this resource. - element_property=True, - ) - time__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_time", title="Extension field for ``time``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CompositionAttester`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "mode", "time", "party"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2197( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("mode", "mode__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CompositionEvent(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The clinical service(s) being documented. - The clinical service, such as a colonoscopy or an appendectomy, being - documented. - """ - - resource_type = Field("CompositionEvent", const=True) - - code: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="code", - title="Code(s) that apply to the event being documented", - description=( - "This list of codes represents the main clinical acts, such as a " - "colonoscopy or an appendectomy, being documented. In some cases, the " - 'event is inherent in the typeCode, such as a "History and Physical ' - 'Report" in which the procedure being documented is necessarily a ' - '"History and Physical" act.' - ), - # if property is element of this resource. - element_property=True, - ) - - detail: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="detail", - title="The event(s) being documented", - description=( - "The description and/or reference of the event(s) being documented. For" - " example, this could be used to document such a colonoscopy or an " - "appendectomy." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="The period covered by the documentation", - description=( - "The period of time covered by the documentation. There is no assertion" - " that the documentation is a complete representation for this period, " - "only that it documents events during this time." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CompositionEvent`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "period", "detail"] - - -class CompositionRelatesTo(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Relationships to other compositions/documents. - Relationships that this composition has with other compositions or - documents that already exist. - """ - - resource_type = Field("CompositionRelatesTo", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="replaces | transforms | signs | appends", - description=( - "The type of relationship that this composition has with anther " - "composition or document." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["replaces", "transforms", "signs", "appends"], - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - targetIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="targetIdentifier", - title="Target of the relationship", - description="The target composition/document of this relationship.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e target[x] - one_of_many="target", - one_of_many_required=True, - ) - - targetReference: fhirtypes.ReferenceType = Field( - None, - alias="targetReference", - title="Target of the relationship", - description="The target composition/document of this relationship.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e target[x] - one_of_many="target", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Composition"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CompositionRelatesTo`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "targetIdentifier", - "targetReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2265( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2265( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"target": ["targetIdentifier", "targetReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class CompositionSection(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Composition is broken into sections. - The root of the sections that make up the composition. - """ - - resource_type = Field("CompositionSection", const=True) - - author: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="author", - title="Who and/or what authored the section", - description=( - "Identifies who is responsible for the information in this section, not" - " necessarily who typed it in." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Device", - "Patient", - "RelatedPerson", - "Organization", - ], - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Classification of section (recommended)", - description=( - "A code identifying the kind of content contained within the section. " - "This must be consistent with the section title." - ), - # if property is element of this resource. - element_property=True, - ) - - emptyReason: fhirtypes.CodeableConceptType = Field( - None, - alias="emptyReason", - title="Why the section is empty", - description=( - "If the section is empty, why the list is empty. An empty section " - "typically has some text explaining the empty reason." - ), - # if property is element of this resource. - element_property=True, - ) - - entry: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="entry", - title="A reference to data that supports this section", - description=( - "A reference to the actual resource from which the narrative in the " - "section is derived." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - focus: fhirtypes.ReferenceType = Field( - None, - alias="focus", - title=( - "Who/what the section is about, when it is not about the subject of " - "composition" - ), - description=( - "The actual focus of the section when it is not the subject of the " - "composition, but instead represents something or someone associated " - "with the subject such as (for a patient subject) a spouse, parent, " - "fetus, or donor. If not focus is specified, the focus is assumed to be" - " focus of the parent section, or, for a section in the Composition " - "itself, the subject of the composition. Sections with a focus SHALL " - "only include resources where the logical subject (patient, subject, " - "focus, etc.) matches the section focus, or the resources have no " - "logical subject (few resources)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - mode: fhirtypes.Code = Field( - None, - alias="mode", - title="working | snapshot | changes", - description=( - "How the entry list was prepared - whether it is a working list that is" - " suitable for being maintained on an ongoing basis, or if it " - "represents a snapshot of a list of items from another source, or " - "whether it is a prepared list where items may be marked as added, " - "modified or deleted." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["working", "snapshot", "changes"], - ) - mode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mode", title="Extension field for ``mode``." - ) - - orderedBy: fhirtypes.CodeableConceptType = Field( - None, - alias="orderedBy", - title="Order of section entries", - description="Specifies the order applied to the items in the section entries.", - # if property is element of this resource. - element_property=True, - ) - - section: typing.List[fhirtypes.CompositionSectionType] = Field( - None, - alias="section", - title="Nested Section", - description="A nested sub-section within this section.", - # if property is element of this resource. - element_property=True, - ) - - text: fhirtypes.NarrativeType = Field( - None, - alias="text", - title="Text summary of the section, for human interpretation", - description=( - "A human-readable narrative that contains the attested content of the " - "section, used to represent the content of the resource to a human. The" - " narrative need not encode all the structured data, but is required to" - ' contain sufficient detail to make it "clinically safe" for a human to' - " just read the narrative." - ), - # if property is element of this resource. - element_property=True, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Label for section (e.g. for ToC)", - description=( - "The label for this particular section. This will be part of the " - "rendered content for the document, and is often used to build a table " - "of contents." - ), - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CompositionSection`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "title", - "code", - "author", - "focus", - "text", - "mode", - "orderedBy", - "entry", - "emptyReason", - "section", - ] diff --git a/fhir/resources/conceptmap.py b/fhir/resources/conceptmap.py deleted file mode 100644 index fb6c8b6b..00000000 --- a/fhir/resources/conceptmap.py +++ /dev/null @@ -1,1174 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ConceptMap -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ConceptMap(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A map from one set of concepts to one or more other concepts. - A statement of relationships from one set of concepts to one or more other - concepts - either concepts in code systems, or data element/data element - concepts, or classes in class models. - """ - - resource_type = Field("ConceptMap", const=True) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the concept map and/or its contents." - " Copyright statements are generally legal restrictions on the use and " - "publishing of the concept map." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the concept map was published. " - "The date must change when the business version changes and it must " - "change if the status code changes. In addition, it should change when " - "the substantive content of the concept map changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the concept map", - description=( - "A free text natural language description of the concept map from a " - "consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this concept map is authored for " - "testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - group: typing.List[fhirtypes.ConceptMapGroupType] = Field( - None, - alias="group", - title="Same source and target systems", - description="A group of mappings that all have the same source and target system.", - # if property is element of this resource. - element_property=True, - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Additional identifier for the concept map", - description=( - "A formal identifier that is used to identify this concept map when it " - "is represented in other formats, or referenced in a specification, " - "model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for concept map (if applicable)", - description=( - "A legal or geographic region in which the concept map is intended to " - "be used." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this concept map (computer friendly)", - description=( - "A natural language name identifying the concept map. This name should " - "be usable as an identifier for the module by machine processing " - "applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the concept " - "map." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this concept map is defined", - description=( - "Explanation of why this concept map is needed and why it has been " - "designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - sourceCanonical: fhirtypes.Canonical = Field( - None, - alias="sourceCanonical", - title="The source value set that contains the concepts that are being mapped", - description=( - "Identifier for the source value set that contains the concepts that " - "are being mapped and provides context for the mappings." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e source[x] - one_of_many="source", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - sourceCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sourceCanonical", title="Extension field for ``sourceCanonical``." - ) - - sourceUri: fhirtypes.Uri = Field( - None, - alias="sourceUri", - title="The source value set that contains the concepts that are being mapped", - description=( - "Identifier for the source value set that contains the concepts that " - "are being mapped and provides context for the mappings." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e source[x] - one_of_many="source", - one_of_many_required=False, - ) - sourceUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sourceUri", title="Extension field for ``sourceUri``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this concept map. Enables tracking the life-cycle of the" - " content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - targetCanonical: fhirtypes.Canonical = Field( - None, - alias="targetCanonical", - title="The target value set which provides context for the mappings", - description=( - "The target value set provides context for the mappings. Note that the " - "mapping is made between concepts, not between value sets, but the " - "value set provides important context about how the concept mapping " - "choices are made." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e target[x] - one_of_many="target", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - targetCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_targetCanonical", title="Extension field for ``targetCanonical``." - ) - - targetUri: fhirtypes.Uri = Field( - None, - alias="targetUri", - title="The target value set which provides context for the mappings", - description=( - "The target value set provides context for the mappings. Note that the " - "mapping is made between concepts, not between value sets, but the " - "value set provides important context about how the concept mapping " - "choices are made." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e target[x] - one_of_many="target", - one_of_many_required=False, - ) - targetUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_targetUri", title="Extension field for ``targetUri``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this concept map (human friendly)", - description="A short, descriptive, user-friendly title for the concept map.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this concept map, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this concept map when it is " - "referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this concept map is (or will be) published. This URL can " - "be the target of a canonical reference. It SHALL remain the same when " - "the concept map is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate concept map instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the concept map", - description=( - "The identifier that is used to identify this version of the concept " - "map when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the concept map author" - " and is not expected to be globally unique. For example, it might be a" - " timestamp (e.g. yyyymmdd) if a managed version is not available. " - "There is also no expectation that versions can be placed in a " - "lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConceptMap`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "copyright", - "sourceUri", - "sourceCanonical", - "targetUri", - "targetCanonical", - "group", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1181( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1181( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "source": ["sourceCanonical", "sourceUri"], - "target": ["targetCanonical", "targetUri"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ConceptMapGroup(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Same source and target systems. - A group of mappings that all have the same source and target system. - """ - - resource_type = Field("ConceptMapGroup", const=True) - - element: typing.List[fhirtypes.ConceptMapGroupElementType] = Field( - ..., - alias="element", - title="Mappings for a concept from the source set", - description=( - "Mappings for an individual concept in the source to one or more " - "concepts in the target." - ), - # if property is element of this resource. - element_property=True, - ) - - source: fhirtypes.Uri = Field( - None, - alias="source", - title="Source system where concepts to be mapped are defined", - description=( - "An absolute URI that identifies the source system where the concepts " - "to be mapped are defined." - ), - # if property is element of this resource. - element_property=True, - ) - source__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_source", title="Extension field for ``source``." - ) - - sourceVersion: fhirtypes.String = Field( - None, - alias="sourceVersion", - title="Specific version of the code system", - description=( - "The specific version of the code system, as determined by the code " - "system authority." - ), - # if property is element of this resource. - element_property=True, - ) - sourceVersion__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sourceVersion", title="Extension field for ``sourceVersion``." - ) - - target: fhirtypes.Uri = Field( - None, - alias="target", - title="Target system that the concepts are to be mapped to", - description=( - "An absolute URI that identifies the target system that the concepts " - "will be mapped to." - ), - # if property is element of this resource. - element_property=True, - ) - target__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_target", title="Extension field for ``target``." - ) - - targetVersion: fhirtypes.String = Field( - None, - alias="targetVersion", - title="Specific version of the code system", - description=( - "The specific version of the code system, as determined by the code " - "system authority." - ), - # if property is element of this resource. - element_property=True, - ) - targetVersion__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_targetVersion", title="Extension field for ``targetVersion``." - ) - - unmapped: fhirtypes.ConceptMapGroupUnmappedType = Field( - None, - alias="unmapped", - title="What to do when there is no mapping for the source concept", - description=( - 'What to do when there is no mapping for the source concept. "Unmapped"' - " does not include codes that are unmatched, and the unmapped element " - "is ignored in a code is specified to have equivalence = unmatched." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConceptMapGroup`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "source", - "sourceVersion", - "target", - "targetVersion", - "element", - "unmapped", - ] - - -class ConceptMapGroupElement(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Mappings for a concept from the source set. - Mappings for an individual concept in the source to one or more concepts in - the target. - """ - - resource_type = Field("ConceptMapGroupElement", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Identifies element being mapped", - description="Identity (code or path) or the element/item being mapped.", - # if property is element of this resource. - element_property=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - display: fhirtypes.String = Field( - None, - alias="display", - title="Display for the code", - description=( - "The display for the code. The display is only provided to help editors" - " when editing the concept map." - ), - # if property is element of this resource. - element_property=True, - ) - display__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_display", title="Extension field for ``display``." - ) - - target: typing.List[fhirtypes.ConceptMapGroupElementTargetType] = Field( - None, - alias="target", - title="Concept in target system for element", - description="A concept from the target value set that this concept maps to.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConceptMapGroupElement`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "display", "target"] - - -class ConceptMapGroupElementTarget(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Concept in target system for element. - A concept from the target value set that this concept maps to. - """ - - resource_type = Field("ConceptMapGroupElementTarget", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Code that identifies the target element", - description="Identity (code or path) or the element/item that the map refers to.", - # if property is element of this resource. - element_property=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Description of status/issues in mapping", - description=( - "A description of status/issues in mapping that conveys additional " - "information not represented in the structured data." - ), - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - dependsOn: typing.List[fhirtypes.ConceptMapGroupElementTargetDependsOnType] = Field( - None, - alias="dependsOn", - title="Other elements required for this mapping (from context)", - description=( - "A set of additional dependencies for this mapping to hold. This " - "mapping is only applicable if the specified element can be resolved, " - "and it has the specified value." - ), - # if property is element of this resource. - element_property=True, - ) - - display: fhirtypes.String = Field( - None, - alias="display", - title="Display for the code", - description=( - "The display for the code. The display is only provided to help editors" - " when editing the concept map." - ), - # if property is element of this resource. - element_property=True, - ) - display__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_display", title="Extension field for ``display``." - ) - - equivalence: fhirtypes.Code = Field( - None, - alias="equivalence", - title=( - "relatedto | equivalent | equal | wider | subsumes | narrower | " - "specializes | inexact | unmatched | disjoint" - ), - description=( - "The equivalence between the source and target concepts (counting for " - "the dependencies and products). The equivalence is read from target to" - " source (e.g. the target is 'wider' than the source)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "relatedto", - "equivalent", - "equal", - "wider", - "subsumes", - "narrower", - "specializes", - "inexact", - "unmatched", - "disjoint", - ], - ) - equivalence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_equivalence", title="Extension field for ``equivalence``." - ) - - product: typing.List[fhirtypes.ConceptMapGroupElementTargetDependsOnType] = Field( - None, - alias="product", - title="Other concepts that this mapping also produces", - description=( - "A set of additional outcomes from this mapping to other elements. To " - "properly execute this mapping, the specified element must be mapped to" - " some data element or source that is in context. The mapping may still" - " be useful without a place for the additional data elements, but the " - "equivalence cannot be relied on." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConceptMapGroupElementTarget`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "display", - "equivalence", - "comment", - "dependsOn", - "product", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3039( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("equivalence", "equivalence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ConceptMapGroupElementTargetDependsOn(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Other elements required for this mapping (from context). - A set of additional dependencies for this mapping to hold. This mapping is - only applicable if the specified element can be resolved, and it has the - specified value. - """ - - resource_type = Field("ConceptMapGroupElementTargetDependsOn", const=True) - - display: fhirtypes.String = Field( - None, - alias="display", - title="Display for the code (if value is a code)", - description=( - "The display for the code. The display is only provided to help editors" - " when editing the concept map." - ), - # if property is element of this resource. - element_property=True, - ) - display__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_display", title="Extension field for ``display``." - ) - - property: fhirtypes.Uri = Field( - None, - alias="property", - title="Reference to property mapping depends on", - description=( - "A reference to an element that holds a coded value that corresponds to" - " a code system property. The idea is that the information model " - "carries an element somewhere that is labeled to correspond with a code" - " system property." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - property__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_property", title="Extension field for ``property``." - ) - - system: fhirtypes.Canonical = Field( - None, - alias="system", - title="Code System (if necessary)", - description=( - "An absolute URI that identifies the code system of the dependency code" - " (if the source/dependency is a value set that crosses code systems)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CodeSystem"], - ) - system__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_system", title="Extension field for ``system``." - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="Value of the referenced element", - description=( - "Identity (code or path) or the element/item/ValueSet/text that the map" - " depends on / refers to." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConceptMapGroupElementTargetDependsOn`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "property", - "system", - "value", - "display", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3929( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("property", "property__ext"), ("value", "value__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ConceptMapGroupUnmapped(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What to do when there is no mapping for the source concept. - What to do when there is no mapping for the source concept. "Unmapped" does - not include codes that are unmatched, and the unmapped element is ignored - in a code is specified to have equivalence = unmatched. - """ - - resource_type = Field("ConceptMapGroupUnmapped", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Fixed code when mode = fixed", - description=( - "The fixed code to use when the mode = 'fixed' - all unmapped codes " - "are mapped to a single fixed code." - ), - # if property is element of this resource. - element_property=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - display: fhirtypes.String = Field( - None, - alias="display", - title="Display for the code", - description=( - "The display for the code. The display is only provided to help editors" - " when editing the concept map." - ), - # if property is element of this resource. - element_property=True, - ) - display__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_display", title="Extension field for ``display``." - ) - - mode: fhirtypes.Code = Field( - None, - alias="mode", - title="provided | fixed | other-map", - description=( - "Defines which action to take if there is no match for the source " - "concept in the target system designated for the group. One of 3 " - "actions are possible: use the unmapped code (this is useful when doing" - " a mapping between versions, and only a few codes have changed), use a" - " fixed code (a default code), or alternatively, a reference to a " - "different concept map can be provided (by canonical URL)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["provided", "fixed", "other-map"], - ) - mode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mode", title="Extension field for ``mode``." - ) - - url: fhirtypes.Canonical = Field( - None, - alias="url", - title=( - "canonical reference to an additional ConceptMap to use for mapping if " - "the source concept is unmapped" - ), - description=( - "The canonical reference to an additional ConceptMap resource instance " - "to use for mapping if this ConceptMap resource contains no matching " - "mapping for the source concept." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ConceptMap"], - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConceptMapGroupUnmapped`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "mode", - "code", - "display", - "url", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2520( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("mode", "mode__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/condition.py b/fhir/resources/condition.py deleted file mode 100644 index 9c8a2fc5..00000000 --- a/fhir/resources/condition.py +++ /dev/null @@ -1,587 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Condition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class Condition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Detailed information about conditions, problems or diagnoses. - A clinical condition, problem, diagnosis, or other event, situation, issue, - or clinical concept that has risen to a level of concern. - """ - - resource_type = Field("Condition", const=True) - - abatementAge: fhirtypes.AgeType = Field( - None, - alias="abatementAge", - title="When in resolution/remission", - description=( - "The date or estimated date that the condition resolved or went into " - 'remission. This is called "abatement" because of the many overloaded ' - 'connotations associated with "remission" or "resolution" - Conditions ' - "are never really resolved, but they can abate." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e abatement[x] - one_of_many="abatement", - one_of_many_required=False, - ) - - abatementDateTime: fhirtypes.DateTime = Field( - None, - alias="abatementDateTime", - title="When in resolution/remission", - description=( - "The date or estimated date that the condition resolved or went into " - 'remission. This is called "abatement" because of the many overloaded ' - 'connotations associated with "remission" or "resolution" - Conditions ' - "are never really resolved, but they can abate." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e abatement[x] - one_of_many="abatement", - one_of_many_required=False, - ) - abatementDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_abatementDateTime", - title="Extension field for ``abatementDateTime``.", - ) - - abatementPeriod: fhirtypes.PeriodType = Field( - None, - alias="abatementPeriod", - title="When in resolution/remission", - description=( - "The date or estimated date that the condition resolved or went into " - 'remission. This is called "abatement" because of the many overloaded ' - 'connotations associated with "remission" or "resolution" - Conditions ' - "are never really resolved, but they can abate." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e abatement[x] - one_of_many="abatement", - one_of_many_required=False, - ) - - abatementRange: fhirtypes.RangeType = Field( - None, - alias="abatementRange", - title="When in resolution/remission", - description=( - "The date or estimated date that the condition resolved or went into " - 'remission. This is called "abatement" because of the many overloaded ' - 'connotations associated with "remission" or "resolution" - Conditions ' - "are never really resolved, but they can abate." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e abatement[x] - one_of_many="abatement", - one_of_many_required=False, - ) - - abatementString: fhirtypes.String = Field( - None, - alias="abatementString", - title="When in resolution/remission", - description=( - "The date or estimated date that the condition resolved or went into " - 'remission. This is called "abatement" because of the many overloaded ' - 'connotations associated with "remission" or "resolution" - Conditions ' - "are never really resolved, but they can abate." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e abatement[x] - one_of_many="abatement", - one_of_many_required=False, - ) - abatementString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_abatementString", title="Extension field for ``abatementString``." - ) - - asserter: fhirtypes.ReferenceType = Field( - None, - alias="asserter", - title="Person who asserts this condition", - description="Individual who is making the condition statement.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Patient", - "RelatedPerson", - ], - ) - - bodySite: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="bodySite", - title="Anatomical location, if relevant", - description="The anatomical location where this condition manifests itself.", - # if property is element of this resource. - element_property=True, - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="problem-list-item | encounter-diagnosis", - description="A category assigned to the condition.", - # if property is element of this resource. - element_property=True, - ) - - clinicalStatus: fhirtypes.CodeableConceptType = Field( - None, - alias="clinicalStatus", - title="active | recurrence | relapse | inactive | remission | resolved", - description="The clinical status of the condition.", - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Identification of the condition, problem or diagnosis", - description=None, - # if property is element of this resource. - element_property=True, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter created as part of", - description=( - "The Encounter during which this Condition was created or to which the " - "creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - evidence: typing.List[fhirtypes.ConditionEvidenceType] = Field( - None, - alias="evidence", - title="Supporting evidence", - description=( - "Supporting evidence / manifestations that are the basis of the " - "Condition's verification status, such as evidence that confirmed or " - "refuted the condition." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Ids for this condition", - description=( - "Business identifiers assigned to this condition by the performer or " - "other systems which remain constant as the resource is updated and " - "propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Additional information about the Condition", - description=( - "Additional information about the Condition. This is a general " - "notes/comments entry for description of the Condition, its diagnosis " - "and prognosis." - ), - # if property is element of this resource. - element_property=True, - ) - - onsetAge: fhirtypes.AgeType = Field( - None, - alias="onsetAge", - title="Estimated or actual date, date-time, or age", - description=( - "Estimated or actual date or date-time the condition began, in the " - "opinion of the clinician." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - - onsetDateTime: fhirtypes.DateTime = Field( - None, - alias="onsetDateTime", - title="Estimated or actual date, date-time, or age", - description=( - "Estimated or actual date or date-time the condition began, in the " - "opinion of the clinician." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - onsetDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_onsetDateTime", title="Extension field for ``onsetDateTime``." - ) - - onsetPeriod: fhirtypes.PeriodType = Field( - None, - alias="onsetPeriod", - title="Estimated or actual date, date-time, or age", - description=( - "Estimated or actual date or date-time the condition began, in the " - "opinion of the clinician." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - - onsetRange: fhirtypes.RangeType = Field( - None, - alias="onsetRange", - title="Estimated or actual date, date-time, or age", - description=( - "Estimated or actual date or date-time the condition began, in the " - "opinion of the clinician." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - - onsetString: fhirtypes.String = Field( - None, - alias="onsetString", - title="Estimated or actual date, date-time, or age", - description=( - "Estimated or actual date or date-time the condition began, in the " - "opinion of the clinician." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - onsetString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_onsetString", title="Extension field for ``onsetString``." - ) - - recordedDate: fhirtypes.DateTime = Field( - None, - alias="recordedDate", - title="Date record was first recorded", - description=( - "The recordedDate represents when this particular Condition record was " - "created in the system, which is often a system-generated date." - ), - # if property is element of this resource. - element_property=True, - ) - recordedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_recordedDate", title="Extension field for ``recordedDate``." - ) - - recorder: fhirtypes.ReferenceType = Field( - None, - alias="recorder", - title="Who recorded the condition", - description=( - "Individual who recorded the record and takes responsibility for its " - "content." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Patient", - "RelatedPerson", - ], - ) - - severity: fhirtypes.CodeableConceptType = Field( - None, - alias="severity", - title="Subjective severity of condition", - description=( - "A subjective assessment of the severity of the condition as evaluated " - "by the clinician." - ), - # if property is element of this resource. - element_property=True, - ) - - stage: typing.List[fhirtypes.ConditionStageType] = Field( - None, - alias="stage", - title="Stage/grade, usually assessed formally", - description=( - "Clinical stage or grade of a condition. May include formal severity " - "assessments." - ), - # if property is element of this resource. - element_property=True, - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Who has the condition?", - description=( - "Indicates the patient or group who the condition record is associated " - "with." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - verificationStatus: fhirtypes.CodeableConceptType = Field( - None, - alias="verificationStatus", - title=( - "unconfirmed | provisional | differential | confirmed | refuted | " - "entered-in-error" - ), - description=( - "The verification status to support the clinical status of the " - "condition." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Condition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "clinicalStatus", - "verificationStatus", - "category", - "severity", - "code", - "bodySite", - "subject", - "encounter", - "onsetDateTime", - "onsetAge", - "onsetPeriod", - "onsetRange", - "onsetString", - "abatementDateTime", - "abatementAge", - "abatementPeriod", - "abatementRange", - "abatementString", - "recordedDate", - "recorder", - "asserter", - "stage", - "evidence", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1112( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "abatement": [ - "abatementAge", - "abatementDateTime", - "abatementPeriod", - "abatementRange", - "abatementString", - ], - "onset": [ - "onsetAge", - "onsetDateTime", - "onsetPeriod", - "onsetRange", - "onsetString", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ConditionEvidence(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Supporting evidence. - Supporting evidence / manifestations that are the basis of the Condition's - verification status, such as evidence that confirmed or refuted the - condition. - """ - - resource_type = Field("ConditionEvidence", const=True) - - code: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="code", - title="Manifestation/symptom", - description=( - "A manifestation or symptom that led to the recording of this " "condition." - ), - # if property is element of this resource. - element_property=True, - ) - - detail: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="detail", - title="Supporting information found elsewhere", - description="Links to other relevant information, including pathology reports.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConditionEvidence`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "detail"] - - -class ConditionStage(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Stage/grade, usually assessed formally. - Clinical stage or grade of a condition. May include formal severity - assessments. - """ - - resource_type = Field("ConditionStage", const=True) - - assessment: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="assessment", - title="Formal record of assessment", - description=( - "Reference to a formal record of the evidence on which the staging " - "assessment is based." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ClinicalImpression", "DiagnosticReport", "Observation"], - ) - - summary: fhirtypes.CodeableConceptType = Field( - None, - alias="summary", - title="Simple summary (disease specific)", - description=( - 'A simple summary of the stage such as "Stage 3". The determination of ' - "the stage is disease-specific." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Kind of staging", - description="The kind of staging, such as pathological or clinical staging.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConditionStage`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "summary", "assessment", "type"] diff --git a/fhir/resources/consent.py b/fhir/resources/consent.py deleted file mode 100644 index b7565292..00000000 --- a/fhir/resources/consent.py +++ /dev/null @@ -1,876 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Consent -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Consent(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A healthcare consumer's choices to permit or deny recipients or roles to - perform actions for specific purposes and periods of time. - A record of a healthcare consumer’s choices, which permits or denies - identified recipient(s) or recipient role(s) to perform one or more actions - within a given policy context, for specific purposes and periods of time. - """ - - resource_type = Field("Consent", const=True) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - ..., - alias="category", - title="Classification of the consent statement - for indexing/retrieval", - description=( - "A classification of the type of consents found in the statement. This " - "element supports indexing and retrieval of consent statements." - ), - # if property is element of this resource. - element_property=True, - ) - - dateTime: fhirtypes.DateTime = Field( - None, - alias="dateTime", - title="When this Consent was created or indexed", - description="When this Consent was issued / created / indexed.", - # if property is element of this resource. - element_property=True, - ) - dateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_dateTime", title="Extension field for ``dateTime``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Identifier for this record (external references)", - description="Unique identifier for this copy of the Consent Statement.", - # if property is element of this resource. - element_property=True, - ) - - organization: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="organization", - title="Custodian of the consent", - description=( - "The organization that manages the consent, and the framework within " - "which it is executed." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - patient: fhirtypes.ReferenceType = Field( - None, - alias="patient", - title="Who the consent applies to", - description="The patient/healthcare consumer to whom this consent applies.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - performer: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="performer", - title="Who is agreeing to the policy and rules", - description=( - "Either the Grantor, which is the entity responsible for granting the " - "rights listed in a Consent Directive or the Grantee, which is the " - "entity responsible for complying with the Consent Directive, including" - " any obligations or limitations on authorizations and enforcement of " - "prohibitions." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Organization", - "Patient", - "Practitioner", - "RelatedPerson", - "PractitionerRole", - ], - ) - - policy: typing.List[fhirtypes.ConsentPolicyType] = Field( - None, - alias="policy", - title="Policies covered by this consent", - description=( - "The references to the policies that are included in this consent " - "scope. Policies may be organizational, but are often defined " - "jurisdictionally, or in law." - ), - # if property is element of this resource. - element_property=True, - ) - - policyRule: fhirtypes.CodeableConceptType = Field( - None, - alias="policyRule", - title="Regulation that this consents to", - description="A reference to the specific base computable regulation or policy.", - # if property is element of this resource. - element_property=True, - ) - - provision: fhirtypes.ConsentProvisionType = Field( - None, - alias="provision", - title="Constraints to the base Consent.policyRule", - description=( - "An exception to the base policy of this consent. An exception can be " - "an addition or removal of access permissions." - ), - # if property is element of this resource. - element_property=True, - ) - - scope: fhirtypes.CodeableConceptType = Field( - ..., - alias="scope", - title="Which of the four areas this resource covers (extensible)", - description=( - "A selector of the type of consent being presented: ADR, Privacy, " - "Treatment, Research. This list is now extensible." - ), - # if property is element of this resource. - element_property=True, - ) - - sourceAttachment: fhirtypes.AttachmentType = Field( - None, - alias="sourceAttachment", - title="Source from which this consent is taken", - description=( - "The source on which this consent statement is based. The source might " - "be a scanned original paper form, or a reference to a consent that " - "links back to such a source, a reference to a document repository " - "(e.g. XDS) that stores the original consent document." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e source[x] - one_of_many="source", - one_of_many_required=False, - ) - - sourceReference: fhirtypes.ReferenceType = Field( - None, - alias="sourceReference", - title="Source from which this consent is taken", - description=( - "The source on which this consent statement is based. The source might " - "be a scanned original paper form, or a reference to a consent that " - "links back to such a source, a reference to a document repository " - "(e.g. XDS) that stores the original consent document." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e source[x] - one_of_many="source", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Consent", - "DocumentReference", - "Contract", - "QuestionnaireResponse", - ], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | proposed | active | rejected | inactive | entered-in-error", - description="Indicates the current state of this consent.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "draft", - "proposed", - "active", - "rejected", - "inactive", - "entered-in-error", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - verification: typing.List[fhirtypes.ConsentVerificationType] = Field( - None, - alias="verification", - title="Consent Verified by patient or family", - description=( - "Whether a treatment instruction (e.g. artificial respiration yes or " - "no) was verified with the patient, his/her family or another " - "authorized person." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Consent`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "scope", - "category", - "patient", - "dateTime", - "performer", - "organization", - "sourceAttachment", - "sourceReference", - "policy", - "policyRule", - "verification", - "provision", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_913( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_913( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"source": ["sourceAttachment", "sourceReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ConsentPolicy(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Policies covered by this consent. - The references to the policies that are included in this consent scope. - Policies may be organizational, but are often defined jurisdictionally, or - in law. - """ - - resource_type = Field("ConsentPolicy", const=True) - - authority: fhirtypes.Uri = Field( - None, - alias="authority", - title="Enforcement source for policy", - description=( - "Entity or Organization having regulatory jurisdiction or " - "accountability for enforcing policies pertaining to Consent " - "Directives." - ), - # if property is element of this resource. - element_property=True, - ) - authority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_authority", title="Extension field for ``authority``." - ) - - uri: fhirtypes.Uri = Field( - None, - alias="uri", - title="Specific policy covered by this consent", - description=( - "The references to the policies that are included in this consent " - "scope. Policies may be organizational, but are often defined " - "jurisdictionally, or in law." - ), - # if property is element of this resource. - element_property=True, - ) - uri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_uri", title="Extension field for ``uri``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConsentPolicy`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "authority", "uri"] - - -class ConsentProvision(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Constraints to the base Consent.policyRule. - An exception to the base policy of this consent. An exception can be an - addition or removal of access permissions. - """ - - resource_type = Field("ConsentProvision", const=True) - - action: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="action", - title="Actions controlled by this rule", - description="Actions controlled by this Rule.", - # if property is element of this resource. - element_property=True, - ) - - actor: typing.List[fhirtypes.ConsentProvisionActorType] = Field( - None, - alias="actor", - title="Who|what controlled by this rule (or group, by role)", - description=( - "Who or what is controlled by this rule. Use group to identify a set of" - " actors by some property they share (e.g. 'admitting officers')." - ), - # if property is element of this resource. - element_property=True, - ) - - class_fhir: typing.List[fhirtypes.CodingType] = Field( - None, - alias="class", - title="e.g. Resource Type, Profile, CDA, etc.", - description=( - "The class of information covered by this rule. The type can be a FHIR " - "resource type, a profile on a type, or a CDA document, or some other " - "type that indicates what sort of information the consent relates to." - ), - # if property is element of this resource. - element_property=True, - ) - - code: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="code", - title="e.g. LOINC or SNOMED CT code, etc. in the content", - description="If this code is found in an instance, then the rule applies.", - # if property is element of this resource. - element_property=True, - ) - - data: typing.List[fhirtypes.ConsentProvisionDataType] = Field( - None, - alias="data", - title="Data controlled by this rule", - description=( - "The resources controlled by this rule if specific resources are " - "referenced." - ), - # if property is element of this resource. - element_property=True, - ) - - dataPeriod: fhirtypes.PeriodType = Field( - None, - alias="dataPeriod", - title="Timeframe for data controlled by this rule", - description=( - "Clinical or Operational Relevant period of time that bounds the data " - "controlled by this rule." - ), - # if property is element of this resource. - element_property=True, - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Timeframe for this rule", - description="The timeframe in this rule is valid.", - # if property is element of this resource. - element_property=True, - ) - - provision: typing.List[fhirtypes.ConsentProvisionType] = Field( - None, - alias="provision", - title="Nested Exception Rules", - description="Rules which provide exceptions to the base rule or subrules.", - # if property is element of this resource. - element_property=True, - ) - - purpose: typing.List[fhirtypes.CodingType] = Field( - None, - alias="purpose", - title="Context of activities covered by this rule", - description=( - "The context of the activities a user is taking - why the user is " - "accessing the data - that are controlled by this rule." - ), - # if property is element of this resource. - element_property=True, - ) - - securityLabel: typing.List[fhirtypes.CodingType] = Field( - None, - alias="securityLabel", - title="Security Labels that define affected resources", - description=( - "A security label, comprised of 0..* security label fields (Privacy " - "tags), which define which resources are controlled by this exception." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="deny | permit", - description=( - "Action to take - permit or deny - when the rule conditions are met. " - "Not permitted in root rule, required in all nested rules." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["deny", "permit"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConsentProvision`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "period", - "actor", - "action", - "securityLabel", - "purpose", - "class", - "code", - "dataPeriod", - "data", - "provision", - ] - - -class ConsentProvisionActor(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Who|what controlled by this rule (or group, by role). - Who or what is controlled by this rule. Use group to identify a set of - actors by some property they share (e.g. 'admitting officers'). - """ - - resource_type = Field("ConsentProvisionActor", const=True) - - reference: fhirtypes.ReferenceType = Field( - ..., - alias="reference", - title="Resource for the actor (or group, by role)", - description=( - "The resource that identifies the actor. To identify actors by type, " - "use group to identify a set of actors by some property they share " - "(e.g. 'admitting officers')." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Device", - "Group", - "CareTeam", - "Organization", - "Patient", - "Practitioner", - "RelatedPerson", - "PractitionerRole", - ], - ) - - role: fhirtypes.CodeableConceptType = Field( - ..., - alias="role", - title="How the actor is involved", - description=( - "How the individual is involved in the resources content that is " - "described in the exception." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConsentProvisionActor`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "role", "reference"] - - -class ConsentProvisionData(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Data controlled by this rule. - The resources controlled by this rule if specific resources are referenced. - """ - - resource_type = Field("ConsentProvisionData", const=True) - - meaning: fhirtypes.Code = Field( - None, - alias="meaning", - title="instance | related | dependents | authoredby", - description=( - "How the resource reference is interpreted when testing consent " - "restrictions." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["instance", "related", "dependents", "authoredby"], - ) - meaning__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_meaning", title="Extension field for ``meaning``." - ) - - reference: fhirtypes.ReferenceType = Field( - ..., - alias="reference", - title="The actual data reference", - description=( - "A reference to a specific resource that defines which resources are " - "covered by this consent." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConsentProvisionData`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "meaning", "reference"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2241( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("meaning", "meaning__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ConsentVerification(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Consent Verified by patient or family. - Whether a treatment instruction (e.g. artificial respiration yes or no) was - verified with the patient, his/her family or another authorized person. - """ - - resource_type = Field("ConsentVerification", const=True) - - verificationDate: fhirtypes.DateTime = Field( - None, - alias="verificationDate", - title="When consent verified", - description="Date verification was collected.", - # if property is element of this resource. - element_property=True, - ) - verificationDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_verificationDate", - title="Extension field for ``verificationDate``.", - ) - - verified: bool = Field( - None, - alias="verified", - title="Has been verified", - description="Has the instruction been verified.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - verified__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_verified", title="Extension field for ``verified``." - ) - - verifiedWith: fhirtypes.ReferenceType = Field( - None, - alias="verifiedWith", - title="Person who verified", - description=( - "Who verified the instruction (Patient, Relative or other Authorized " - "Person)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "RelatedPerson"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ConsentVerification`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "verified", - "verifiedWith", - "verificationDate", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2158( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("verified", "verified__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/contactdetail.py b/fhir/resources/contactdetail.py deleted file mode 100644 index 083cf231..00000000 --- a/fhir/resources/contactdetail.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ContactDetail -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import element, fhirtypes - - -class ContactDetail(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contact information. - Specifies contact information for a person or organization. - """ - - resource_type = Field("ContactDetail", const=True) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name of an individual to contact", - description="The name of an individual to contact.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="Contact details for individual or organization", - description=( - "The contact details for the individual (if a name was provided) or the" - " organization." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContactDetail`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "name", "telecom"] diff --git a/fhir/resources/contactpoint.py b/fhir/resources/contactpoint.py deleted file mode 100644 index f347ff13..00000000 --- a/fhir/resources/contactpoint.py +++ /dev/null @@ -1,105 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ContactPoint -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import element, fhirtypes - - -class ContactPoint(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Details of a Technology mediated contact point (phone, fax, email, etc.). - Details for all kinds of technology mediated contact points for a person or - organization, including telephone, email, etc. - """ - - resource_type = Field("ContactPoint", const=True) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Time period when the contact point was/is in use", - description=None, - # if property is element of this resource. - element_property=True, - ) - - rank: fhirtypes.PositiveInt = Field( - None, - alias="rank", - title="Specify preferred order of use (1 = highest)", - description=( - "Specifies a preferred order in which to use a set of contacts. " - "ContactPoints with lower rank values are more preferred than those " - "with higher rank values." - ), - # if property is element of this resource. - element_property=True, - ) - rank__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_rank", title="Extension field for ``rank``." - ) - - system: fhirtypes.Code = Field( - None, - alias="system", - title="phone | fax | email | pager | url | sms | other", - description=( - "Telecommunications form for contact point - what communications system" - " is required to make use of the contact." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["phone", "fax", "email", "pager", "url", "sms", "other"], - ) - system__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_system", title="Extension field for ``system``." - ) - - use: fhirtypes.Code = Field( - None, - alias="use", - title="home | work | temp | old | mobile - purpose of this contact point", - description="Identifies the purpose for the contact point.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["home", "work", "temp", "old", "mobile"], - ) - use__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_use", title="Extension field for ``use``." - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="The actual contact point details", - description=( - "The actual contact point details, in a form that is meaningful to the " - "designated communication system (i.e. phone number or email address)." - ), - # if property is element of this resource. - element_property=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContactPoint`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "system", "value", "use", "rank", "period"] diff --git a/fhir/resources/contract.py b/fhir/resources/contract.py deleted file mode 100644 index 5fb18dff..00000000 --- a/fhir/resources/contract.py +++ /dev/null @@ -1,3060 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Contract -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Contract(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Legal Agreement. - Legally enforceable, formally recorded unilateral or bilateral directive - i.e., a policy or agreement. - """ - - resource_type = Field("Contract", const=True) - - alias: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="alias", - title="Acronym or short name", - description=( - "Alternative representation of the title for this Contract definition, " - "derivative, or instance in any legal state., e.g., a domain specific " - "contract number related to legislation." - ), - # if property is element of this resource. - element_property=True, - ) - alias__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_alias", title="Extension field for ``alias``.") - - applies: fhirtypes.PeriodType = Field( - None, - alias="applies", - title="Effective time", - description="Relevant time or time-period when this Contract is applicable.", - # if property is element of this resource. - element_property=True, - ) - - author: fhirtypes.ReferenceType = Field( - None, - alias="author", - title="Source of Contract", - description=( - "The individual or organization that authored the Contract definition, " - "derivative, or instance in any legal state." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "Organization", - ], - ) - - authority: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="authority", - title="Authority under which this Contract has standing", - description=( - "A formally or informally recognized grouping of people, principals, " - "organizations, or jurisdictions formed for the purpose of achieving " - "some form of collective action such as the promulgation, " - "administration and enforcement of contracts and policies." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - contentDefinition: fhirtypes.ContractContentDefinitionType = Field( - None, - alias="contentDefinition", - title="Contract precursor content", - description=( - "Precusory content developed with a focus and intent of supporting the " - "formation a Contract instance, which may be associated with and " - "transformable into a Contract." - ), - # if property is element of this resource. - element_property=True, - ) - - contentDerivative: fhirtypes.CodeableConceptType = Field( - None, - alias="contentDerivative", - title="Content derived from the basal information", - description=( - "The minimal content derived from the basal information source at a " - "specific stage in its lifecycle." - ), - # if property is element of this resource. - element_property=True, - ) - - domain: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="domain", - title=( - "A sphere of control governed by an authoritative jurisdiction, " - "organization, or person" - ), - description=( - "Recognized governance framework or system operating with a " - "circumscribed scope in accordance with specified principles, policies," - " processes or procedures for managing rights, actions, or behaviors of" - " parties or principals relative to resources." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - expirationType: fhirtypes.CodeableConceptType = Field( - None, - alias="expirationType", - title="Contract cessation cause", - description=( - "Event resulting in discontinuation or termination of this Contract " - "instance by one or more parties to the contract." - ), - # if property is element of this resource. - element_property=True, - ) - - friendly: typing.List[fhirtypes.ContractFriendlyType] = Field( - None, - alias="friendly", - title="Contract Friendly Language", - description=( - 'The "patient friendly language" versionof the Contract in whole or in ' - 'parts. "Patient friendly language" means the representation of the ' - "Contract and Contract Provisions in a manner that is readily " - "accessible and understandable by a layperson in accordance with best " - "practices for communication styles that ensure that those agreeing to " - "or signing the Contract understand the roles, actions, obligations, " - "responsibilities, and implication of the agreement." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Contract number", - description=( - "Unique identifier for this Contract or a derivative that references a " - "Source Contract." - ), - # if property is element of this resource. - element_property=True, - ) - - instantiatesCanonical: fhirtypes.ReferenceType = Field( - None, - alias="instantiatesCanonical", - title="Source Contract Definition", - description=( - "The URL pointing to a FHIR-defined Contract Definition that is adhered" - " to in whole or part by this Contract." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Contract"], - ) - - instantiatesUri: fhirtypes.Uri = Field( - None, - alias="instantiatesUri", - title="External Contract Definition", - description=( - "The URL pointing to an externally maintained definition that is " - "adhered to in whole or in part by this Contract." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - issued: fhirtypes.DateTime = Field( - None, - alias="issued", - title="When this Contract was issued", - description="When this Contract was issued.", - # if property is element of this resource. - element_property=True, - ) - issued__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_issued", title="Extension field for ``issued``." - ) - - legal: typing.List[fhirtypes.ContractLegalType] = Field( - None, - alias="legal", - title="Contract Legal Language", - description="List of Legal expressions or representations of this Contract.", - # if property is element of this resource. - element_property=True, - ) - - legalState: fhirtypes.CodeableConceptType = Field( - None, - alias="legalState", - title="Negotiation status", - description=( - "Legal states of the formation of a legal instrument, which is a " - "formally executed written document that can be formally attributed to " - "its author, records and formally expresses a legally enforceable act, " - "process, or contractual duty, obligation, or right, and therefore " - "evidences that act, process, or agreement." - ), - # if property is element of this resource. - element_property=True, - ) - - legallyBindingAttachment: fhirtypes.AttachmentType = Field( - None, - alias="legallyBindingAttachment", - title="Binding Contract", - description=( - "Legally binding Contract: This is the signed and legally recognized " - 'representation of the Contract, which is considered the "source of ' - 'truth" and which would be the basis for legal action related to ' - "enforcement of this Contract." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e legallyBinding[x] - one_of_many="legallyBinding", - one_of_many_required=False, - ) - - legallyBindingReference: fhirtypes.ReferenceType = Field( - None, - alias="legallyBindingReference", - title="Binding Contract", - description=( - "Legally binding Contract: This is the signed and legally recognized " - 'representation of the Contract, which is considered the "source of ' - 'truth" and which would be the basis for legal action related to ' - "enforcement of this Contract." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e legallyBinding[x] - one_of_many="legallyBinding", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Composition", - "DocumentReference", - "QuestionnaireResponse", - "Contract", - ], - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Computer friendly designation", - description=( - "A natural language name identifying this Contract definition, " - "derivative, or instance in any legal state. Provides additional " - "information about its content. This name should be usable as an " - "identifier for the module by machine processing applications such as " - "code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - relevantHistory: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="relevantHistory", - title="Key event in Contract History", - description=( - "Links to Provenance records for past versions of this Contract " - "definition, derivative, or instance, which identify key state " - "transitions or updates that are likely to be relevant to a user " - "looking at the current version of the Contract. The Provence.entity " - "indicates the target that was changed in the update. " - "http://build.fhir.org/provenance-definitions.html#Provenance.entity." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Provenance"], - ) - - rule: typing.List[fhirtypes.ContractRuleType] = Field( - None, - alias="rule", - title="Computable Contract Language", - description=( - "List of Computable Policy Rule Language Representations of this " - "Contract." - ), - # if property is element of this resource. - element_property=True, - ) - - scope: fhirtypes.CodeableConceptType = Field( - None, - alias="scope", - title="Range of Legal Concerns", - description=( - "A selector of legal concerns for this Contract definition, derivative," - " or instance in any legal state." - ), - # if property is element of this resource. - element_property=True, - ) - - signer: typing.List[fhirtypes.ContractSignerType] = Field( - None, - alias="signer", - title="Contract Signatory", - description=( - "Parties with legal standing in the Contract, including the principal " - "parties, the grantor(s) and grantee(s), which are any person or " - "organization bound by the contract, and any ancillary parties, which " - "facilitate the execution of the contract such as a notary or witness." - ), - # if property is element of this resource. - element_property=True, - ) - - site: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="site", - title="Specific Location", - description="Sites in which the contract is complied with, exercised, or in force.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "amended | appended | cancelled | disputed | entered-in-error | " - "executable | executed | negotiable | offered | policy | rejected | " - "renewed | revoked | resolved | terminated" - ), - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "amended", - "appended", - "cancelled", - "disputed", - "entered-in-error", - "executable", - "executed", - "negotiable", - "offered", - "policy", - "rejected", - "renewed", - "revoked", - "resolved", - "terminated", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subType: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="subType", - title="Subtype within the context of type", - description=( - "Sub-category for the Contract that distinguishes the kinds of systems " - "that would be interested in the Contract within the context of the " - "Contract's scope." - ), - # if property is element of this resource. - element_property=True, - ) - - subject: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="subject", - title="Contract Target Entity", - description=( - "The target entity impacted by or of interest to parties to the " - "agreement." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - subtitle: fhirtypes.String = Field( - None, - alias="subtitle", - title="Subordinate Friendly name", - description=( - "An explanatory or alternate user-friendly title for this Contract " - "definition, derivative, or instance in any legal state.t giving " - "additional information about its content." - ), - # if property is element of this resource. - element_property=True, - ) - subtitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subtitle", title="Extension field for ``subtitle``." - ) - - supportingInfo: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingInfo", - title="Extra Information", - description=( - "Information that may be needed by/relevant to the performer in their " - "execution of this term action." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - term: typing.List[fhirtypes.ContractTermType] = Field( - None, - alias="term", - title="Contract Term List", - description=( - "One or more Contract Provisions, which may be related and conveyed as " - "a group, and may contain nested groups." - ), - # if property is element of this resource. - element_property=True, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Human Friendly name", - description=( - "A short, descriptive, user-friendly title for this Contract " - "definition, derivative, or instance in any legal state.t giving " - "additional information about its content." - ), - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topicCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="topicCodeableConcept", - title="Focus of contract interest", - description=( - "Narrows the range of legal concerns to focus on the achievement of " - "specific contractual objectives." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e topic[x] - one_of_many="topic", - one_of_many_required=False, - ) - - topicReference: fhirtypes.ReferenceType = Field( - None, - alias="topicReference", - title="Focus of contract interest", - description=( - "Narrows the range of legal concerns to focus on the achievement of " - "specific contractual objectives." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e topic[x] - one_of_many="topic", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Legal instrument category", - description=( - "A high-level category for the legal instrument, whether constructed as" - " a Contract definition, derivative, or instance in any legal state. " - "Provides additional information about its content within the context " - "of the Contract's scope to distinguish the kinds of systems that would" - " be interested in the contract." - ), - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title="Basal definition", - description=( - "Canonical identifier for this contract, represented as a URI (globally" - " unique)." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business edition", - description=( - "An edition identifier used for business purposes to label business " - "significant variants." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Contract`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "url", - "version", - "status", - "legalState", - "instantiatesCanonical", - "instantiatesUri", - "contentDerivative", - "issued", - "applies", - "expirationType", - "subject", - "authority", - "domain", - "site", - "name", - "title", - "subtitle", - "alias", - "author", - "scope", - "topicCodeableConcept", - "topicReference", - "type", - "subType", - "contentDefinition", - "term", - "supportingInfo", - "relevantHistory", - "signer", - "friendly", - "legal", - "rule", - "legallyBindingAttachment", - "legallyBindingReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1013( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "legallyBinding": ["legallyBindingAttachment", "legallyBindingReference"], - "topic": ["topicCodeableConcept", "topicReference"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ContractContentDefinition(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contract precursor content. - Precusory content developed with a focus and intent of supporting the - formation a Contract instance, which may be associated with and - transformable into a Contract. - """ - - resource_type = Field("ContractContentDefinition", const=True) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Publication Ownership", - description=( - "A copyright statement relating to Contract precursor content. " - "Copyright statements are generally legal restrictions on the use and " - "publishing of the Contract precursor content." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - publicationDate: fhirtypes.DateTime = Field( - None, - alias="publicationDate", - title="When published", - description=( - "The date (and optionally time) when the contract was published. The " - "date must change when the business version changes and it must change " - "if the status code changes. In addition, it should change when the " - "substantive content of the contract changes." - ), - # if property is element of this resource. - element_property=True, - ) - publicationDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publicationDate", title="Extension field for ``publicationDate``." - ) - - publicationStatus: fhirtypes.Code = Field( - None, - alias="publicationStatus", - title=( - "amended | appended | cancelled | disputed | entered-in-error | " - "executable | executed | negotiable | offered | policy | rejected | " - "renewed | revoked | resolved | terminated" - ), - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "amended", - "appended", - "cancelled", - "disputed", - "entered-in-error", - "executable", - "executed", - "negotiable", - "offered", - "policy", - "rejected", - "renewed", - "revoked", - "resolved", - "terminated", - ], - ) - publicationStatus__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_publicationStatus", - title="Extension field for ``publicationStatus``.", - ) - - publisher: fhirtypes.ReferenceType = Field( - None, - alias="publisher", - title="Publisher Entity", - description=( - "The individual or organization that published the Contract precursor " - "content." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - subType: fhirtypes.CodeableConceptType = Field( - None, - alias="subType", - title="Detailed Content Type Definition", - description="Detailed Precusory content type.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Content structure and use", - description=( - "Precusory content structure and use, i.e., a boilerplate, template, " - "application for a contract such as an insurance policy or benefits " - "under a program, e.g., workers compensation." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractContentDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "subType", - "publisher", - "publicationDate", - "publicationStatus", - "copyright", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2771( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("publicationStatus", "publicationStatus__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ContractFriendly(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contract Friendly Language. - The "patient friendly language" versionof the Contract in whole or in - parts. "Patient friendly language" means the representation of the Contract - and Contract Provisions in a manner that is readily accessible and - understandable by a layperson in accordance with best practices for - communication styles that ensure that those agreeing to or signing the - Contract understand the roles, actions, obligations, responsibilities, and - implication of the agreement. - """ - - resource_type = Field("ContractFriendly", const=True) - - contentAttachment: fhirtypes.AttachmentType = Field( - None, - alias="contentAttachment", - title="Easily comprehended representation of this Contract", - description=( - "Human readable rendering of this Contract in a format and " - "representation intended to enhance comprehension and ensure " - "understandability." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - ) - - contentReference: fhirtypes.ReferenceType = Field( - None, - alias="contentReference", - title="Easily comprehended representation of this Contract", - description=( - "Human readable rendering of this Contract in a format and " - "representation intended to enhance comprehension and ensure " - "understandability." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Composition", - "DocumentReference", - "QuestionnaireResponse", - ], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractFriendly`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "contentAttachment", - "contentReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1847( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"content": ["contentAttachment", "contentReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ContractLegal(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contract Legal Language. - List of Legal expressions or representations of this Contract. - """ - - resource_type = Field("ContractLegal", const=True) - - contentAttachment: fhirtypes.AttachmentType = Field( - None, - alias="contentAttachment", - title="Contract Legal Text", - description="Contract legal text in human renderable form.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - ) - - contentReference: fhirtypes.ReferenceType = Field( - None, - alias="contentReference", - title="Contract Legal Text", - description="Contract legal text in human renderable form.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Composition", - "DocumentReference", - "QuestionnaireResponse", - ], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractLegal`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "contentAttachment", - "contentReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1490( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"content": ["contentAttachment", "contentReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ContractRule(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Computable Contract Language. - List of Computable Policy Rule Language Representations of this Contract. - """ - - resource_type = Field("ContractRule", const=True) - - contentAttachment: fhirtypes.AttachmentType = Field( - None, - alias="contentAttachment", - title="Computable Contract Rules", - description=( - "Computable Contract conveyed using a policy rule language (e.g. XACML," - " DKAL, SecPal)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - ) - - contentReference: fhirtypes.ReferenceType = Field( - None, - alias="contentReference", - title="Computable Contract Rules", - description=( - "Computable Contract conveyed using a policy rule language (e.g. XACML," - " DKAL, SecPal)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e content[x] - one_of_many="content", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractRule`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "contentAttachment", - "contentReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1406( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"content": ["contentAttachment", "contentReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ContractSigner(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contract Signatory. - Parties with legal standing in the Contract, including the principal - parties, the grantor(s) and grantee(s), which are any person or - organization bound by the contract, and any ancillary parties, which - facilitate the execution of the contract such as a notary or witness. - """ - - resource_type = Field("ContractSigner", const=True) - - party: fhirtypes.ReferenceType = Field( - ..., - alias="party", - title="Contract Signatory Party", - description="Party which is a signator to this Contract.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Organization", - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - ], - ) - - signature: typing.List[fhirtypes.SignatureType] = Field( - ..., - alias="signature", - title="Contract Documentation Signature", - description="Legally binding Contract DSIG signature contents in Base64.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodingType = Field( - ..., - alias="type", - title="Contract Signatory Role", - description="Role of this Contract signer, e.g. notary, grantee.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractSigner`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "party", "signature"] - - -class ContractTerm(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contract Term List. - One or more Contract Provisions, which may be related and conveyed as a - group, and may contain nested groups. - """ - - resource_type = Field("ContractTerm", const=True) - - action: typing.List[fhirtypes.ContractTermActionType] = Field( - None, - alias="action", - title="Entity being ascribed responsibility", - description=( - "An actor taking a role in an activity for which it can be assigned " - "some degree of responsibility for the activity taking place." - ), - # if property is element of this resource. - element_property=True, - ) - - applies: fhirtypes.PeriodType = Field( - None, - alias="applies", - title="Contract Term Effective Time", - description=( - "Relevant time or time-period when this Contract Provision is " - "applicable." - ), - # if property is element of this resource. - element_property=True, - ) - - asset: typing.List[fhirtypes.ContractTermAssetType] = Field( - None, - alias="asset", - title="Contract Term Asset List", - description=None, - # if property is element of this resource. - element_property=True, - ) - - group: typing.List[fhirtypes.ContractTermType] = Field( - None, - alias="group", - title="Nested Contract Term Group", - description="Nested group of Contract Provisions.", - # if property is element of this resource. - element_property=True, - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Contract Term Number", - description="Unique identifier for this particular Contract Provision.", - # if property is element of this resource. - element_property=True, - ) - - issued: fhirtypes.DateTime = Field( - None, - alias="issued", - title="Contract Term Issue Date Time", - description="When this Contract Provision was issued.", - # if property is element of this resource. - element_property=True, - ) - issued__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_issued", title="Extension field for ``issued``." - ) - - offer: fhirtypes.ContractTermOfferType = Field( - ..., - alias="offer", - title="Context of the Contract term", - description=( - "The matter of concern in the context of this provision of the " "agrement." - ), - # if property is element of this resource. - element_property=True, - ) - - securityLabel: typing.List[fhirtypes.ContractTermSecurityLabelType] = Field( - None, - alias="securityLabel", - title="Protection for the Term", - description=( - "Security labels that protect the handling of information about the " - "term and its elements, which may be specifically identified.." - ), - # if property is element of this resource. - element_property=True, - ) - - subType: fhirtypes.CodeableConceptType = Field( - None, - alias="subType", - title="Contract Term Type specific classification", - description=( - "A specialized legal clause or condition based on overarching contract " - "type." - ), - # if property is element of this resource. - element_property=True, - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Term Statement", - description="Statement of a provision in a policy or a contract.", - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - topicCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="topicCodeableConcept", - title="Term Concern", - description="The entity that the term applies to.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e topic[x] - one_of_many="topic", - one_of_many_required=False, - ) - - topicReference: fhirtypes.ReferenceType = Field( - None, - alias="topicReference", - title="Term Concern", - description="The entity that the term applies to.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e topic[x] - one_of_many="topic", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Contract Term Type or Form", - description=( - "A legal clause or condition contained within a contract that requires " - "one or both parties to perform a particular requirement by some " - "specified time or prevents one or both parties from performing a " - "particular requirement by some specified time." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractTerm`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "issued", - "applies", - "topicCodeableConcept", - "topicReference", - "type", - "subType", - "text", - "securityLabel", - "offer", - "asset", - "action", - "group", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1414( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"topic": ["topicCodeableConcept", "topicReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ContractTermAction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Entity being ascribed responsibility. - An actor taking a role in an activity for which it can be assigned some - degree of responsibility for the activity taking place. - """ - - resource_type = Field("ContractTermAction", const=True) - - context: fhirtypes.ReferenceType = Field( - None, - alias="context", - title="Episode associated with action", - description=( - "Encounter or Episode with primary association to specified term " - "activity." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter", "EpisodeOfCare"], - ) - - contextLinkId: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="contextLinkId", - title="Pointer to specific item", - description=( - "Id [identifier??] of the clause or question text related to the " - "requester of this action in the referenced form or " - "QuestionnaireResponse." - ), - # if property is element of this resource. - element_property=True, - ) - contextLinkId__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_contextLinkId", title="Extension field for ``contextLinkId``." - ) - - doNotPerform: bool = Field( - None, - alias="doNotPerform", - title="True if the term prohibits the action", - description=None, - # if property is element of this resource. - element_property=True, - ) - doNotPerform__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_doNotPerform", title="Extension field for ``doNotPerform``." - ) - - intent: fhirtypes.CodeableConceptType = Field( - ..., - alias="intent", - title="Purpose for the Contract Term Action", - description=( - "Reason or purpose for the action stipulated by this Contract " "Provision." - ), - # if property is element of this resource. - element_property=True, - ) - - linkId: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="linkId", - title="Pointer to specific item", - description=( - "Id [identifier??] of the clause or question text related to this " - "action in the referenced form or QuestionnaireResponse." - ), - # if property is element of this resource. - element_property=True, - ) - linkId__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_linkId", title="Extension field for ``linkId``.") - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments about the action", - description=( - "Comments made about the term action made by the requester, performer, " - "subject or other participants." - ), - # if property is element of this resource. - element_property=True, - ) - - occurrenceDateTime: fhirtypes.DateTime = Field( - None, - alias="occurrenceDateTime", - title="When action happens", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - occurrenceDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurrenceDateTime", - title="Extension field for ``occurrenceDateTime``.", - ) - - occurrencePeriod: fhirtypes.PeriodType = Field( - None, - alias="occurrencePeriod", - title="When action happens", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - occurrenceTiming: fhirtypes.TimingType = Field( - None, - alias="occurrenceTiming", - title="When action happens", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - performer: fhirtypes.ReferenceType = Field( - None, - alias="performer", - title="Actor that wil execute (or not) the action", - description=( - "Indicates who or what is being asked to perform (or not perform) the " - "ction." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "RelatedPerson", - "Patient", - "Practitioner", - "PractitionerRole", - "CareTeam", - "Device", - "Substance", - "Organization", - "Location", - ], - ) - - performerLinkId: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="performerLinkId", - title="Pointer to specific item", - description=( - "Id [identifier??] of the clause or question text related to the reason" - " type or reference of this action in the referenced form or " - "QuestionnaireResponse." - ), - # if property is element of this resource. - element_property=True, - ) - performerLinkId__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_performerLinkId", title="Extension field for ``performerLinkId``." - ) - - performerRole: fhirtypes.CodeableConceptType = Field( - None, - alias="performerRole", - title="Competency of the performer", - description=( - "The type of role or competency of an individual desired or required to" - " perform or not perform the action." - ), - # if property is element of this resource. - element_property=True, - ) - - performerType: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="performerType", - title="Kind of service performer", - description=( - "The type of individual that is desired or required to perform or not " - "perform the action." - ), - # if property is element of this resource. - element_property=True, - ) - - reason: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="reason", - title="Why action is to be performed", - description=( - "Describes why the action is to be performed or not performed in " - "textual form." - ), - # if property is element of this resource. - element_property=True, - ) - reason__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_reason", title="Extension field for ``reason``.") - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why is action (not) needed?", - description=( - "Rationale for the action to be performed or not performed. Describes " - "why the action is permitted or prohibited." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonLinkId: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="reasonLinkId", - title="Pointer to specific item", - description=( - "Id [identifier??] of the clause or question text related to the reason" - " type or reference of this action in the referenced form or " - "QuestionnaireResponse." - ), - # if property is element of this resource. - element_property=True, - ) - reasonLinkId__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_reasonLinkId", title="Extension field for ``reasonLinkId``." - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why is action (not) needed?", - description=( - "Indicates another resource whose existence justifies permitting or not" - " permitting this action." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "DiagnosticReport", - "DocumentReference", - "Questionnaire", - "QuestionnaireResponse", - ], - ) - - requester: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="requester", - title="Who asked for action", - description=( - "Who or what initiated the action and has responsibility for its " - "activation." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "RelatedPerson", - "Practitioner", - "PractitionerRole", - "Device", - "Group", - "Organization", - ], - ) - - requesterLinkId: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="requesterLinkId", - title="Pointer to specific item", - description=( - "Id [identifier??] of the clause or question text related to the " - "requester of this action in the referenced form or " - "QuestionnaireResponse." - ), - # if property is element of this resource. - element_property=True, - ) - requesterLinkId__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_requesterLinkId", title="Extension field for ``requesterLinkId``." - ) - - securityLabelNumber: typing.List[fhirtypes.UnsignedInt] = Field( - None, - alias="securityLabelNumber", - title="Action restriction numbers", - description="Security labels that protects the action.", - # if property is element of this resource. - element_property=True, - ) - securityLabelNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_securityLabelNumber", - title="Extension field for ``securityLabelNumber``.", - ) - - status: fhirtypes.CodeableConceptType = Field( - ..., - alias="status", - title="State of the action", - description="Current state of the term action.", - # if property is element of this resource. - element_property=True, - ) - - subject: typing.List[fhirtypes.ContractTermActionSubjectType] = Field( - None, - alias="subject", - title="Entity of the action", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Type or form of the action", - description=( - "Activity or service obligation to be done or not done, performed or " - "not performed, effectuated or not by this Contract term." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractTermAction`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "doNotPerform", - "type", - "subject", - "intent", - "linkId", - "status", - "context", - "contextLinkId", - "occurrenceDateTime", - "occurrencePeriod", - "occurrenceTiming", - "requester", - "requesterLinkId", - "performerType", - "performerRole", - "performer", - "performerLinkId", - "reasonCode", - "reasonReference", - "reason", - "reasonLinkId", - "note", - "securityLabelNumber", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2021( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "occurrence": ["occurrenceDateTime", "occurrencePeriod", "occurrenceTiming"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ContractTermActionSubject(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Entity of the action. - """ - - resource_type = Field("ContractTermActionSubject", const=True) - - reference: typing.List[fhirtypes.ReferenceType] = Field( - ..., - alias="reference", - title="Entity of the action", - description="The entity the action is performed or not performed on or for.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "RelatedPerson", - "Practitioner", - "PractitionerRole", - "Device", - "Group", - "Organization", - ], - ) - - role: fhirtypes.CodeableConceptType = Field( - None, - alias="role", - title="Role type of the agent", - description="Role type of agent assigned roles in this Contract.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractTermActionSubject`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "reference", "role"] - - -class ContractTermAsset(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contract Term Asset List. - """ - - resource_type = Field("ContractTermAsset", const=True) - - answer: typing.List[fhirtypes.ContractTermOfferAnswerType] = Field( - None, - alias="answer", - title="Response to assets", - description=None, - # if property is element of this resource. - element_property=True, - ) - - condition: fhirtypes.String = Field( - None, - alias="condition", - title="Quality desctiption of asset", - description=( - "Description of the quality and completeness of the asset that imay be " - "a factor in its valuation." - ), - # if property is element of this resource. - element_property=True, - ) - condition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_condition", title="Extension field for ``condition``." - ) - - context: typing.List[fhirtypes.ContractTermAssetContextType] = Field( - None, - alias="context", - title="Circumstance of the asset", - description=None, - # if property is element of this resource. - element_property=True, - ) - - linkId: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="linkId", - title="Pointer to asset text", - description=( - "Id [identifier??] of the clause or question text about the asset in " - "the referenced form or QuestionnaireResponse." - ), - # if property is element of this resource. - element_property=True, - ) - linkId__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_linkId", title="Extension field for ``linkId``.") - - period: typing.List[fhirtypes.PeriodType] = Field( - None, - alias="period", - title="Time period of the asset", - description="Asset relevant contractual time period.", - # if property is element of this resource. - element_property=True, - ) - - periodType: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="periodType", - title="Asset availability types", - description="Type of Asset availability for use or ownership.", - # if property is element of this resource. - element_property=True, - ) - - relationship: fhirtypes.CodingType = Field( - None, - alias="relationship", - title="Kinship of the asset", - description=( - "Specifies the applicability of the term to an asset resource instance," - " and instances it refers to orinstances that refer to it, and/or are " - "owned by the offeree." - ), - # if property is element of this resource. - element_property=True, - ) - - scope: fhirtypes.CodeableConceptType = Field( - None, - alias="scope", - title="Range of asset", - description="Differentiates the kind of the asset .", - # if property is element of this resource. - element_property=True, - ) - - securityLabelNumber: typing.List[fhirtypes.UnsignedInt] = Field( - None, - alias="securityLabelNumber", - title="Asset restriction numbers", - description="Security labels that protects the asset.", - # if property is element of this resource. - element_property=True, - ) - securityLabelNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_securityLabelNumber", - title="Extension field for ``securityLabelNumber``.", - ) - - subtype: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="subtype", - title="Asset sub-category", - description="May be a subtype or part of an offered asset.", - # if property is element of this resource. - element_property=True, - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Asset clause or question text", - description=( - "Clause or question text (Prose Object) concerning the asset in a " - "linked form, such as a QuestionnaireResponse used in the formation of " - "the contract." - ), - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Asset category", - description="Target entity type about which the term may be concerned.", - # if property is element of this resource. - element_property=True, - ) - - typeReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="typeReference", - title="Associated entities", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - usePeriod: typing.List[fhirtypes.PeriodType] = Field( - None, - alias="usePeriod", - title="Time period", - description="Time period of asset use.", - # if property is element of this resource. - element_property=True, - ) - - valuedItem: typing.List[fhirtypes.ContractTermAssetValuedItemType] = Field( - None, - alias="valuedItem", - title="Contract Valued Item List", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractTermAsset`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "scope", - "type", - "typeReference", - "subtype", - "relationship", - "context", - "condition", - "periodType", - "period", - "usePeriod", - "text", - "linkId", - "answer", - "securityLabelNumber", - "valuedItem", - ] - - -class ContractTermAssetContext(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Circumstance of the asset. - """ - - resource_type = Field("ContractTermAssetContext", const=True) - - code: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="code", - title="Codeable asset context", - description=( - "Coded representation of the context generally or of the Referenced " - "entity, such as the asset holder type or location." - ), - # if property is element of this resource. - element_property=True, - ) - - reference: fhirtypes.ReferenceType = Field( - None, - alias="reference", - title="Creator,custodian or owner", - description=( - "Asset context reference may include the creator, custodian, or owning " - "Person or Organization (e.g., bank, repository), location held, e.g.," - " building, jurisdiction." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Context description", - description=None, - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractTermAssetContext`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "reference", "code", "text"] - - -class ContractTermAssetValuedItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contract Valued Item List. - """ - - resource_type = Field("ContractTermAssetValuedItem", const=True) - - effectiveTime: fhirtypes.DateTime = Field( - None, - alias="effectiveTime", - title="Contract Valued Item Effective Tiem", - description=( - "Indicates the time during which this Contract ValuedItem information " - "is effective." - ), - # if property is element of this resource. - element_property=True, - ) - effectiveTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_effectiveTime", title="Extension field for ``effectiveTime``." - ) - - entityCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="entityCodeableConcept", - title="Contract Valued Item Type", - description="Specific type of Contract Valued Item that may be priced.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e entity[x] - one_of_many="entity", - one_of_many_required=False, - ) - - entityReference: fhirtypes.ReferenceType = Field( - None, - alias="entityReference", - title="Contract Valued Item Type", - description="Specific type of Contract Valued Item that may be priced.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e entity[x] - one_of_many="entity", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Contract Valued Item Price Scaling Factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of the Contract Valued Item delivered. The concept of a " - "Factor allows for a discount or surcharge multiplier to be applied to " - "a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Contract Valued Item Number", - description="Identifies a Contract Valued Item instance.", - # if property is element of this resource. - element_property=True, - ) - - linkId: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="linkId", - title="Pointer to specific item", - description=( - "Id of the clause or question text related to the context of this " - "valuedItem in the referenced form or QuestionnaireResponse." - ), - # if property is element of this resource. - element_property=True, - ) - linkId__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_linkId", title="Extension field for ``linkId``.") - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total Contract Valued Item Value", - description=( - "Expresses the product of the Contract Valued Item unitQuantity and the" - " unitPriceAmt. For example, the formula: unit Quantity * unit Price " - "(Cost per Point) * factor Number * points = net Amount. Quantity, " - "factor and points are assumed to be 1 if not supplied." - ), - # if property is element of this resource. - element_property=True, - ) - - payment: fhirtypes.String = Field( - None, - alias="payment", - title="Terms of valuation", - description=None, - # if property is element of this resource. - element_property=True, - ) - payment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_payment", title="Extension field for ``payment``." - ) - - paymentDate: fhirtypes.DateTime = Field( - None, - alias="paymentDate", - title="When payment is due", - description=None, - # if property is element of this resource. - element_property=True, - ) - paymentDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_paymentDate", title="Extension field for ``paymentDate``." - ) - - points: fhirtypes.Decimal = Field( - None, - alias="points", - title="Contract Valued Item Difficulty Scaling Factor", - description=( - "An amount that expresses the weighting (based on difficulty, cost " - "and/or resource intensiveness) associated with the Contract Valued " - "Item delivered. The concept of Points allows for assignment of point " - "values for a Contract Valued Item, such that a monetary amount can be " - "assigned to each point." - ), - # if property is element of this resource. - element_property=True, - ) - points__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_points", title="Extension field for ``points``." - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of Contract Valued Items", - description=( - "Specifies the units by which the Contract Valued Item is measured or " - "counted, and quantifies the countable or measurable Contract Valued " - "Item instances." - ), - # if property is element of this resource. - element_property=True, - ) - - recipient: fhirtypes.ReferenceType = Field( - None, - alias="recipient", - title="Who will receive payment", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Organization", - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - ], - ) - - responsible: fhirtypes.ReferenceType = Field( - None, - alias="responsible", - title="Who will make payment", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Organization", - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - ], - ) - - securityLabelNumber: typing.List[fhirtypes.UnsignedInt] = Field( - None, - alias="securityLabelNumber", - title="Security Labels that define affected terms", - description=( - "A set of security labels that define which terms are controlled by " - "this condition." - ), - # if property is element of this resource. - element_property=True, - ) - securityLabelNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_securityLabelNumber", - title="Extension field for ``securityLabelNumber``.", - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Contract Valued Item fee, charge, or cost", - description="A Contract Valued Item unit valuation measure.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractTermAssetValuedItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "entityCodeableConcept", - "entityReference", - "identifier", - "effectiveTime", - "quantity", - "unitPrice", - "factor", - "points", - "net", - "payment", - "paymentDate", - "responsible", - "recipient", - "linkId", - "securityLabelNumber", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2934( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"entity": ["entityCodeableConcept", "entityReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ContractTermOffer(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Context of the Contract term. - The matter of concern in the context of this provision of the agrement. - """ - - resource_type = Field("ContractTermOffer", const=True) - - answer: typing.List[fhirtypes.ContractTermOfferAnswerType] = Field( - None, - alias="answer", - title="Response to offer text", - description=None, - # if property is element of this resource. - element_property=True, - ) - - decision: fhirtypes.CodeableConceptType = Field( - None, - alias="decision", - title="Accepting party choice", - description=( - "Type of choice made by accepting party with respect to an offer made " - "by an offeror/ grantee." - ), - # if property is element of this resource. - element_property=True, - ) - - decisionMode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="decisionMode", - title="How decision is conveyed", - description="How the decision about a Contract was conveyed.", - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Offer business ID", - description="Unique identifier for this particular Contract Provision.", - # if property is element of this resource. - element_property=True, - ) - - linkId: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="linkId", - title="Pointer to text", - description=( - "The id of the clause or question text of the offer in the referenced " - "questionnaire/response." - ), - # if property is element of this resource. - element_property=True, - ) - linkId__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_linkId", title="Extension field for ``linkId``.") - - party: typing.List[fhirtypes.ContractTermOfferPartyType] = Field( - None, - alias="party", - title="Offer Recipient", - description=None, - # if property is element of this resource. - element_property=True, - ) - - securityLabelNumber: typing.List[fhirtypes.UnsignedInt] = Field( - None, - alias="securityLabelNumber", - title="Offer restriction numbers", - description="Security labels that protects the offer.", - # if property is element of this resource. - element_property=True, - ) - securityLabelNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_securityLabelNumber", - title="Extension field for ``securityLabelNumber``.", - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Human readable offer text", - description="Human readable form of this Contract Offer.", - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - topic: fhirtypes.ReferenceType = Field( - None, - alias="topic", - title="Negotiable offer asset", - description=( - "The owner of an asset has the residual control rights over the asset: " - "the right to decide all usages of the asset in any way not " - "inconsistent with a prior contract, custom, or law (Hart, 1995, p. " - "30)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Contract Offer Type or Form", - description=( - "Type of Contract Provision such as specific requirements, purposes for" - " actions, obligations, prohibitions, e.g. life time maximum benefit." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractTermOffer`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "party", - "topic", - "type", - "decision", - "decisionMode", - "answer", - "text", - "linkId", - "securityLabelNumber", - ] - - -class ContractTermOfferAnswer(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Response to offer text. - """ - - resource_type = Field("ContractTermOfferAnswer", const=True) - - valueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="valueAttachment", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCoding: fhirtypes.CodingType = Field( - None, - alias="valueCoding", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDate: fhirtypes.Date = Field( - None, - alias="valueDate", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDate", title="Extension field for ``valueDate``." - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueDecimal: fhirtypes.Decimal = Field( - None, - alias="valueDecimal", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDecimal", title="Extension field for ``valueDecimal``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - valueTime: fhirtypes.Time = Field( - None, - alias="valueTime", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueTime", title="Extension field for ``valueTime``." - ) - - valueUri: fhirtypes.Uri = Field( - None, - alias="valueUri", - title="The actual answer response", - description=( - "Response to an offer clause or question text, which enables selection" - " of values to be agreed to, e.g., the period of participation, the " - "date of occupancy of a rental, warrently duration, or whether " - "biospecimen may be used for further research." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUri", title="Extension field for ``valueUri``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractTermOfferAnswer`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "valueBoolean", - "valueDecimal", - "valueInteger", - "valueDate", - "valueDateTime", - "valueTime", - "valueString", - "valueUri", - "valueAttachment", - "valueCoding", - "valueQuantity", - "valueReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2541( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueAttachment", - "valueBoolean", - "valueCoding", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueInteger", - "valueQuantity", - "valueReference", - "valueString", - "valueTime", - "valueUri", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ContractTermOfferParty(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Offer Recipient. - """ - - resource_type = Field("ContractTermOfferParty", const=True) - - reference: typing.List[fhirtypes.ReferenceType] = Field( - ..., - alias="reference", - title="Referenced entity", - description="Participant in the offer.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "RelatedPerson", - "Practitioner", - "PractitionerRole", - "Device", - "Group", - "Organization", - ], - ) - - role: fhirtypes.CodeableConceptType = Field( - ..., - alias="role", - title="Participant engagement type", - description="How the party participates in the offer.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractTermOfferParty`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "reference", "role"] - - -class ContractTermSecurityLabel(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Protection for the Term. - Security labels that protect the handling of information about the term and - its elements, which may be specifically identified.. - """ - - resource_type = Field("ContractTermSecurityLabel", const=True) - - category: typing.List[fhirtypes.CodingType] = Field( - None, - alias="category", - title="Applicable Policy", - description=( - "Security label privacy tag that species the applicable privacy and " - "security policies governing this term and/or term elements." - ), - # if property is element of this resource. - element_property=True, - ) - - classification: fhirtypes.CodingType = Field( - ..., - alias="classification", - title="Confidentiality Protection", - description=( - "Security label privacy tag that species the level of confidentiality " - "protection required for this term and/or term elements." - ), - # if property is element of this resource. - element_property=True, - ) - - control: typing.List[fhirtypes.CodingType] = Field( - None, - alias="control", - title="Handling Instructions", - description=( - "Security label privacy tag that species the manner in which term " - "and/or term elements are to be protected." - ), - # if property is element of this resource. - element_property=True, - ) - - number: typing.List[fhirtypes.UnsignedInt] = Field( - None, - alias="number", - title="Link to Security Labels", - description=( - "Number used to link this term or term element to the applicable " - "Security Label." - ), - # if property is element of this resource. - element_property=True, - ) - number__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_number", title="Extension field for ``number``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ContractTermSecurityLabel`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "number", - "classification", - "category", - "control", - ] diff --git a/fhir/resources/contributor.py b/fhir/resources/contributor.py deleted file mode 100644 index 53ca01b6..00000000 --- a/fhir/resources/contributor.py +++ /dev/null @@ -1,139 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Contributor -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import element, fhirtypes - - -class Contributor(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contributor information. - A contributor to the content of a knowledge asset, including authors, - editors, reviewers, and endorsers. - """ - - resource_type = Field("Contributor", const=True) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details of the contributor", - description=( - "Contact details to assist a user in finding and communicating with the" - " contributor." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Who contributed the content", - description=( - "The name of the individual or organization responsible for the " - "contribution." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="author | editor | reviewer | endorser", - description="The type of contributor.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["author", "editor", "reviewer", "endorser"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Contributor`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "type", "name", "contact"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1360( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/core/fhirabstractmodel.py b/fhir/resources/core/fhirabstractmodel.py index bbe52661..83d9c3f0 100644 --- a/fhir/resources/core/fhirabstractmodel.py +++ b/fhir/resources/core/fhirabstractmodel.py @@ -358,7 +358,7 @@ def json( # type: ignore option |= orjson.OPT_SORT_KEYS if len(dumps_kwargs) > 0: - logger.warning( + logger.debug( "When ``dumps`` method is used from ``orjson`` " "all dumps kwargs are ignored except `indent`, `sort_keys` " "and of course ``option`` from orjson" diff --git a/fhir/resources/core/patch/__init__.py b/fhir/resources/core/patch/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/fhir/resources/core/patch/patch_r4b_test.py b/fhir/resources/core/patch/patch_r4b_test.py new file mode 100644 index 00000000..e69de29b diff --git a/fhir/resources/count.py b/fhir/resources/count.py deleted file mode 100644 index 9dc997c2..00000000 --- a/fhir/resources/count.py +++ /dev/null @@ -1,33 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Count -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import quantity - - -class Count(quantity.Quantity): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A measured or measurable amount. - A measured amount (or an amount that can potentially be measured). Note - that measured amounts include amounts that are not precisely quantified, - including amounts involving arbitrary units and floating currencies. - """ - - resource_type = Field("Count", const=True) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Count`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "value", "comparator", "unit", "system", "code"] diff --git a/fhir/resources/coverage.py b/fhir/resources/coverage.py deleted file mode 100644 index a1792ac1..00000000 --- a/fhir/resources/coverage.py +++ /dev/null @@ -1,613 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Coverage -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Coverage(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Insurance or medical plan or a payment agreement. - Financial instrument which may be used to reimburse or pay for health care - products and services. Includes both insurance and self-payment. - """ - - resource_type = Field("Coverage", const=True) - - beneficiary: fhirtypes.ReferenceType = Field( - ..., - alias="beneficiary", - title="Plan beneficiary", - description=( - "The party who benefits from the insurance coverage; the patient when " - "products and/or services are provided." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - class_fhir: typing.List[fhirtypes.CoverageClassType] = Field( - None, - alias="class", - title="Additional coverage classifications", - description="A suite of underwriter specific classifiers.", - # if property is element of this resource. - element_property=True, - ) - - contract: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="contract", - title="Contract details", - description="The policy(s) which constitute this insurance coverage.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Contract"], - ) - - costToBeneficiary: typing.List[fhirtypes.CoverageCostToBeneficiaryType] = Field( - None, - alias="costToBeneficiary", - title="Patient payments for services/products", - description=( - "A suite of codes indicating the cost category and associated amount " - "which have been detailed in the policy and may have been included on " - "the health card." - ), - # if property is element of this resource. - element_property=True, - ) - - dependent: fhirtypes.String = Field( - None, - alias="dependent", - title="Dependent number", - description="A unique identifier for a dependent under the coverage.", - # if property is element of this resource. - element_property=True, - ) - dependent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_dependent", title="Extension field for ``dependent``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for the coverage", - description="A unique identifier assigned to this coverage.", - # if property is element of this resource. - element_property=True, - ) - - network: fhirtypes.String = Field( - None, - alias="network", - title="Insurer network", - description=( - "The insurer-specific identifier for the insurer-defined network of " - "providers to which the beneficiary may seek treatment which will be " - "covered at the 'in-network' rate, otherwise 'out of network' terms and" - " conditions apply." - ), - # if property is element of this resource. - element_property=True, - ) - network__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_network", title="Extension field for ``network``." - ) - - order: fhirtypes.PositiveInt = Field( - None, - alias="order", - title="Relative order of the coverage", - description=( - "The order of applicability of this coverage relative to other " - "coverages which are currently in force. Note, there may be gaps in the" - " numbering and this does not imply primary, secondary etc. as the " - "specific positioning of coverages depends upon the episode of care." - ), - # if property is element of this resource. - element_property=True, - ) - order__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_order", title="Extension field for ``order``." - ) - - payor: typing.List[fhirtypes.ReferenceType] = Field( - ..., - alias="payor", - title="Issuer of the policy", - description=( - "The program or plan underwriter or payor including both insurance and " - "non-insurance agreements, such as patient-pay agreements." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization", "Patient", "RelatedPerson"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Coverage start and end dates", - description=( - "Time period during which the coverage is in force. A missing start " - "date indicates the start date isn't known, a missing end date means " - "the coverage is continuing to be in force." - ), - # if property is element of this resource. - element_property=True, - ) - - policyHolder: fhirtypes.ReferenceType = Field( - None, - alias="policyHolder", - title="Owner of the policy", - description="The party who 'owns' the insurance policy.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "RelatedPerson", "Organization"], - ) - - relationship: fhirtypes.CodeableConceptType = Field( - None, - alias="relationship", - title="Beneficiary relationship to the subscriber", - description="The relationship of beneficiary (patient) to the subscriber.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | cancelled | draft | entered-in-error", - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "cancelled", "draft", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subrogation: bool = Field( - None, - alias="subrogation", - title="Reimbursement to insurer", - description=( - "When 'subrogation=true' this insurance instance has been included not " - "for adjudication but to provide insurers with the details to recover " - "costs." - ), - # if property is element of this resource. - element_property=True, - ) - subrogation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subrogation", title="Extension field for ``subrogation``." - ) - - subscriber: fhirtypes.ReferenceType = Field( - None, - alias="subscriber", - title="Subscriber to the policy", - description=( - "The party who has signed-up for or 'owns' the contractual relationship" - " to the policy or to whom the benefit of the policy for services " - "rendered to them or their family is due." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "RelatedPerson"], - ) - - subscriberId: fhirtypes.String = Field( - None, - alias="subscriberId", - title="ID assigned to the subscriber", - description="The insurer assigned ID for the Subscriber.", - # if property is element of this resource. - element_property=True, - ) - subscriberId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subscriberId", title="Extension field for ``subscriberId``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Coverage category such as medical or accident", - description=( - "The type of coverage: social program, medical plan, accident coverage " - "(workers compensation, auto), group health or payment by an individual" - " or organization." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Coverage`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "type", - "policyHolder", - "subscriber", - "subscriberId", - "beneficiary", - "dependent", - "relationship", - "period", - "payor", - "class", - "order", - "network", - "costToBeneficiary", - "subrogation", - "contract", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_980( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CoverageClass(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Additional coverage classifications. - A suite of underwriter specific classifiers. - """ - - resource_type = Field("CoverageClass", const=True) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Human readable description of the type and value", - description="A short description for the class.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Type of class such as 'group' or 'plan'", - description=( - "The type of classification for which an insurer-specific class label " - "or number and optional name is provided, for example may be used to " - "identify a class of coverage or employer group, Policy, Plan." - ), - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="Value associated with the type", - description=( - "The alphanumeric string value associated with the insurer issued " "label." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageClass`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "value", "name"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1496( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("value", "value__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class CoverageCostToBeneficiary(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Patient payments for services/products. - A suite of codes indicating the cost category and associated amount which - have been detailed in the policy and may have been included on the health - card. - """ - - resource_type = Field("CoverageCostToBeneficiary", const=True) - - exception: typing.List[fhirtypes.CoverageCostToBeneficiaryExceptionType] = Field( - None, - alias="exception", - title="Exceptions for patient payments", - description=( - "A suite of codes indicating exceptions or reductions to patient costs " - "and their effective periods." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Cost category", - description="The category of patient centric costs associated with treatment.", - # if property is element of this resource. - element_property=True, - ) - - valueMoney: fhirtypes.MoneyType = Field( - None, - alias="valueMoney", - title="The amount or percentage due from the beneficiary", - description="The amount due from the patient for the cost category.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="The amount or percentage due from the beneficiary", - description="The amount due from the patient for the cost category.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageCostToBeneficiary`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "valueQuantity", - "valueMoney", - "exception", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2725( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"value": ["valueMoney", "valueQuantity"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class CoverageCostToBeneficiaryException(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Exceptions for patient payments. - A suite of codes indicating exceptions or reductions to patient costs and - their effective periods. - """ - - resource_type = Field("CoverageCostToBeneficiaryException", const=True) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="The effective period of the exception", - description="The timeframe during when the exception is in force.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Exception category", - description="The code for the specific exception.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageCostToBeneficiaryException`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "period"] diff --git a/fhir/resources/coverageeligibilityrequest.py b/fhir/resources/coverageeligibilityrequest.py deleted file mode 100644 index 19045950..00000000 --- a/fhir/resources/coverageeligibilityrequest.py +++ /dev/null @@ -1,825 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CoverageEligibilityRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class CoverageEligibilityRequest(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - CoverageEligibilityRequest resource. - The CoverageEligibilityRequest provides patient and insurance coverage - information to an insurer for them to respond, in the form of an - CoverageEligibilityResponse, with information regarding whether the stated - coverage is valid and in-force and optionally to provide the insurance - details of the policy. - """ - - resource_type = Field("CoverageEligibilityRequest", const=True) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="Creation date", - description="The date when this resource was created.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - enterer: fhirtypes.ReferenceType = Field( - None, - alias="enterer", - title="Author", - description="Person who created the request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - facility: fhirtypes.ReferenceType = Field( - None, - alias="facility", - title="Servicing facility", - description="Facility where the services are intended to be provided.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for coverage eligiblity request", - description="A unique identifier assigned to this coverage eligiblity request.", - # if property is element of this resource. - element_property=True, - ) - - insurance: typing.List[fhirtypes.CoverageEligibilityRequestInsuranceType] = Field( - None, - alias="insurance", - title="Patient insurance information", - description=( - "Financial instruments for reimbursement for the health care products " - "and services." - ), - # if property is element of this resource. - element_property=True, - ) - - insurer: fhirtypes.ReferenceType = Field( - ..., - alias="insurer", - title="Coverage issuer", - description=( - "The Insurer who issued the coverage in question and is the recipient " - "of the request." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - item: typing.List[fhirtypes.CoverageEligibilityRequestItemType] = Field( - None, - alias="item", - title="Item to be evaluated for eligibiity", - description=( - "Service categories or billable services for which benefit details " - "and/or an authorization prior to service delivery may be required by " - "the payor." - ), - # if property is element of this resource. - element_property=True, - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="Intended recipient of products and services", - description=( - "The party who is the beneficiary of the supplied coverage and for whom" - " eligibility is sought." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - priority: fhirtypes.CodeableConceptType = Field( - None, - alias="priority", - title="Desired processing priority", - description="When the requestor expects the processor to complete processing.", - # if property is element of this resource. - element_property=True, - ) - - provider: fhirtypes.ReferenceType = Field( - None, - alias="provider", - title="Party responsible for the request", - description="The provider which is responsible for the request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - purpose: typing.List[fhirtypes.Code] = Field( - None, - alias="purpose", - title="auth-requirements | benefits | discovery | validation", - description=( - "Code to specify whether requesting: prior authorization requirements " - "for some service categories or billing codes; benefits for coverages " - "specified or discovered; discovery and return of coverages for the " - "patient; and/or validation that the specified coverage is in-force at " - "the date/period specified or 'now' if not specified." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["auth-requirements", "benefits", "discovery", "validation"], - ) - purpose__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_purpose", title="Extension field for ``purpose``.") - - servicedDate: fhirtypes.Date = Field( - None, - alias="servicedDate", - title="Estimated date or dates of service", - description=( - "The date or dates when the enclosed suite of services were performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - servicedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_servicedDate", title="Extension field for ``servicedDate``." - ) - - servicedPeriod: fhirtypes.PeriodType = Field( - None, - alias="servicedPeriod", - title="Estimated date or dates of service", - description=( - "The date or dates when the enclosed suite of services were performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | cancelled | draft | entered-in-error", - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "cancelled", "draft", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - supportingInfo: typing.List[ - fhirtypes.CoverageEligibilityRequestSupportingInfoType - ] = Field( - None, - alias="supportingInfo", - title="Supporting information", - description=( - "Additional information codes regarding exceptions, special " - "considerations, the condition, situation, prior or concurrent issues." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageEligibilityRequest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "priority", - "purpose", - "patient", - "servicedDate", - "servicedPeriod", - "created", - "enterer", - "provider", - "insurer", - "facility", - "supportingInfo", - "insurance", - "item", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2883( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("created", "created__ext"), - ("purpose", "purpose__ext"), - ("status", "status__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2883( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"serviced": ["servicedDate", "servicedPeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class CoverageEligibilityRequestInsurance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Patient insurance information. - Financial instruments for reimbursement for the health care products and - services. - """ - - resource_type = Field("CoverageEligibilityRequestInsurance", const=True) - - businessArrangement: fhirtypes.String = Field( - None, - alias="businessArrangement", - title="Additional provider contract number", - description=( - "A business agreement number established between the provider and the " - "insurer for special business processing purposes." - ), - # if property is element of this resource. - element_property=True, - ) - businessArrangement__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_businessArrangement", - title="Extension field for ``businessArrangement``.", - ) - - coverage: fhirtypes.ReferenceType = Field( - ..., - alias="coverage", - title="Insurance information", - description=( - "Reference to the insurance card level information contained in the " - "Coverage resource. The coverage issuing insurer will use these details" - " to locate the patient's actual coverage within the insurer's " - "information system." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Coverage"], - ) - - focal: bool = Field( - None, - alias="focal", - title="Applicable coverage", - description=( - "A flag to indicate that this Coverage is to be used for evaluation of " - "this request when set to true." - ), - # if property is element of this resource. - element_property=True, - ) - focal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_focal", title="Extension field for ``focal``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageEligibilityRequestInsurance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "focal", - "coverage", - "businessArrangement", - ] - - -class CoverageEligibilityRequestItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Item to be evaluated for eligibiity. - Service categories or billable services for which benefit details and/or an - authorization prior to service delivery may be required by the payor. - """ - - resource_type = Field("CoverageEligibilityRequestItem", const=True) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Benefit classification", - description=( - "Code to identify the general type of benefits under which products and" - " services are provided." - ), - # if property is element of this resource. - element_property=True, - ) - - detail: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="detail", - title="Product or service details", - description="The plan/proposal/order describing the proposed service in detail.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - diagnosis: typing.List[ - fhirtypes.CoverageEligibilityRequestItemDiagnosisType - ] = Field( - None, - alias="diagnosis", - title="Applicable diagnosis", - description="Patient diagnosis for which care is sought.", - # if property is element of this resource. - element_property=True, - ) - - facility: fhirtypes.ReferenceType = Field( - None, - alias="facility", - title="Servicing facility", - description="Facility where the services will be provided.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location", "Organization"], - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Product or service billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - productOrService: fhirtypes.CodeableConceptType = Field( - None, - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "This contains the product, service, drug or other billing code for the" - " item." - ), - # if property is element of this resource. - element_property=True, - ) - - provider: fhirtypes.ReferenceType = Field( - None, - alias="provider", - title="Perfoming practitioner", - description=( - "The practitioner who is responsible for the product or service to be " - "rendered to the patient." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - supportingInfoSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="supportingInfoSequence", - title="Applicable exception or supporting information", - description=( - "Exceptions, special conditions and supporting information applicable " - "for this service or product line." - ), - # if property is element of this resource. - element_property=True, - ) - supportingInfoSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_supportingInfoSequence", - title="Extension field for ``supportingInfoSequence``.", - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description="The amount charged to the patient by the provider for a single unit.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageEligibilityRequestItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "supportingInfoSequence", - "category", - "productOrService", - "modifier", - "provider", - "quantity", - "unitPrice", - "facility", - "diagnosis", - "detail", - ] - - -class CoverageEligibilityRequestItemDiagnosis(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Applicable diagnosis. - Patient diagnosis for which care is sought. - """ - - resource_type = Field("CoverageEligibilityRequestItemDiagnosis", const=True) - - diagnosisCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="diagnosisCodeableConcept", - title="Nature of illness or problem", - description=( - "The nature of illness or problem in a coded form or as a reference to " - "an external defined Condition." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e diagnosis[x] - one_of_many="diagnosis", - one_of_many_required=False, - ) - - diagnosisReference: fhirtypes.ReferenceType = Field( - None, - alias="diagnosisReference", - title="Nature of illness or problem", - description=( - "The nature of illness or problem in a coded form or as a reference to " - "an external defined Condition." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e diagnosis[x] - one_of_many="diagnosis", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageEligibilityRequestItemDiagnosis`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "diagnosisCodeableConcept", - "diagnosisReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4210( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "diagnosis": ["diagnosisCodeableConcept", "diagnosisReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class CoverageEligibilityRequestSupportingInfo(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Supporting information. - Additional information codes regarding exceptions, special considerations, - the condition, situation, prior or concurrent issues. - """ - - resource_type = Field("CoverageEligibilityRequestSupportingInfo", const=True) - - appliesToAll: bool = Field( - None, - alias="appliesToAll", - title="Applies to all items", - description=( - "The supporting materials are applicable for all detail items, " - "product/servce categories and specific billing codes." - ), - # if property is element of this resource. - element_property=True, - ) - appliesToAll__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_appliesToAll", title="Extension field for ``appliesToAll``." - ) - - information: fhirtypes.ReferenceType = Field( - ..., - alias="information", - title="Data to be provided", - description=( - "Additional data or information such as resources, documents, images " - "etc. including references to the data or the actual inclusion of the " - "data." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Information instance identifier", - description="A number to uniquely identify supporting information entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageEligibilityRequestSupportingInfo`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "information", - "appliesToAll", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4357( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/coverageeligibilityresponse.py b/fhir/resources/coverageeligibilityresponse.py deleted file mode 100644 index 19658660..00000000 --- a/fhir/resources/coverageeligibilityresponse.py +++ /dev/null @@ -1,879 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CoverageEligibilityResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class CoverageEligibilityResponse(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - CoverageEligibilityResponse resource. - This resource provides eligibility and plan details from the processing of - an CoverageEligibilityRequest resource. - """ - - resource_type = Field("CoverageEligibilityResponse", const=True) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="Response creation date", - description="The date this resource was created.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - disposition: fhirtypes.String = Field( - None, - alias="disposition", - title="Disposition Message", - description="A human readable description of the status of the adjudication.", - # if property is element of this resource. - element_property=True, - ) - disposition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_disposition", title="Extension field for ``disposition``." - ) - - error: typing.List[fhirtypes.CoverageEligibilityResponseErrorType] = Field( - None, - alias="error", - title="Processing errors", - description="Errors encountered during the processing of the request.", - # if property is element of this resource. - element_property=True, - ) - - form: fhirtypes.CodeableConceptType = Field( - None, - alias="form", - title="Printed form identifier", - description="A code for the form to be used for printing the content.", - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for coverage eligiblity request", - description="A unique identifier assigned to this coverage eligiblity request.", - # if property is element of this resource. - element_property=True, - ) - - insurance: typing.List[fhirtypes.CoverageEligibilityResponseInsuranceType] = Field( - None, - alias="insurance", - title="Patient insurance information", - description=( - "Financial instruments for reimbursement for the health care products " - "and services." - ), - # if property is element of this resource. - element_property=True, - ) - - insurer: fhirtypes.ReferenceType = Field( - ..., - alias="insurer", - title="Coverage issuer", - description=( - "The Insurer who issued the coverage in question and is the author of " - "the response." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - outcome: fhirtypes.Code = Field( - None, - alias="outcome", - title="queued | complete | error | partial", - description="The outcome of the request processing.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["queued", "complete", "error", "partial"], - ) - outcome__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_outcome", title="Extension field for ``outcome``." - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="Intended recipient of products and services", - description=( - "The party who is the beneficiary of the supplied coverage and for whom" - " eligibility is sought." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - preAuthRef: fhirtypes.String = Field( - None, - alias="preAuthRef", - title="Preauthorization reference", - description=( - "A reference from the Insurer to which these services pertain to be " - "used on further communication and as proof that the request occurred." - ), - # if property is element of this resource. - element_property=True, - ) - preAuthRef__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_preAuthRef", title="Extension field for ``preAuthRef``." - ) - - purpose: typing.List[fhirtypes.Code] = Field( - None, - alias="purpose", - title="auth-requirements | benefits | discovery | validation", - description=( - "Code to specify whether requesting: prior authorization requirements " - "for some service categories or billing codes; benefits for coverages " - "specified or discovered; discovery and return of coverages for the " - "patient; and/or validation that the specified coverage is in-force at " - "the date/period specified or 'now' if not specified." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["auth-requirements", "benefits", "discovery", "validation"], - ) - purpose__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_purpose", title="Extension field for ``purpose``.") - - request: fhirtypes.ReferenceType = Field( - ..., - alias="request", - title="Eligibility request reference", - description="Reference to the original request resource.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CoverageEligibilityRequest"], - ) - - requestor: fhirtypes.ReferenceType = Field( - None, - alias="requestor", - title="Party responsible for the request", - description="The provider which is responsible for the request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - servicedDate: fhirtypes.Date = Field( - None, - alias="servicedDate", - title="Estimated date or dates of service", - description=( - "The date or dates when the enclosed suite of services were performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - servicedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_servicedDate", title="Extension field for ``servicedDate``." - ) - - servicedPeriod: fhirtypes.PeriodType = Field( - None, - alias="servicedPeriod", - title="Estimated date or dates of service", - description=( - "The date or dates when the enclosed suite of services were performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | cancelled | draft | entered-in-error", - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "cancelled", "draft", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageEligibilityResponse`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "purpose", - "patient", - "servicedDate", - "servicedPeriod", - "created", - "requestor", - "request", - "outcome", - "disposition", - "insurer", - "insurance", - "preAuthRef", - "form", - "error", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2970( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("created", "created__ext"), - ("outcome", "outcome__ext"), - ("purpose", "purpose__ext"), - ("status", "status__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2970( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"serviced": ["servicedDate", "servicedPeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class CoverageEligibilityResponseError(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Processing errors. - Errors encountered during the processing of the request. - """ - - resource_type = Field("CoverageEligibilityResponseError", const=True) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Error code detailing processing issues", - description=( - "An error code,from a specified code system, which details why the " - "eligibility check could not be performed." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageEligibilityResponseError`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code"] - - -class CoverageEligibilityResponseInsurance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Patient insurance information. - Financial instruments for reimbursement for the health care products and - services. - """ - - resource_type = Field("CoverageEligibilityResponseInsurance", const=True) - - benefitPeriod: fhirtypes.PeriodType = Field( - None, - alias="benefitPeriod", - title="When the benefits are applicable", - description="The term of the benefits documented in this response.", - # if property is element of this resource. - element_property=True, - ) - - coverage: fhirtypes.ReferenceType = Field( - ..., - alias="coverage", - title="Insurance information", - description=( - "Reference to the insurance card level information contained in the " - "Coverage resource. The coverage issuing insurer will use these details" - " to locate the patient's actual coverage within the insurer's " - "information system." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Coverage"], - ) - - inforce: bool = Field( - None, - alias="inforce", - title="Coverage inforce indicator", - description=( - "Flag indicating if the coverage provided is inforce currently if no " - "service date(s) specified or for the whole duration of the service " - "dates." - ), - # if property is element of this resource. - element_property=True, - ) - inforce__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_inforce", title="Extension field for ``inforce``." - ) - - item: typing.List[fhirtypes.CoverageEligibilityResponseInsuranceItemType] = Field( - None, - alias="item", - title="Benefits and authorization details", - description=( - "Benefits and optionally current balances, and authorization details by" - " category or service." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageEligibilityResponseInsurance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "coverage", - "inforce", - "benefitPeriod", - "item", - ] - - -class CoverageEligibilityResponseInsuranceItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Benefits and authorization details. - Benefits and optionally current balances, and authorization details by - category or service. - """ - - resource_type = Field("CoverageEligibilityResponseInsuranceItem", const=True) - - authorizationRequired: bool = Field( - None, - alias="authorizationRequired", - title="Authorization required flag", - description=( - "A boolean flag indicating whether a preauthorization is required prior" - " to actual service delivery." - ), - # if property is element of this resource. - element_property=True, - ) - authorizationRequired__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_authorizationRequired", - title="Extension field for ``authorizationRequired``.", - ) - - authorizationSupporting: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="authorizationSupporting", - title="Type of required supporting materials", - description=( - "Codes or comments regarding information or actions associated with the" - " preauthorization." - ), - # if property is element of this resource. - element_property=True, - ) - - authorizationUrl: fhirtypes.Uri = Field( - None, - alias="authorizationUrl", - title="Preauthorization requirements endpoint", - description=( - "A web location for obtaining requirements or descriptive information " - "regarding the preauthorization." - ), - # if property is element of this resource. - element_property=True, - ) - authorizationUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_authorizationUrl", - title="Extension field for ``authorizationUrl``.", - ) - - benefit: typing.List[ - fhirtypes.CoverageEligibilityResponseInsuranceItemBenefitType - ] = Field( - None, - alias="benefit", - title="Benefit Summary", - description="Benefits used to date.", - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Benefit classification", - description=( - "Code to identify the general type of benefits under which products and" - " services are provided." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Description of the benefit or services covered", - description="A richer description of the benefit or services covered.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - excluded: bool = Field( - None, - alias="excluded", - title="Excluded from the plan", - description=( - "True if the indicated class of service is excluded from the plan, " - "missing or False indicates the product or service is included in the " - "coverage." - ), - # if property is element of this resource. - element_property=True, - ) - excluded__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_excluded", title="Extension field for ``excluded``." - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Product or service billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Short name for the benefit", - description="A short name or tag for the benefit.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - network: fhirtypes.CodeableConceptType = Field( - None, - alias="network", - title="In or out of network", - description=( - "Is a flag to indicate whether the benefits refer to in-network " - "providers or out-of-network providers." - ), - # if property is element of this resource. - element_property=True, - ) - - productOrService: fhirtypes.CodeableConceptType = Field( - None, - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "This contains the product, service, drug or other billing code for the" - " item." - ), - # if property is element of this resource. - element_property=True, - ) - - provider: fhirtypes.ReferenceType = Field( - None, - alias="provider", - title="Performing practitioner", - description=( - "The practitioner who is eligible for the provision of the product or " - "service." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - term: fhirtypes.CodeableConceptType = Field( - None, - alias="term", - title="Annual or lifetime", - description=( - "The term or period of the values such as 'maximum lifetime benefit' or" - " 'maximum annual visits'." - ), - # if property is element of this resource. - element_property=True, - ) - - unit: fhirtypes.CodeableConceptType = Field( - None, - alias="unit", - title="Individual or family", - description="Indicates if the benefits apply to an individual or to the family.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageEligibilityResponseInsuranceItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "category", - "productOrService", - "modifier", - "provider", - "excluded", - "name", - "description", - "network", - "unit", - "term", - "benefit", - "authorizationRequired", - "authorizationSupporting", - "authorizationUrl", - ] - - -class CoverageEligibilityResponseInsuranceItemBenefit(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Benefit Summary. - Benefits used to date. - """ - - resource_type = Field("CoverageEligibilityResponseInsuranceItemBenefit", const=True) - - allowedMoney: fhirtypes.MoneyType = Field( - None, - alias="allowedMoney", - title="Benefits allowed", - description="The quantity of the benefit which is permitted under the coverage.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e allowed[x] - one_of_many="allowed", - one_of_many_required=False, - ) - - allowedString: fhirtypes.String = Field( - None, - alias="allowedString", - title="Benefits allowed", - description="The quantity of the benefit which is permitted under the coverage.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e allowed[x] - one_of_many="allowed", - one_of_many_required=False, - ) - allowedString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_allowedString", title="Extension field for ``allowedString``." - ) - - allowedUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="allowedUnsignedInt", - title="Benefits allowed", - description="The quantity of the benefit which is permitted under the coverage.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e allowed[x] - one_of_many="allowed", - one_of_many_required=False, - ) - allowedUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_allowedUnsignedInt", - title="Extension field for ``allowedUnsignedInt``.", - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Benefit classification", - description="Classification of benefit being provided.", - # if property is element of this resource. - element_property=True, - ) - - usedMoney: fhirtypes.MoneyType = Field( - None, - alias="usedMoney", - title="Benefits used", - description="The quantity of the benefit which have been consumed to date.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e used[x] - one_of_many="used", - one_of_many_required=False, - ) - - usedString: fhirtypes.String = Field( - None, - alias="usedString", - title="Benefits used", - description="The quantity of the benefit which have been consumed to date.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e used[x] - one_of_many="used", - one_of_many_required=False, - ) - usedString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_usedString", title="Extension field for ``usedString``." - ) - - usedUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="usedUnsignedInt", - title="Benefits used", - description="The quantity of the benefit which have been consumed to date.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e used[x] - one_of_many="used", - one_of_many_required=False, - ) - usedUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_usedUnsignedInt", title="Extension field for ``usedUnsignedInt``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``CoverageEligibilityResponseInsuranceItemBenefit`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "allowedUnsignedInt", - "allowedString", - "allowedMoney", - "usedUnsignedInt", - "usedString", - "usedMoney", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_5021( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "allowed": ["allowedMoney", "allowedString", "allowedUnsignedInt"], - "used": ["usedMoney", "usedString", "usedUnsignedInt"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/datarequirement.py b/fhir/resources/datarequirement.py deleted file mode 100644 index f2daf7b5..00000000 --- a/fhir/resources/datarequirement.py +++ /dev/null @@ -1,674 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DataRequirement -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import element, fhirtypes - - -class DataRequirement(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Describes a required data item. - Describes a required data item for evaluation in terms of the type of data, - and optional code or date-based filters of the data. - """ - - resource_type = Field("DataRequirement", const=True) - - codeFilter: typing.List[fhirtypes.DataRequirementCodeFilterType] = Field( - None, - alias="codeFilter", - title="What codes are expected", - description=( - "Code filters specify additional constraints on the data, specifying " - "the value set of interest for a particular element of the data. Each " - "code filter defines an additional constraint on the data, i.e. code " - "filters are AND'ed, not OR'ed." - ), - # if property is element of this resource. - element_property=True, - ) - - dateFilter: typing.List[fhirtypes.DataRequirementDateFilterType] = Field( - None, - alias="dateFilter", - title="What dates/date ranges are expected", - description=( - "Date filters specify additional constraints on the data in terms of " - "the applicable date range for specific elements. Each date filter " - "specifies an additional constraint on the data, i.e. date filters are " - "AND'ed, not OR'ed." - ), - # if property is element of this resource. - element_property=True, - ) - - limit: fhirtypes.PositiveInt = Field( - None, - alias="limit", - title="Number of results", - description=( - "Specifies a maximum number of results that are required (uses the " - "_count search parameter)." - ), - # if property is element of this resource. - element_property=True, - ) - limit__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_limit", title="Extension field for ``limit``." - ) - - mustSupport: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="mustSupport", - title=( - "Indicates specific structure elements that are referenced by the " - "knowledge module" - ), - description=( - "Indicates that specific elements of the type are referenced by the " - "knowledge module and must be supported by the consumer in order to " - "obtain an effective evaluation. This does not mean that a value is " - "required for this element, only that the consuming system must " - "understand the element and be able to provide values for it if they " - "are available. The value of mustSupport SHALL be a FHIRPath " - "resolveable on the type of the DataRequirement. The path SHALL consist" - " only of identifiers, constant indexers, and .resolve() (see the " - "[Simple FHIRPath Profile](fhirpath.html#simple) for full details)." - ), - # if property is element of this resource. - element_property=True, - ) - mustSupport__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_mustSupport", title="Extension field for ``mustSupport``.") - - profile: typing.List[fhirtypes.Canonical] = Field( - None, - alias="profile", - title="The profile of the required data", - description=( - "The profile of the required data, specified as the uri of the profile " - "definition." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - profile__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_profile", title="Extension field for ``profile``.") - - sort: typing.List[fhirtypes.DataRequirementSortType] = Field( - None, - alias="sort", - title="Order of the results", - description="Specifies the order of the results to be returned.", - # if property is element of this resource. - element_property=True, - ) - - subjectCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="subjectCodeableConcept", - title=( - "E.g. Patient, Practitioner, RelatedPerson, Organization, Location, " - "Device" - ), - description=( - "The intended subjects of the data requirement. If this element is not " - "provided, a Patient subject is assumed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - ) - - subjectReference: fhirtypes.ReferenceType = Field( - None, - alias="subjectReference", - title=( - "E.g. Patient, Practitioner, RelatedPerson, Organization, Location, " - "Device" - ), - description=( - "The intended subjects of the data requirement. If this element is not " - "provided, a Patient subject is assumed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Group"], - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="The type of the required data", - description=( - "The type of the required data, specified as the type name of a " - "resource. For profiles, this value is set to the type of the base " - "resource of the profile." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DataRequirement`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "type", - "profile", - "subjectCodeableConcept", - "subjectReference", - "mustSupport", - "codeFilter", - "dateFilter", - "limit", - "sort", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1731( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1731( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"subject": ["subjectCodeableConcept", "subjectReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class DataRequirementCodeFilter(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What codes are expected. - Code filters specify additional constraints on the data, specifying the - value set of interest for a particular element of the data. Each code - filter defines an additional constraint on the data, i.e. code filters are - AND'ed, not OR'ed. - """ - - resource_type = Field("DataRequirementCodeFilter", const=True) - - code: typing.List[fhirtypes.CodingType] = Field( - None, - alias="code", - title="What code is expected", - description=( - "The codes for the code filter. If values are given, the filter will " - "return only those data items for which the code-valued attribute " - "specified by the path has a value that is one of the specified codes. " - "If codes are specified in addition to a value set, the filter returns " - "items matching a code in the value set or one of the specified codes." - ), - # if property is element of this resource. - element_property=True, - ) - - path: fhirtypes.String = Field( - None, - alias="path", - title="A code-valued attribute to filter on", - description=( - "The code-valued attribute of the filter. The specified path SHALL be a" - " FHIRPath resolveable on the specified type of the DataRequirement, " - "and SHALL consist only of identifiers, constant indexers, and " - ".resolve(). The path is allowed to contain qualifiers (.) to traverse " - "sub-elements, as well as indexers ([x]) to traverse multiple-" - "cardinality sub-elements (see the [Simple FHIRPath " - "Profile](fhirpath.html#simple) for full details). Note that the index " - "must be an integer constant. The path must resolve to an element of " - "type code, Coding, or CodeableConcept." - ), - # if property is element of this resource. - element_property=True, - ) - path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_path", title="Extension field for ``path``." - ) - - searchParam: fhirtypes.String = Field( - None, - alias="searchParam", - title="A coded (token) parameter to search on", - description=( - "A token parameter that refers to a search parameter defined on the " - "specified type of the DataRequirement, and which searches on elements " - "of type code, Coding, or CodeableConcept." - ), - # if property is element of this resource. - element_property=True, - ) - searchParam__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_searchParam", title="Extension field for ``searchParam``." - ) - - valueSet: fhirtypes.Canonical = Field( - None, - alias="valueSet", - title="Valueset for the filter", - description=( - "The valueset for the code filter. The valueSet and code elements are " - "additive. If valueSet is specified, the filter will return only those " - "data items for which the value of the code-valued element specified in" - " the path is a member of the specified valueset." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - valueSet__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueSet", title="Extension field for ``valueSet``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DataRequirementCodeFilter`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "path", "searchParam", "valueSet", "code"] - - -class DataRequirementDateFilter(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What dates/date ranges are expected. - Date filters specify additional constraints on the data in terms of the - applicable date range for specific elements. Each date filter specifies an - additional constraint on the data, i.e. date filters are AND'ed, not OR'ed. - """ - - resource_type = Field("DataRequirementDateFilter", const=True) - - path: fhirtypes.String = Field( - None, - alias="path", - title="A date-valued attribute to filter on", - description=( - "The date-valued attribute of the filter. The specified path SHALL be a" - " FHIRPath resolveable on the specified type of the DataRequirement, " - "and SHALL consist only of identifiers, constant indexers, and " - ".resolve(). The path is allowed to contain qualifiers (.) to traverse " - "sub-elements, as well as indexers ([x]) to traverse multiple-" - "cardinality sub-elements (see the [Simple FHIRPath " - "Profile](fhirpath.html#simple) for full details). Note that the index " - "must be an integer constant. The path must resolve to an element of " - "type date, dateTime, Period, Schedule, or Timing." - ), - # if property is element of this resource. - element_property=True, - ) - path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_path", title="Extension field for ``path``." - ) - - searchParam: fhirtypes.String = Field( - None, - alias="searchParam", - title="A date valued parameter to search on", - description=( - "A date parameter that refers to a search parameter defined on the " - "specified type of the DataRequirement, and which searches on elements " - "of type date, dateTime, Period, Schedule, or Timing." - ), - # if property is element of this resource. - element_property=True, - ) - searchParam__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_searchParam", title="Extension field for ``searchParam``." - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="The value of the filter, as a Period, DateTime, or Duration value", - description=( - "The value of the filter. If period is specified, the filter will " - "return only those data items that fall within the bounds determined by" - " the Period, inclusive of the period boundaries. If dateTime is " - "specified, the filter will return only those data items that are equal" - " to the specified dateTime. If a Duration is specified, the filter " - "will return only those data items that fall within Duration before " - "now." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueDuration: fhirtypes.DurationType = Field( - None, - alias="valueDuration", - title="The value of the filter, as a Period, DateTime, or Duration value", - description=( - "The value of the filter. If period is specified, the filter will " - "return only those data items that fall within the bounds determined by" - " the Period, inclusive of the period boundaries. If dateTime is " - "specified, the filter will return only those data items that are equal" - " to the specified dateTime. If a Duration is specified, the filter " - "will return only those data items that fall within Duration before " - "now." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valuePeriod: fhirtypes.PeriodType = Field( - None, - alias="valuePeriod", - title="The value of the filter, as a Period, DateTime, or Duration value", - description=( - "The value of the filter. If period is specified, the filter will " - "return only those data items that fall within the bounds determined by" - " the Period, inclusive of the period boundaries. If dateTime is " - "specified, the filter will return only those data items that are equal" - " to the specified dateTime. If a Duration is specified, the filter " - "will return only those data items that fall within Duration before " - "now." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DataRequirementDateFilter`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "path", - "searchParam", - "valueDateTime", - "valuePeriod", - "valueDuration", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2725( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": ["valueDateTime", "valueDuration", "valuePeriod"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class DataRequirementSort(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Order of the results. - Specifies the order of the results to be returned. - """ - - resource_type = Field("DataRequirementSort", const=True) - - direction: fhirtypes.Code = Field( - None, - alias="direction", - title="ascending | descending", - description="The direction of the sort, ascending or descending.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["ascending", "descending"], - ) - direction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_direction", title="Extension field for ``direction``." - ) - - path: fhirtypes.String = Field( - None, - alias="path", - title="The name of the attribute to perform the sort", - description=( - "The attribute of the sort. The specified path must be resolvable from " - "the type of the required data. The path is allowed to contain " - "qualifiers (.) to traverse sub-elements, as well as indexers ([x]) to " - "traverse multiple-cardinality sub-elements. Note that the index must " - "be an integer constant." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_path", title="Extension field for ``path``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DataRequirementSort`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "path", "direction"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2155( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("direction", "direction__ext"), ("path", "path__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/detectedissue.py b/fhir/resources/detectedissue.py deleted file mode 100644 index 02ab8088..00000000 --- a/fhir/resources/detectedissue.py +++ /dev/null @@ -1,440 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DetectedIssue -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class DetectedIssue(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Clinical issue with action. - Indicates an actual or potential clinical issue with or between one or more - active or proposed clinical actions for a patient; e.g. Drug-drug - interaction, Ineffective treatment frequency, Procedure-condition conflict, - etc. - """ - - resource_type = Field("DetectedIssue", const=True) - - author: fhirtypes.ReferenceType = Field( - None, - alias="author", - title="The provider or device that identified the issue", - description=( - "Individual or device responsible for the issue being raised. For " - "example, a decision support application or a pharmacist conducting a " - "medication review." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Device"], - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Issue Category, e.g. drug-drug, duplicate therapy, etc.", - description="Identifies the general type of issue identified.", - # if property is element of this resource. - element_property=True, - ) - - detail: fhirtypes.String = Field( - None, - alias="detail", - title="Description and context", - description="A textual explanation of the detected issue.", - # if property is element of this resource. - element_property=True, - ) - detail__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_detail", title="Extension field for ``detail``." - ) - - evidence: typing.List[fhirtypes.DetectedIssueEvidenceType] = Field( - None, - alias="evidence", - title="Supporting evidence", - description=( - "Supporting evidence or manifestations that provide the basis for " - "identifying the detected issue such as a GuidanceResponse or " - "MeasureReport." - ), - # if property is element of this resource. - element_property=True, - ) - - identifiedDateTime: fhirtypes.DateTime = Field( - None, - alias="identifiedDateTime", - title="When identified", - description="The date or period when the detected issue was initially identified.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e identified[x] - one_of_many="identified", - one_of_many_required=False, - ) - identifiedDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_identifiedDateTime", - title="Extension field for ``identifiedDateTime``.", - ) - - identifiedPeriod: fhirtypes.PeriodType = Field( - None, - alias="identifiedPeriod", - title="When identified", - description="The date or period when the detected issue was initially identified.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e identified[x] - one_of_many="identified", - one_of_many_required=False, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Unique id for the detected issue", - description="Business identifier associated with the detected issue record.", - # if property is element of this resource. - element_property=True, - ) - - implicated: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="implicated", - title="Problem resource", - description=( - "Indicates the resource representing the current activity or proposed " - "activity that is potentially problematic." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - mitigation: typing.List[fhirtypes.DetectedIssueMitigationType] = Field( - None, - alias="mitigation", - title="Step taken to address", - description=( - "Indicates an action that has been taken or is committed to reduce or " - "eliminate the likelihood of the risk identified by the detected issue " - "from manifesting. Can also reflect an observation of known mitigating" - " factors that may reduce/eliminate the need for any action." - ), - # if property is element of this resource. - element_property=True, - ) - - patient: fhirtypes.ReferenceType = Field( - None, - alias="patient", - title="Associated patient", - description=( - "Indicates the patient whose record the detected issue is associated " - "with." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - reference: fhirtypes.Uri = Field( - None, - alias="reference", - title="Authority for issue", - description=( - "The literature, knowledge-base or similar reference that describes the" - " propensity for the detected issue identified." - ), - # if property is element of this resource. - element_property=True, - ) - reference__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_reference", title="Extension field for ``reference``." - ) - - severity: fhirtypes.Code = Field( - None, - alias="severity", - title="high | moderate | low", - description=( - "Indicates the degree of importance associated with the identified " - "issue based on the potential impact on the patient." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["high", "moderate", "low"], - ) - severity__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_severity", title="Extension field for ``severity``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="registered | preliminary | final | amended +", - description="Indicates the status of the detected issue.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["registered", "preliminary", "final", "amended", "+"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DetectedIssue`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "code", - "severity", - "patient", - "identifiedDateTime", - "identifiedPeriod", - "author", - "implicated", - "evidence", - "detail", - "reference", - "mitigation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1492( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1492( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"identified": ["identifiedDateTime", "identifiedPeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class DetectedIssueEvidence(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Supporting evidence. - Supporting evidence or manifestations that provide the basis for - identifying the detected issue such as a GuidanceResponse or MeasureReport. - """ - - resource_type = Field("DetectedIssueEvidence", const=True) - - code: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="code", - title="Manifestation", - description="A manifestation that led to the recording of this detected issue.", - # if property is element of this resource. - element_property=True, - ) - - detail: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="detail", - title="Supporting information", - description=( - "Links to resources that constitute evidence for the detected issue " - "such as a GuidanceResponse or MeasureReport." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DetectedIssueEvidence`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "detail"] - - -class DetectedIssueMitigation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Step taken to address. - Indicates an action that has been taken or is committed to reduce or - eliminate the likelihood of the risk identified by the detected issue from - manifesting. Can also reflect an observation of known mitigating factors - that may reduce/eliminate the need for any action. - """ - - resource_type = Field("DetectedIssueMitigation", const=True) - - action: fhirtypes.CodeableConceptType = Field( - ..., - alias="action", - title="What mitigation?", - description=( - "Describes the action that was taken or the observation that was made " - "that reduces/eliminates the risk associated with the identified issue." - ), - # if property is element of this resource. - element_property=True, - ) - - author: fhirtypes.ReferenceType = Field( - None, - alias="author", - title="Who is committing?", - description=( - "Identifies the practitioner who determined the mitigation and takes " - "responsibility for the mitigation step occurring." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date committed", - description="Indicates when the mitigating action was documented.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DetectedIssueMitigation`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "action", "date", "author"] diff --git a/fhir/resources/device.py b/fhir/resources/device.py deleted file mode 100644 index b2197510..00000000 --- a/fhir/resources/device.py +++ /dev/null @@ -1,866 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Device -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Device(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Item used in healthcare. - A type of a manufactured item that is used in the provision of healthcare - without being substantially changed through that activity. The device may - be a medical or non-medical device. - """ - - resource_type = Field("Device", const=True) - - contact: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="contact", - title="Details for human/organization for support", - description=( - "Contact details for an organization or a particular human that is " - "responsible for the device." - ), - # if property is element of this resource. - element_property=True, - ) - - definition: fhirtypes.ReferenceType = Field( - None, - alias="definition", - title="The reference to the definition for the device", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DeviceDefinition"], - ) - - deviceName: typing.List[fhirtypes.DeviceDeviceNameType] = Field( - None, - alias="deviceName", - title="The name of the device as given by the manufacturer", - description=( - "This represents the manufacturer's name of the device as provided by " - "the device, from a UDI label, or by a person describing the Device. " - "This typically would be used when a person provides the name(s) or " - "when the device represents one of the names available from " - "DeviceDefinition." - ), - # if property is element of this resource. - element_property=True, - ) - - distinctIdentifier: fhirtypes.String = Field( - None, - alias="distinctIdentifier", - title="The distinct identification string", - description=( - "The distinct identification string as required by regulation for a " - "human cell, tissue, or cellular and tissue-based product." - ), - # if property is element of this resource. - element_property=True, - ) - distinctIdentifier__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_distinctIdentifier", - title="Extension field for ``distinctIdentifier``.", - ) - - expirationDate: fhirtypes.DateTime = Field( - None, - alias="expirationDate", - title="Date and time of expiry of this device (if applicable)", - description=( - "The date and time beyond which this device is no longer valid or " - "should not be used (if applicable)." - ), - # if property is element of this resource. - element_property=True, - ) - expirationDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expirationDate", title="Extension field for ``expirationDate``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Instance identifier", - description=( - "Unique instance identifiers assigned to a device by manufacturers " - "other organizations or owners." - ), - # if property is element of this resource. - element_property=True, - ) - - location: fhirtypes.ReferenceType = Field( - None, - alias="location", - title="Where the device is found", - description="The place where the device can be found.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - lotNumber: fhirtypes.String = Field( - None, - alias="lotNumber", - title="Lot number of manufacture", - description="Lot number assigned by the manufacturer.", - # if property is element of this resource. - element_property=True, - ) - lotNumber__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lotNumber", title="Extension field for ``lotNumber``." - ) - - manufactureDate: fhirtypes.DateTime = Field( - None, - alias="manufactureDate", - title="Date when the device was made", - description="The date and time when the device was manufactured.", - # if property is element of this resource. - element_property=True, - ) - manufactureDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_manufactureDate", title="Extension field for ``manufactureDate``." - ) - - manufacturer: fhirtypes.String = Field( - None, - alias="manufacturer", - title="Name of device manufacturer", - description="A name of the manufacturer.", - # if property is element of this resource. - element_property=True, - ) - manufacturer__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_manufacturer", title="Extension field for ``manufacturer``." - ) - - modelNumber: fhirtypes.String = Field( - None, - alias="modelNumber", - title="The model number for the device", - description=None, - # if property is element of this resource. - element_property=True, - ) - modelNumber__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_modelNumber", title="Extension field for ``modelNumber``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Device notes and comments", - description=( - "Descriptive information, usage information or implantation information" - " that is not captured in an existing element." - ), - # if property is element of this resource. - element_property=True, - ) - - owner: fhirtypes.ReferenceType = Field( - None, - alias="owner", - title="Organization responsible for device", - description=( - "An organization that is responsible for the provision and ongoing " - "maintenance of the device." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - parent: fhirtypes.ReferenceType = Field( - None, - alias="parent", - title="The parent device", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - partNumber: fhirtypes.String = Field( - None, - alias="partNumber", - title="The part number of the device", - description=None, - # if property is element of this resource. - element_property=True, - ) - partNumber__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_partNumber", title="Extension field for ``partNumber``." - ) - - patient: fhirtypes.ReferenceType = Field( - None, - alias="patient", - title="Patient to whom Device is affixed", - description="Patient information, If the device is affixed to a person.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - property: typing.List[fhirtypes.DevicePropertyType] = Field( - None, - alias="property", - title=( - "The actual configuration settings of a device as it actually operates," - " e.g., regulation status, time properties" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - safety: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="safety", - title="Safety Characteristics of Device", - description=( - "Provides additional safety characteristics about a medical device. " - "For example devices containing latex." - ), - # if property is element of this resource. - element_property=True, - ) - - serialNumber: fhirtypes.String = Field( - None, - alias="serialNumber", - title="Serial number assigned by the manufacturer", - description=( - "The serial number assigned by the organization when the device was " - "manufactured." - ), - # if property is element of this resource. - element_property=True, - ) - serialNumber__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_serialNumber", title="Extension field for ``serialNumber``." - ) - - specialization: typing.List[fhirtypes.DeviceSpecializationType] = Field( - None, - alias="specialization", - title=( - "The capabilities supported on a device, the standards to which the " - "device conforms for a particular purpose, and used for the " - "communication" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | inactive | entered-in-error | unknown", - description="Status of the Device availability.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "inactive", "entered-in-error", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReason: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="statusReason", - title=( - "online | paused | standby | offline | not-ready | transduc-discon | " - "hw-discon | off" - ), - description="Reason for the dtatus of the Device availability.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="The kind or type of device", - description=None, - # if property is element of this resource. - element_property=True, - ) - - udiCarrier: typing.List[fhirtypes.DeviceUdiCarrierType] = Field( - None, - alias="udiCarrier", - title="Unique Device Identifier (UDI) Barcode string", - description=( - "Unique device identifier (UDI) assigned to device label or package. " - "Note that the Device may include multiple udiCarriers as it either may" - " include just the udiCarrier for the jurisdiction it is sold, or for " - "multiple jurisdictions it could have been sold." - ), - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title="Network address to contact device", - description="A network address on which the device may be contacted directly.", - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - version: typing.List[fhirtypes.DeviceVersionType] = Field( - None, - alias="version", - title=( - "The actual design of the device or software version running on the " - "device" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Device`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "definition", - "udiCarrier", - "status", - "statusReason", - "distinctIdentifier", - "manufacturer", - "manufactureDate", - "expirationDate", - "lotNumber", - "serialNumber", - "deviceName", - "modelNumber", - "partNumber", - "type", - "specialization", - "version", - "property", - "patient", - "owner", - "contact", - "location", - "url", - "note", - "safety", - "parent", - ] - - -class DeviceDeviceName(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The name of the device as given by the manufacturer. - This represents the manufacturer's name of the device as provided by the - device, from a UDI label, or by a person describing the Device. This - typically would be used when a person provides the name(s) or when the - device represents one of the names available from DeviceDefinition. - """ - - resource_type = Field("DeviceDeviceName", const=True) - - name: fhirtypes.String = Field( - None, - alias="name", - title="The name of the device", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title=( - "udi-label-name | user-friendly-name | patient-reported-name | " - "manufacturer-name | model-name | other" - ), - description=( - "The type of deviceName. UDILabelName | UserFriendlyName | " - "PatientReportedName | ManufactureDeviceName | ModelName." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "udi-label-name", - "user-friendly-name", - "patient-reported-name", - "manufacturer-name", - "model-name", - "other", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceDeviceName`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "name", "type"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1738( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class DeviceProperty(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The actual configuration settings of a device as it actually operates, - e.g., regulation status, time properties. - """ - - resource_type = Field("DeviceProperty", const=True) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title=( - "Code that specifies the property DeviceDefinitionPropetyCode " - "(Extensible)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - valueCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="valueCode", - title="Property value as a code, e.g., NTP4 (synced to NTP)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - valueQuantity: typing.List[fhirtypes.QuantityType] = Field( - None, - alias="valueQuantity", - title="Property value as a quantity", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceProperty`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "valueQuantity", - "valueCode", - ] - - -class DeviceSpecialization(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The capabilities supported on a device, the standards to which the device - conforms for a particular purpose, and used for the communication. - """ - - resource_type = Field("DeviceSpecialization", const=True) - - systemType: fhirtypes.CodeableConceptType = Field( - ..., - alias="systemType", - title="The standard that is used to operate and communicate", - description=None, - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="The version of the standard that is used to operate and communicate", - description=None, - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceSpecialization`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "systemType", "version"] - - -class DeviceUdiCarrier(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Unique Device Identifier (UDI) Barcode string. - Unique device identifier (UDI) assigned to device label or package. Note - that the Device may include multiple udiCarriers as it either may include - just the udiCarrier for the jurisdiction it is sold, or for multiple - jurisdictions it could have been sold. - """ - - resource_type = Field("DeviceUdiCarrier", const=True) - - carrierAIDC: fhirtypes.Base64Binary = Field( - None, - alias="carrierAIDC", - title="UDI Machine Readable Barcode String", - description=( - "The full UDI carrier of the Automatic Identification and Data Capture " - "(AIDC) technology representation of the barcode string as printed on " - "the packaging of the device - e.g., a barcode or RFID. Because of " - "limitations on character sets in XML and the need to round-trip JSON " - "data through XML, AIDC Formats *SHALL* be base64 encoded." - ), - # if property is element of this resource. - element_property=True, - ) - carrierAIDC__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_carrierAIDC", title="Extension field for ``carrierAIDC``." - ) - - carrierHRF: fhirtypes.String = Field( - None, - alias="carrierHRF", - title="UDI Human Readable Barcode String", - description=( - "The full UDI carrier as the human readable form (HRF) representation " - "of the barcode string as printed on the packaging of the device." - ), - # if property is element of this resource. - element_property=True, - ) - carrierHRF__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_carrierHRF", title="Extension field for ``carrierHRF``." - ) - - deviceIdentifier: fhirtypes.String = Field( - None, - alias="deviceIdentifier", - title="Mandatory fixed portion of UDI", - description=( - "The device identifier (DI) is a mandatory, fixed portion of a UDI that" - " identifies the labeler and the specific version or model of a device." - ), - # if property is element of this resource. - element_property=True, - ) - deviceIdentifier__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_deviceIdentifier", - title="Extension field for ``deviceIdentifier``.", - ) - - entryType: fhirtypes.Code = Field( - None, - alias="entryType", - title="barcode | rfid | manual +", - description="A coded entry to indicate how the data was entered.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["barcode", "rfid", "manual", "+"], - ) - entryType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_entryType", title="Extension field for ``entryType``." - ) - - issuer: fhirtypes.Uri = Field( - None, - alias="issuer", - title="UDI Issuing Organization", - description=( - "Organization that is charged with issuing UDIs for devices. For " - "example, the US FDA issuers include : 1) GS1: " - "http://hl7.org/fhir/NamingSystem/gs1-di, 2) HIBCC: " - "http://hl7.org/fhir/NamingSystem/hibcc-dI, 3) ICCBBA for blood " - "containers: http://hl7.org/fhir/NamingSystem/iccbba-blood-di, 4) " - "ICCBA for other devices: http://hl7.org/fhir/NamingSystem/iccbba-" - "other-di." - ), - # if property is element of this resource. - element_property=True, - ) - issuer__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_issuer", title="Extension field for ``issuer``." - ) - - jurisdiction: fhirtypes.Uri = Field( - None, - alias="jurisdiction", - title="Regional UDI authority", - description=( - "The identity of the authoritative source for UDI generation within a " - "jurisdiction. All UDIs are globally unique within a single namespace " - "with the appropriate repository uri as the system. For example, UDIs" - " of devices managed in the U.S. by the FDA, the value is " - "http://hl7.org/fhir/NamingSystem/fda-udi." - ), - # if property is element of this resource. - element_property=True, - ) - jurisdiction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_jurisdiction", title="Extension field for ``jurisdiction``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceUdiCarrier`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "deviceIdentifier", - "issuer", - "jurisdiction", - "carrierAIDC", - "carrierHRF", - "entryType", - ] - - -class DeviceVersion(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The actual design of the device or software version running on the device. - """ - - resource_type = Field("DeviceVersion", const=True) - - component: fhirtypes.IdentifierType = Field( - None, - alias="component", - title="A single component of the device version", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="The type of the device version", - description=None, - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="The version text", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceVersion`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "component", "value"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1512( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("value", "value__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/devicedefinition.py b/fhir/resources/devicedefinition.py deleted file mode 100644 index 2a04ccd5..00000000 --- a/fhir/resources/devicedefinition.py +++ /dev/null @@ -1,896 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DeviceDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class DeviceDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An instance of a medical-related component of a medical device. - The characteristics, operational status and capabilities of a medical- - related component of a medical device. - """ - - resource_type = Field("DeviceDefinition", const=True) - - capability: typing.List[fhirtypes.DeviceDefinitionCapabilityType] = Field( - None, - alias="capability", - title="Device capabilities", - description=None, - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="contact", - title="Details for human/organization for support", - description=( - "Contact details for an organization or a particular human that is " - "responsible for the device." - ), - # if property is element of this resource. - element_property=True, - ) - - deviceName: typing.List[fhirtypes.DeviceDefinitionDeviceNameType] = Field( - None, - alias="deviceName", - title="A name given to the device to identify it", - description=None, - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Instance identifier", - description=( - "Unique instance identifiers assigned to a device by the software, " - "manufacturers, other organizations or owners. For example: handle ID." - ), - # if property is element of this resource. - element_property=True, - ) - - languageCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="languageCode", - title=( - "Language code for the human-readable text strings produced by the " - "device (all supported)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - manufacturerReference: fhirtypes.ReferenceType = Field( - None, - alias="manufacturerReference", - title="Name of device manufacturer", - description="A name of the manufacturer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e manufacturer[x] - one_of_many="manufacturer", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - manufacturerString: fhirtypes.String = Field( - None, - alias="manufacturerString", - title="Name of device manufacturer", - description="A name of the manufacturer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e manufacturer[x] - one_of_many="manufacturer", - one_of_many_required=False, - ) - manufacturerString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_manufacturerString", - title="Extension field for ``manufacturerString``.", - ) - - material: typing.List[fhirtypes.DeviceDefinitionMaterialType] = Field( - None, - alias="material", - title="A substance used to create the material(s) of which the device is made", - description=None, - # if property is element of this resource. - element_property=True, - ) - - modelNumber: fhirtypes.String = Field( - None, - alias="modelNumber", - title="The model number for the device", - description=None, - # if property is element of this resource. - element_property=True, - ) - modelNumber__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_modelNumber", title="Extension field for ``modelNumber``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Device notes and comments", - description=( - "Descriptive information, usage information or implantation information" - " that is not captured in an existing element." - ), - # if property is element of this resource. - element_property=True, - ) - - onlineInformation: fhirtypes.Uri = Field( - None, - alias="onlineInformation", - title="Access to on-line information", - description="Access to on-line information about the device.", - # if property is element of this resource. - element_property=True, - ) - onlineInformation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_onlineInformation", - title="Extension field for ``onlineInformation``.", - ) - - owner: fhirtypes.ReferenceType = Field( - None, - alias="owner", - title="Organization responsible for device", - description=( - "An organization that is responsible for the provision and ongoing " - "maintenance of the device." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - parentDevice: fhirtypes.ReferenceType = Field( - None, - alias="parentDevice", - title="The parent device it can be part of", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DeviceDefinition"], - ) - - physicalCharacteristics: fhirtypes.ProdCharacteristicType = Field( - None, - alias="physicalCharacteristics", - title="Dimensions, color etc.", - description="Dimensions, color etc.", - # if property is element of this resource. - element_property=True, - ) - - property: typing.List[fhirtypes.DeviceDefinitionPropertyType] = Field( - None, - alias="property", - title=( - "The actual configuration settings of a device as it actually operates," - " e.g., regulation status, time properties" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title=( - "The quantity of the device present in the packaging (e.g. the number " - "of devices present in a pack, or the number of devices in the same " - "package of the medicinal product)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - safety: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="safety", - title="Safety characteristics of the device", - description=None, - # if property is element of this resource. - element_property=True, - ) - - shelfLifeStorage: typing.List[fhirtypes.ProductShelfLifeType] = Field( - None, - alias="shelfLifeStorage", - title="Shelf Life and storage information", - description=None, - # if property is element of this resource. - element_property=True, - ) - - specialization: typing.List[fhirtypes.DeviceDefinitionSpecializationType] = Field( - None, - alias="specialization", - title=( - "The capabilities supported on a device, the standards to which the " - "device conforms for a particular purpose, and used for the " - "communication" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="What kind of device or device system this is", - description=None, - # if property is element of this resource. - element_property=True, - ) - - udiDeviceIdentifier: typing.List[ - fhirtypes.DeviceDefinitionUdiDeviceIdentifierType - ] = Field( - None, - alias="udiDeviceIdentifier", - title="Unique Device Identifier (UDI) Barcode string", - description=( - "Unique device identifier (UDI) assigned to device label or package. " - "Note that the Device may include multiple udiCarriers as it either may" - " include just the udiCarrier for the jurisdiction it is sold, or for " - "multiple jurisdictions it could have been sold." - ), - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title="Network address to contact device", - description="A network address on which the device may be contacted directly.", - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - version: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="version", - title="Available versions", - description="The available versions of the device, e.g., software versions.", - # if property is element of this resource. - element_property=True, - ) - version__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_version", title="Extension field for ``version``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "udiDeviceIdentifier", - "manufacturerString", - "manufacturerReference", - "deviceName", - "modelNumber", - "type", - "specialization", - "version", - "safety", - "shelfLifeStorage", - "physicalCharacteristics", - "languageCode", - "capability", - "property", - "owner", - "contact", - "url", - "onlineInformation", - "note", - "quantity", - "parentDevice", - "material", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1803( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "manufacturer": ["manufacturerReference", "manufacturerString"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class DeviceDefinitionCapability(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Device capabilities. - """ - - resource_type = Field("DeviceDefinitionCapability", const=True) - - description: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="description", - title="Description of capability", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Type of capability", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceDefinitionCapability`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "description"] - - -class DeviceDefinitionDeviceName(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A name given to the device to identify it. - """ - - resource_type = Field("DeviceDefinitionDeviceName", const=True) - - name: fhirtypes.String = Field( - None, - alias="name", - title="The name of the device", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title=( - "udi-label-name | user-friendly-name | patient-reported-name | " - "manufacturer-name | model-name | other" - ), - description=( - "The type of deviceName. UDILabelName | UserFriendlyName | " - "PatientReportedName | ManufactureDeviceName | ModelName." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "udi-label-name", - "user-friendly-name", - "patient-reported-name", - "manufacturer-name", - "model-name", - "other", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceDefinitionDeviceName`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "name", "type"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2771( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class DeviceDefinitionMaterial(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A substance used to create the material(s) of which the device is made. - """ - - resource_type = Field("DeviceDefinitionMaterial", const=True) - - allergenicIndicator: bool = Field( - None, - alias="allergenicIndicator", - title="Whether the substance is a known or suspected allergen", - description=None, - # if property is element of this resource. - element_property=True, - ) - allergenicIndicator__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_allergenicIndicator", - title="Extension field for ``allergenicIndicator``.", - ) - - alternate: bool = Field( - None, - alias="alternate", - title="Indicates an alternative material of the device", - description=None, - # if property is element of this resource. - element_property=True, - ) - alternate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_alternate", title="Extension field for ``alternate``." - ) - - substance: fhirtypes.CodeableConceptType = Field( - ..., - alias="substance", - title="The substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceDefinitionMaterial`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "substance", - "alternate", - "allergenicIndicator", - ] - - -class DeviceDefinitionProperty(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The actual configuration settings of a device as it actually operates, - e.g., regulation status, time properties. - """ - - resource_type = Field("DeviceDefinitionProperty", const=True) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title=( - "Code that specifies the property DeviceDefinitionPropetyCode " - "(Extensible)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - valueCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="valueCode", - title="Property value as a code, e.g., NTP4 (synced to NTP)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - valueQuantity: typing.List[fhirtypes.QuantityType] = Field( - None, - alias="valueQuantity", - title="Property value as a quantity", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceDefinitionProperty`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "valueQuantity", - "valueCode", - ] - - -class DeviceDefinitionSpecialization(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The capabilities supported on a device, the standards to which the device - conforms for a particular purpose, and used for the communication. - """ - - resource_type = Field("DeviceDefinitionSpecialization", const=True) - - systemType: fhirtypes.String = Field( - None, - alias="systemType", - title="The standard that is used to operate and communicate", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - systemType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_systemType", title="Extension field for ``systemType``." - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="The version of the standard that is used to operate and communicate", - description=None, - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceDefinitionSpecialization`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "systemType", "version"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3274( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("systemType", "systemType__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class DeviceDefinitionUdiDeviceIdentifier(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Unique Device Identifier (UDI) Barcode string. - Unique device identifier (UDI) assigned to device label or package. Note - that the Device may include multiple udiCarriers as it either may include - just the udiCarrier for the jurisdiction it is sold, or for multiple - jurisdictions it could have been sold. - """ - - resource_type = Field("DeviceDefinitionUdiDeviceIdentifier", const=True) - - deviceIdentifier: fhirtypes.String = Field( - None, - alias="deviceIdentifier", - title=( - "The identifier that is to be associated with every Device that " - "references this DeviceDefintiion for the issuer and jurisdication " - "porvided in the DeviceDefinition.udiDeviceIdentifier" - ), - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - deviceIdentifier__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_deviceIdentifier", - title="Extension field for ``deviceIdentifier``.", - ) - - issuer: fhirtypes.Uri = Field( - None, - alias="issuer", - title="The organization that assigns the identifier algorithm", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - issuer__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_issuer", title="Extension field for ``issuer``." - ) - - jurisdiction: fhirtypes.Uri = Field( - None, - alias="jurisdiction", - title="The jurisdiction to which the deviceIdentifier applies", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - jurisdiction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_jurisdiction", title="Extension field for ``jurisdiction``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceDefinitionUdiDeviceIdentifier`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "deviceIdentifier", - "issuer", - "jurisdiction", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3716( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("deviceIdentifier", "deviceIdentifier__ext"), - ("issuer", "issuer__ext"), - ("jurisdiction", "jurisdiction__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/devicemetric.py b/fhir/resources/devicemetric.py deleted file mode 100644 index adf8d484..00000000 --- a/fhir/resources/devicemetric.py +++ /dev/null @@ -1,352 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DeviceMetric -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class DeviceMetric(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Measurement, calculation or setting capability of a medical device. - Describes a measurement, calculation or setting capability of a medical - device. - """ - - resource_type = Field("DeviceMetric", const=True) - - calibration: typing.List[fhirtypes.DeviceMetricCalibrationType] = Field( - None, - alias="calibration", - title=( - "Describes the calibrations that have been performed or that are " - "required to be performed" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.Code = Field( - None, - alias="category", - title="measurement | setting | calculation | unspecified", - description=( - "Indicates the category of the observation generation process. A " - "DeviceMetric can be for example a setting, measurement, or " - "calculation." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["measurement", "setting", "calculation", "unspecified"], - ) - category__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_category", title="Extension field for ``category``." - ) - - color: fhirtypes.Code = Field( - None, - alias="color", - title="black | red | green | yellow | blue | magenta | cyan | white", - description=( - "Describes the color representation for the metric. This is often used " - "to aid clinicians to track and identify parameter types by color. In " - "practice, consider a Patient Monitor that has ECG/HR and Pleth for " - "example; the parameters are displayed in different characteristic " - "colors, such as HR-blue, BP-green, and PR and SpO2- magenta." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "black", - "red", - "green", - "yellow", - "blue", - "magenta", - "cyan", - "white", - ], - ) - color__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_color", title="Extension field for ``color``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Instance identifier", - description=( - "Unique instance identifiers assigned to a device by the device or " - "gateway software, manufacturers, other organizations or owners. For " - "example: handle ID." - ), - # if property is element of this resource. - element_property=True, - ) - - measurementPeriod: fhirtypes.TimingType = Field( - None, - alias="measurementPeriod", - title="Describes the measurement repetition time", - description=( - "Describes the measurement repetition time. This is not necessarily the" - " same as the update period. The measurement repetition time can range " - "from milliseconds up to hours. An example for a measurement repetition" - " time in the range of milliseconds is the sampling rate of an ECG. An " - "example for a measurement repetition time in the range of hours is a " - "NIBP that is triggered automatically every hour. The update period may" - " be different than the measurement repetition time, if the device does" - " not update the published observed value with the same frequency as it" - " was measured." - ), - # if property is element of this resource. - element_property=True, - ) - - operationalStatus: fhirtypes.Code = Field( - None, - alias="operationalStatus", - title="on | off | standby | entered-in-error", - description=( - "Indicates current operational state of the device. For example: On, " - "Off, Standby, etc." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["on", "off", "standby", "entered-in-error"], - ) - operationalStatus__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_operationalStatus", - title="Extension field for ``operationalStatus``.", - ) - - parent: fhirtypes.ReferenceType = Field( - None, - alias="parent", - title="Describes the link to the parent Device", - description=( - "Describes the link to the Device that this DeviceMetric belongs to " - "and that provide information about the location of this DeviceMetric " - "in the containment structure of the parent Device. An example would be" - " a Device that represents a Channel. This reference can be used by a " - "client application to distinguish DeviceMetrics that have the same " - "type, but should be interpreted based on their containment location." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - source: fhirtypes.ReferenceType = Field( - None, - alias="source", - title="Describes the link to the source Device", - description=( - "Describes the link to the Device that this DeviceMetric belongs to " - "and that contains administrative device information such as " - "manufacturer, serial number, etc." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Identity of metric, for example Heart Rate or PEEP Setting", - description=( - "Describes the type of the metric. For example: Heart Rate, PEEP " - "Setting, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - unit: fhirtypes.CodeableConceptType = Field( - None, - alias="unit", - title="Unit of Measure for the Metric", - description=( - "Describes the unit that an observed value determined for this metric " - "will have. For example: Percent, Seconds, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceMetric`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "type", - "unit", - "source", - "parent", - "operationalStatus", - "color", - "category", - "measurementPeriod", - "calibration", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1371( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("category", "category__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class DeviceMetricCalibration(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Describes the calibrations that have been performed or that are required to - be performed. - """ - - resource_type = Field("DeviceMetricCalibration", const=True) - - state: fhirtypes.Code = Field( - None, - alias="state", - title="not-calibrated | calibration-required | calibrated | unspecified", - description="Describes the state of the calibration.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "not-calibrated", - "calibration-required", - "calibrated", - "unspecified", - ], - ) - state__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_state", title="Extension field for ``state``." - ) - - time: fhirtypes.Instant = Field( - None, - alias="time", - title="Describes the time last calibration has been performed", - description=None, - # if property is element of this resource. - element_property=True, - ) - time__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_time", title="Extension field for ``time``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="unspecified | offset | gain | two-point", - description="Describes the type of the calibration method.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["unspecified", "offset", "gain", "two-point"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceMetricCalibration`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "state", "time"] diff --git a/fhir/resources/devicerequest.py b/fhir/resources/devicerequest.py deleted file mode 100644 index 6cdc1c1e..00000000 --- a/fhir/resources/devicerequest.py +++ /dev/null @@ -1,730 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DeviceRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class DeviceRequest(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Medical device request. - Represents a request for a patient to employ a medical device. The device - may be an implantable device, or an external assistive device, such as a - walker. - """ - - resource_type = Field("DeviceRequest", const=True) - - authoredOn: fhirtypes.DateTime = Field( - None, - alias="authoredOn", - title="When recorded", - description="When the request transitioned to being actionable.", - # if property is element of this resource. - element_property=True, - ) - authoredOn__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_authoredOn", title="Extension field for ``authoredOn``." - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="What request fulfills", - description="Plan/proposal/order fulfilled by this request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - codeCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="codeCodeableConcept", - title="Device requested", - description="The details of the device to be used.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e code[x] - one_of_many="code", - one_of_many_required=True, - ) - - codeReference: fhirtypes.ReferenceType = Field( - None, - alias="codeReference", - title="Device requested", - description="The details of the device to be used.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e code[x] - one_of_many="code", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter motivating request", - description=( - "An encounter that provides additional context in which this request is" - " made." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - groupIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="groupIdentifier", - title="Identifier of composite request", - description="Composite request this is part of.", - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Request identifier", - description="Identifiers assigned to this order by the orderer or by the receiver.", - # if property is element of this resource. - element_property=True, - ) - - instantiatesCanonical: typing.List[fhirtypes.Canonical] = Field( - None, - alias="instantiatesCanonical", - title="Instantiates FHIR protocol or definition", - description=( - "The URL pointing to a FHIR-defined protocol, guideline, orderset or " - "other definition that is adhered to in whole or in part by this " - "DeviceRequest." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ActivityDefinition", "PlanDefinition"], - ) - instantiatesCanonical__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_instantiatesCanonical", - title="Extension field for ``instantiatesCanonical``.", - ) - - instantiatesUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiatesUri", - title="Instantiates external protocol or definition", - description=( - "The URL pointing to an externally maintained protocol, guideline, " - "orderset or other definition that is adhered to in whole or in part by" - " this DeviceRequest." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - insurance: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="insurance", - title="Associated insurance coverage", - description=( - "Insurance plans, coverage extensions, pre-authorizations and/or pre-" - "determinations that may be required for delivering the requested " - "service." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Coverage", "ClaimResponse"], - ) - - intent: fhirtypes.Code = Field( - None, - alias="intent", - title=( - "proposal | plan | directive | order | original-order | reflex-order | " - "filler-order | instance-order | option" - ), - description=( - "Whether the request is a proposal, plan, an original order or a reflex" - " order." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "proposal", - "plan", - "directive", - "order", - "original-order", - "reflex-order", - "filler-order", - "instance-order", - "option", - ], - ) - intent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_intent", title="Extension field for ``intent``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Notes or comments", - description=( - "Details about this request that were not represented at all or " - "sufficiently in one of the attributes provided in a class. These may " - "include for example a comment, an instruction, or a note associated " - "with the statement." - ), - # if property is element of this resource. - element_property=True, - ) - - occurrenceDateTime: fhirtypes.DateTime = Field( - None, - alias="occurrenceDateTime", - title="Desired time or schedule for use", - description=( - "The timing schedule for the use of the device. The Schedule data type " - 'allows many different expressions, for example. "Every 8 hours"; ' - '"Three times a day"; "1/2 an hour before breakfast for 10 days from ' - '23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".' - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - occurrenceDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurrenceDateTime", - title="Extension field for ``occurrenceDateTime``.", - ) - - occurrencePeriod: fhirtypes.PeriodType = Field( - None, - alias="occurrencePeriod", - title="Desired time or schedule for use", - description=( - "The timing schedule for the use of the device. The Schedule data type " - 'allows many different expressions, for example. "Every 8 hours"; ' - '"Three times a day"; "1/2 an hour before breakfast for 10 days from ' - '23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".' - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - occurrenceTiming: fhirtypes.TimingType = Field( - None, - alias="occurrenceTiming", - title="Desired time or schedule for use", - description=( - "The timing schedule for the use of the device. The Schedule data type " - 'allows many different expressions, for example. "Every 8 hours"; ' - '"Three times a day"; "1/2 an hour before breakfast for 10 days from ' - '23-Dec 2011:"; "15 Oct 2013, 17 Oct 2013 and 1 Nov 2013".' - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - parameter: typing.List[fhirtypes.DeviceRequestParameterType] = Field( - None, - alias="parameter", - title="Device details", - description=( - "Specific parameters for the ordered item. For example, the prism " - "value for lenses." - ), - # if property is element of this resource. - element_property=True, - ) - - performer: fhirtypes.ReferenceType = Field( - None, - alias="performer", - title="Requested Filler", - description="The desired performer for doing the diagnostic testing.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "CareTeam", - "HealthcareService", - "Patient", - "Device", - "RelatedPerson", - ], - ) - - performerType: fhirtypes.CodeableConceptType = Field( - None, - alias="performerType", - title="Filler role", - description="Desired type of performer for doing the diagnostic testing.", - # if property is element of this resource. - element_property=True, - ) - - priorRequest: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="priorRequest", - title="What request replaces", - description=( - "The request takes the place of the referenced completed or terminated " - "request(s)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - priority: fhirtypes.Code = Field( - None, - alias="priority", - title="routine | urgent | asap | stat", - description=( - "Indicates how quickly the {{title}} should be addressed with respect " - "to other requests." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["routine", "urgent", "asap", "stat"], - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Coded Reason for request", - description="Reason or justification for the use of this device.", - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Linked Reason for request", - description="Reason or justification for the use of this device.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "DiagnosticReport", - "DocumentReference", - ], - ) - - relevantHistory: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="relevantHistory", - title="Request provenance", - description="Key events in the history of the request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Provenance"], - ) - - requester: fhirtypes.ReferenceType = Field( - None, - alias="requester", - title="Who/what is requesting diagnostics", - description=( - "The individual who initiated the request and has responsibility for " - "its activation." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Device", - "Practitioner", - "PractitionerRole", - "Organization", - ], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "draft | active | on-hold | revoked | completed | entered-in-error | " - "unknown" - ), - description="The status of the request.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "draft", - "active", - "on-hold", - "revoked", - "completed", - "entered-in-error", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Focus of request", - description="The patient who will use the device.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group", "Location", "Device"], - ) - - supportingInfo: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingInfo", - title="Additional clinical information", - description=( - "Additional clinical information about the patient that may influence " - "the request fulfilment. For example, this may include where on the " - "subject's body the device will be used (i.e. the target site)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceRequest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "instantiatesCanonical", - "instantiatesUri", - "basedOn", - "priorRequest", - "groupIdentifier", - "status", - "intent", - "priority", - "codeReference", - "codeCodeableConcept", - "parameter", - "subject", - "encounter", - "occurrenceDateTime", - "occurrencePeriod", - "occurrenceTiming", - "authoredOn", - "requester", - "performerType", - "performer", - "reasonCode", - "reasonReference", - "insurance", - "supportingInfo", - "note", - "relevantHistory", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1521( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("intent", "intent__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1521( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "code": ["codeCodeableConcept", "codeReference"], - "occurrence": [ - "occurrenceDateTime", - "occurrencePeriod", - "occurrenceTiming", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class DeviceRequestParameter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Device details. - Specific parameters for the ordered item. For example, the prism value for - lenses. - """ - - resource_type = Field("DeviceRequestParameter", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Device detail", - description="A code or string that identifies the device detail being asserted.", - # if property is element of this resource. - element_property=True, - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Value of detail", - description="The value of the device detail.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="Value of detail", - description="The value of the device detail.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Value of detail", - description="The value of the device detail.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRange: fhirtypes.RangeType = Field( - None, - alias="valueRange", - title="Value of detail", - description="The value of the device detail.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceRequestParameter`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "valueCodeableConcept", - "valueQuantity", - "valueRange", - "valueBoolean", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2448( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueBoolean", - "valueCodeableConcept", - "valueQuantity", - "valueRange", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/deviceusestatement.py b/fhir/resources/deviceusestatement.py deleted file mode 100644 index 8982b7a3..00000000 --- a/fhir/resources/deviceusestatement.py +++ /dev/null @@ -1,368 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DeviceUseStatement -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class DeviceUseStatement(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Record of use of a device. - A record of a device being used by a patient where the record is the result - of a report from the patient or another clinician. - """ - - resource_type = Field("DeviceUseStatement", const=True) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Fulfills plan, proposal or order", - description=( - "A plan, proposal or order that is fulfilled in whole or in part by " - "this DeviceUseStatement." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ServiceRequest"], - ) - - bodySite: fhirtypes.CodeableConceptType = Field( - None, - alias="bodySite", - title="Target body site", - description=( - "Indicates the anotomic location on the subject's body where the device" - " was used ( i.e. the target)." - ), - # if property is element of this resource. - element_property=True, - ) - - derivedFrom: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="derivedFrom", - title="Supporting information", - description=( - "Allows linking the DeviceUseStatement to the underlying Request, or to" - " other information that supports or is used to derive the " - "DeviceUseStatement." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "ServiceRequest", - "Procedure", - "Claim", - "Observation", - "QuestionnaireResponse", - "DocumentReference", - ], - ) - - device: fhirtypes.ReferenceType = Field( - ..., - alias="device", - title="Reference to device used", - description="The details of the device used.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External identifier for this record", - description="An external identifier for this statement such as an IRI.", - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Addition details (comments, instructions)", - description=( - "Details about the device statement that were not represented at all or" - " sufficiently in one of the attributes provided in a class. These may " - "include for example a comment, an instruction, or a note associated " - "with the statement." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why device was used", - description="Reason or justification for the use of the device.", - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why was DeviceUseStatement performed?", - description=( - "Indicates another resource whose existence justifies this " - "DeviceUseStatement." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "DiagnosticReport", - "DocumentReference", - "Media", - ], - ) - - recordedOn: fhirtypes.DateTime = Field( - None, - alias="recordedOn", - title="When statement was recorded", - description="The time at which the statement was made/recorded.", - # if property is element of this resource. - element_property=True, - ) - recordedOn__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_recordedOn", title="Extension field for ``recordedOn``." - ) - - source: fhirtypes.ReferenceType = Field( - None, - alias="source", - title="Who made the statement", - description="Who reported the device was being used by the patient.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - ], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | completed | entered-in-error +", - description=( - "A code representing the patient or other source's judgment about the " - "state of the device used that this statement is about. Generally this" - " will be active or completed." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "completed", "entered-in-error", "+"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Patient using device", - description="The patient who used the device.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - timingDateTime: fhirtypes.DateTime = Field( - None, - alias="timingDateTime", - title="How often the device was used", - description="How often the device was used.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - timingDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timingDateTime", title="Extension field for ``timingDateTime``." - ) - - timingPeriod: fhirtypes.PeriodType = Field( - None, - alias="timingPeriod", - title="How often the device was used", - description="How often the device was used.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingTiming: fhirtypes.TimingType = Field( - None, - alias="timingTiming", - title="How often the device was used", - description="How often the device was used.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DeviceUseStatement`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "basedOn", - "status", - "subject", - "derivedFrom", - "timingTiming", - "timingPeriod", - "timingDateTime", - "recordedOn", - "source", - "device", - "reasonCode", - "reasonReference", - "bodySite", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2026( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2026( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "timing": ["timingDateTime", "timingPeriod", "timingTiming"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/diagnosticreport.py b/fhir/resources/diagnosticreport.py deleted file mode 100644 index 06da6a63..00000000 --- a/fhir/resources/diagnosticreport.py +++ /dev/null @@ -1,495 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DiagnosticReport -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class DiagnosticReport(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A Diagnostic report - a combination of request information, atomic results, - images, interpretation, as well as formatted reports. - The findings and interpretation of diagnostic tests performed on patients, - groups of patients, devices, and locations, and/or specimens derived from - these. The report includes clinical context such as requesting and provider - information, and some mix of atomic results, images, textual and coded - interpretations, and formatted representation of diagnostic reports. - """ - - resource_type = Field("DiagnosticReport", const=True) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="What was requested", - description="Details concerning a service requested.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "CarePlan", - "ImmunizationRecommendation", - "MedicationRequest", - "NutritionOrder", - "ServiceRequest", - ], - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Service category", - description=( - "A code that classifies the clinical discipline, department or " - "diagnostic service that created the report (e.g. cardiology, " - "biochemistry, hematology, MRI). This is used for searching, sorting " - "and display purposes." - ), - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Name/Code for this diagnostic report", - description="A code or name that describes this diagnostic report.", - # if property is element of this resource. - element_property=True, - ) - - conclusion: fhirtypes.String = Field( - None, - alias="conclusion", - title="Clinical conclusion (interpretation) of test results", - description=( - "Concise and clinically contextualized summary conclusion " - "(interpretation/impression) of the diagnostic report." - ), - # if property is element of this resource. - element_property=True, - ) - conclusion__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_conclusion", title="Extension field for ``conclusion``." - ) - - conclusionCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="conclusionCode", - title="Codes for the clinical conclusion of test results", - description=( - "One or more codes that represent the summary conclusion " - "(interpretation/impression) of the diagnostic report." - ), - # if property is element of this resource. - element_property=True, - ) - - effectiveDateTime: fhirtypes.DateTime = Field( - None, - alias="effectiveDateTime", - title="Clinically relevant time/time-period for report", - description=( - "The time or time-period the observed values are related to. When the " - "subject of the report is a patient, this is usually either the time of" - " the procedure or of specimen collection(s), but very often the source" - " of the date/time is not known, only the date/time itself." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=False, - ) - effectiveDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_effectiveDateTime", - title="Extension field for ``effectiveDateTime``.", - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="Clinically relevant time/time-period for report", - description=( - "The time or time-period the observed values are related to. When the " - "subject of the report is a patient, this is usually either the time of" - " the procedure or of specimen collection(s), but very often the source" - " of the date/time is not known, only the date/time itself." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=False, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Health care event when test ordered", - description=( - "The healthcare event (e.g. a patient and healthcare provider " - "interaction) which this DiagnosticReport is about." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier for report", - description="Identifiers assigned to this report by the performer or other systems.", - # if property is element of this resource. - element_property=True, - ) - - imagingStudy: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="imagingStudy", - title=( - "Reference to full details of imaging associated with the diagnostic " - "report" - ), - description=( - "One or more links to full details of any imaging performed during the " - "diagnostic investigation. Typically, this is imaging performed by " - "DICOM enabled modalities, but this is not required. A fully enabled " - "PACS viewer can use this information to provide views of the source " - "images." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ImagingStudy"], - ) - - issued: fhirtypes.Instant = Field( - None, - alias="issued", - title="DateTime this version was made", - description=( - "The date and time that this version of the report was made available " - "to providers, typically after the report was reviewed and verified." - ), - # if property is element of this resource. - element_property=True, - ) - issued__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_issued", title="Extension field for ``issued``." - ) - - media: typing.List[fhirtypes.DiagnosticReportMediaType] = Field( - None, - alias="media", - title="Key images associated with this report", - description=( - "A list of key images associated with this report. The images are " - "generally created during the diagnostic process, and may be directly " - "of the patient, or of treated specimens (i.e. slides of interest)." - ), - # if property is element of this resource. - element_property=True, - ) - - performer: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="performer", - title="Responsible Diagnostic Service", - description="The diagnostic service that is responsible for issuing the report.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "CareTeam", - ], - ) - - presentedForm: typing.List[fhirtypes.AttachmentType] = Field( - None, - alias="presentedForm", - title="Entire report as issued", - description=( - "Rich text representation of the entire result as issued by the " - "diagnostic service. Multiple formats are allowed but they SHALL be " - "semantically equivalent." - ), - # if property is element of this resource. - element_property=True, - ) - - result: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="result", - title="Observations", - description=( - "[Observations](observation.html) that are part of this diagnostic " - "report." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Observation"], - ) - - resultsInterpreter: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="resultsInterpreter", - title="Primary result interpreter", - description=( - "The practitioner or organization that is responsible for the report's " - "conclusions and interpretations." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "CareTeam", - ], - ) - - specimen: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="specimen", - title="Specimens this report is based on", - description="Details about the specimens on which this diagnostic report is based.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Specimen"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="registered | partial | preliminary | final +", - description="The status of the diagnostic report.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["registered", "partial", "preliminary", "final", "+"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="The subject of the report - usually, but not always, the patient", - description=( - "The subject of the report. Usually, but not always, this is a patient." - " However, diagnostic services also perform analyses on specimens " - "collected from a variety of other sources." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group", "Device", "Location"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DiagnosticReport`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "basedOn", - "status", - "category", - "code", - "subject", - "encounter", - "effectiveDateTime", - "effectivePeriod", - "issued", - "performer", - "resultsInterpreter", - "specimen", - "result", - "imagingStudy", - "media", - "conclusion", - "conclusionCode", - "presentedForm", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1849( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1849( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"effective": ["effectiveDateTime", "effectivePeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class DiagnosticReportMedia(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Key images associated with this report. - A list of key images associated with this report. The images are generally - created during the diagnostic process, and may be directly of the patient, - or of treated specimens (i.e. slides of interest). - """ - - resource_type = Field("DiagnosticReportMedia", const=True) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Comment about the image (e.g. explanation)", - description=( - "A comment about the image. Typically, this is used to provide an " - "explanation for why the image is included, or to draw the viewer's " - "attention to important features." - ), - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - link: fhirtypes.ReferenceType = Field( - ..., - alias="link", - title="Reference to the image source", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Media"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DiagnosticReportMedia`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "comment", "link"] diff --git a/fhir/resources/distance.py b/fhir/resources/distance.py deleted file mode 100644 index 580003d1..00000000 --- a/fhir/resources/distance.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Distance -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import quantity - - -class Distance(quantity.Quantity): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A length - a value with a unit that is a physical distance. - """ - - resource_type = Field("Distance", const=True) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Distance`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "value", "comparator", "unit", "system", "code"] diff --git a/fhir/resources/documentmanifest.py b/fhir/resources/documentmanifest.py deleted file mode 100644 index a810b312..00000000 --- a/fhir/resources/documentmanifest.py +++ /dev/null @@ -1,339 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DocumentManifest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class DocumentManifest(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A list that defines a set of documents. - A collection of documents compiled for a purpose together with metadata - that applies to the collection. - """ - - resource_type = Field("DocumentManifest", const=True) - - author: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="author", - title="Who and/or what authored the DocumentManifest", - description=( - "Identifies who is the author of the manifest. Manifest author is not " - "necessarly the author of the references included." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Device", - "Patient", - "RelatedPerson", - ], - ) - - content: typing.List[fhirtypes.ReferenceType] = Field( - ..., - alias="content", - title="Items in manifest", - description="The list of Resources that consist of the parts of this manifest.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="When this document manifest created", - description=( - "When the document manifest was created for submission to the server " - "(not necessarily the same thing as the actual resource last modified " - "time, since it may be modified, replicated, etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Human-readable description (title)", - description=( - "Human-readable description of the source document. This is sometimes " - 'known as the "title".' - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Other identifiers for the manifest", - description=( - "Other identifiers associated with the document manifest, including " - "version independent identifiers." - ), - # if property is element of this resource. - element_property=True, - ) - - masterIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="masterIdentifier", - title="Unique Identifier for the set of documents", - description=( - "A single identifier that uniquely identifies this manifest. " - "Principally used to refer to the manifest in non-FHIR contexts." - ), - # if property is element of this resource. - element_property=True, - ) - - recipient: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="recipient", - title="Intended to get notified about this set of documents", - description=( - "A patient, practitioner, or organization for which this set of " - "documents is intended." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Organization", - ], - ) - - related: typing.List[fhirtypes.DocumentManifestRelatedType] = Field( - None, - alias="related", - title="Related things", - description="Related identifiers or resources associated with the DocumentManifest.", - # if property is element of this resource. - element_property=True, - ) - - source: fhirtypes.Uri = Field( - None, - alias="source", - title="The source system/application/software", - description=( - "Identifies the source system, application, or software that produced " - "the document manifest." - ), - # if property is element of this resource. - element_property=True, - ) - source__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_source", title="Extension field for ``source``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="current | superseded | entered-in-error", - description="The status of this document manifest.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["current", "superseded", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="The subject of the set of documents", - description=( - "Who or what the set of documents is about. The documents can be about " - "a person, (patient or healthcare practitioner), a device (i.e. " - "machine) or even a group of subjects (such as a document about a herd " - "of farm animals, or a set of patients that share a common exposure). " - "If the documents cross more than one subject, then more than one " - "subject is allowed here (unusual use case)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Practitioner", "Group", "Device"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Kind of document set", - description=( - "The code specifying the type of clinical activity that resulted in " - "placing the associated content into the DocumentManifest." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DocumentManifest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "masterIdentifier", - "identifier", - "status", - "type", - "subject", - "created", - "author", - "recipient", - "source", - "description", - "content", - "related", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1838( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class DocumentManifestRelated(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Related things. - Related identifiers or resources associated with the DocumentManifest. - """ - - resource_type = Field("DocumentManifestRelated", const=True) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Identifiers of things that are related", - description=( - "Related identifier to this DocumentManifest. For example, Order " - "numbers, accession numbers, XDW workflow numbers." - ), - # if property is element of this resource. - element_property=True, - ) - - ref: fhirtypes.ReferenceType = Field( - None, - alias="ref", - title="Related Resource", - description=( - "Related Resource to this DocumentManifest. For example, Order, " - "ServiceRequest, Procedure, EligibilityRequest, etc." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DocumentManifestRelated`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "identifier", "ref"] diff --git a/fhir/resources/documentreference.py b/fhir/resources/documentreference.py deleted file mode 100644 index 7f95f8e6..00000000 --- a/fhir/resources/documentreference.py +++ /dev/null @@ -1,618 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DocumentReference -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class DocumentReference(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A reference to a document. - A reference to a document of any kind for any purpose. Provides metadata - about the document so that the document can be discovered and managed. The - scope of a document is any seralized object with a mime-type, so includes - formal patient centric documents (CDA), cliical notes, scanned paper, and - non-patient specific documents like policy text. - """ - - resource_type = Field("DocumentReference", const=True) - - authenticator: fhirtypes.ReferenceType = Field( - None, - alias="authenticator", - title="Who/what authenticated the document", - description=( - "Which person or organization authenticates that this document is " "valid." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - author: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="author", - title="Who and/or what authored the document", - description=( - "Identifies who is responsible for adding the information to the " - "document." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Device", - "Patient", - "RelatedPerson", - ], - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Categorization of document", - description=( - "A categorization for the type of document referenced - helps for " - "indexing and searching. This may be implied by or derived from the " - "code specified in the DocumentReference.type." - ), - # if property is element of this resource. - element_property=True, - ) - - content: typing.List[fhirtypes.DocumentReferenceContentType] = Field( - ..., - alias="content", - title="Document referenced", - description=( - "The document and format referenced. There may be multiple content " - "element repetitions, each with a different format." - ), - # if property is element of this resource. - element_property=True, - ) - - context: fhirtypes.DocumentReferenceContextType = Field( - None, - alias="context", - title="Clinical context of document", - description="The clinical context in which the document was prepared.", - # if property is element of this resource. - element_property=True, - ) - - custodian: fhirtypes.ReferenceType = Field( - None, - alias="custodian", - title="Organization which maintains the document", - description=( - "Identifies the organization or group who is responsible for ongoing " - "maintenance of and access to the document." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - date: fhirtypes.Instant = Field( - None, - alias="date", - title="When this document reference was created", - description="When the document reference was created.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Human-readable description", - description="Human-readable description of the source document.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - docStatus: fhirtypes.Code = Field( - None, - alias="docStatus", - title="preliminary | final | amended | entered-in-error", - description="The status of the underlying document.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["preliminary", "final", "amended", "entered-in-error"], - ) - docStatus__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_docStatus", title="Extension field for ``docStatus``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Other identifiers for the document", - description=( - "Other identifiers associated with the document, including version " - "independent identifiers." - ), - # if property is element of this resource. - element_property=True, - ) - - masterIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="masterIdentifier", - title="Master Version Specific Identifier", - description=( - "Document identifier as assigned by the source of the document. This " - "identifier is specific to this version of the document. This unique " - "identifier may be used elsewhere to identify this version of the " - "document." - ), - # if property is element of this resource. - element_property=True, - ) - - relatesTo: typing.List[fhirtypes.DocumentReferenceRelatesToType] = Field( - None, - alias="relatesTo", - title="Relationships to other documents", - description=( - "Relationships that this document has with other document references " - "that already exist." - ), - # if property is element of this resource. - element_property=True, - ) - - securityLabel: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="securityLabel", - title="Document security-tags", - description=( - "A set of Security-Tag codes specifying the level of privacy/security " - "of the Document. Note that DocumentReference.meta.security contains " - 'the security labels of the "reference" to the document, while ' - "DocumentReference.securityLabel contains a snapshot of the security " - "labels on the document the reference refers to." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="current | superseded | entered-in-error", - description="The status of this document reference.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["current", "superseded", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Who/what is the subject of the document", - description=( - "Who or what the document is about. The document can be about a person," - " (patient or healthcare practitioner), a device (e.g. a machine) or " - "even a group of subjects (such as a document about a herd of farm " - "animals, or a set of patients that share a common exposure)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Practitioner", "Group", "Device"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Kind of document (LOINC if possible)", - description=( - "Specifies the particular kind of document referenced (e.g. History " - "and Physical, Discharge Summary, Progress Note). This usually equates " - "to the purpose of making the document referenced." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DocumentReference`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "masterIdentifier", - "identifier", - "status", - "docStatus", - "type", - "category", - "subject", - "date", - "author", - "authenticator", - "custodian", - "relatesTo", - "description", - "securityLabel", - "content", - "context", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1911( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class DocumentReferenceContent(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Document referenced. - The document and format referenced. There may be multiple content element - repetitions, each with a different format. - """ - - resource_type = Field("DocumentReferenceContent", const=True) - - attachment: fhirtypes.AttachmentType = Field( - ..., - alias="attachment", - title="Where to access the document", - description=( - "The document or URL of the document along with critical metadata to " - "prove content has integrity." - ), - # if property is element of this resource. - element_property=True, - ) - - format: fhirtypes.CodingType = Field( - None, - alias="format", - title="Format/content rules for the document", - description=( - "An identifier of the document encoding, structure, and template that " - "the document conforms to beyond the base format indicated in the " - "mimeType." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DocumentReferenceContent`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "attachment", "format"] - - -class DocumentReferenceContext(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Clinical context of document. - The clinical context in which the document was prepared. - """ - - resource_type = Field("DocumentReferenceContext", const=True) - - encounter: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="encounter", - title="Context of the document content", - description=( - "Describes the clinical encounter or type of care that the document " - "content is associated with." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter", "EpisodeOfCare"], - ) - - event: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="event", - title="Main clinical acts documented", - description=( - "This list of codes represents the main clinical acts, such as a " - "colonoscopy or an appendectomy, being documented. In some cases, the " - 'event is inherent in the type Code, such as a "History and Physical ' - 'Report" in which the procedure being documented is necessarily a ' - '"History and Physical" act.' - ), - # if property is element of this resource. - element_property=True, - ) - - facilityType: fhirtypes.CodeableConceptType = Field( - None, - alias="facilityType", - title="Kind of facility where patient was seen", - description="The kind of facility where the patient was seen.", - # if property is element of this resource. - element_property=True, - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Time of service that is being documented", - description=( - "The time period over which the service that is described by the " - "document was provided." - ), - # if property is element of this resource. - element_property=True, - ) - - practiceSetting: fhirtypes.CodeableConceptType = Field( - None, - alias="practiceSetting", - title=( - "Additional details about where the content was created (e.g. clinical " - "specialty)" - ), - description=( - "This property may convey specifics about the practice setting where " - "the content was created, often reflecting the clinical specialty." - ), - # if property is element of this resource. - element_property=True, - ) - - related: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="related", - title="Related identifiers or resources", - description=( - "Related identifiers or resources associated with the " "DocumentReference." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - sourcePatientInfo: fhirtypes.ReferenceType = Field( - None, - alias="sourcePatientInfo", - title="Patient demographics from source", - description=( - "The Patient Information as known when the document was published. May " - "be a reference to a version specific, or contained." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DocumentReferenceContext`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "encounter", - "event", - "period", - "facilityType", - "practiceSetting", - "sourcePatientInfo", - "related", - ] - - -class DocumentReferenceRelatesTo(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Relationships to other documents. - Relationships that this document has with other document references that - already exist. - """ - - resource_type = Field("DocumentReferenceRelatesTo", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="replaces | transforms | signs | appends", - description="The type of relationship that this document has with anther document.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["replaces", "transforms", "signs", "appends"], - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - target: fhirtypes.ReferenceType = Field( - ..., - alias="target", - title="Target of the relationship", - description="The target document of this relationship.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DocumentReferenceRelatesTo`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "target"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2836( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/domainresource.py b/fhir/resources/domainresource.py deleted file mode 100644 index 0b48b8a9..00000000 --- a/fhir/resources/domainresource.py +++ /dev/null @@ -1,110 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DomainResource -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import fhirtypes, resource - - -class DomainResource(resource.Resource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A resource with narrative, extensions, and contained resources. - A resource that includes narrative, extensions, and contained resources. - """ - - resource_type = Field("DomainResource", const=True) - - contained: typing.List[fhirtypes.ResourceType] = Field( - None, - alias="contained", - title="Contained, inline Resources", - description=( - "These resources do not have an independent existence apart from the " - "resource that contains them - they cannot be identified independently," - " and nor can they have their own independent transaction scope." - ), - # if property is element of this resource. - element_property=True, - ) - - extension: typing.List[fhirtypes.ExtensionType] = Field( - None, - alias="extension", - title="Additional content defined by implementations", - description=( - "May be used to represent additional information that is not part of " - "the basic definition of the resource. To make the use of extensions " - "safe and manageable, there is a strict set of governance applied to " - "the definition and use of extensions. Though any implementer can " - "define an extension, there is a set of requirements that SHALL be met " - "as part of the definition of the extension." - ), - # if property is element of this resource. - element_property=True, - ) - - modifierExtension: typing.List[fhirtypes.ExtensionType] = Field( - None, - alias="modifierExtension", - title="Extensions that cannot be ignored", - description=( - "May be used to represent additional information that is not part of " - "the basic definition of the resource and that modifies the " - "understanding of the element that contains it and/or the understanding" - " of the containing element's descendants. Usually modifier elements " - "provide negation or qualification. To make the use of extensions safe " - "and manageable, there is a strict set of governance applied to the " - "definition and use of extensions. Though any implementer is allowed to" - " define an extension, there is a set of requirements that SHALL be met" - " as part of the definition of the extension. Applications processing a" - " resource are required to check for modifier extensions. Modifier " - "extensions SHALL NOT change the meaning of any elements on Resource or" - " DomainResource (including cannot change the meaning of " - "modifierExtension itself)." - ), - # if property is element of this resource. - element_property=True, - ) - - text: fhirtypes.NarrativeType = Field( - None, - alias="text", - title="Text summary of the resource, for human interpretation", - description=( - "A human-readable narrative that contains a summary of the resource and" - " can be used to represent the content of the resource to a human. The " - "narrative need not encode all the structured data, but is required to " - 'contain sufficient detail to make it "clinically safe" for a human to ' - "just read the narrative. Resource definitions may define what content " - "should be represented in the narrative to ensure clinical safety." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DomainResource`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - ] diff --git a/fhir/resources/dosage.py b/fhir/resources/dosage.py deleted file mode 100644 index 997c9189..00000000 --- a/fhir/resources/dosage.py +++ /dev/null @@ -1,399 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Dosage -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, element, fhirtypes - - -class Dosage(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - How the medication is/was taken or should be taken. - Indicates how the medication is/was taken or should be taken by the - patient. - """ - - resource_type = Field("Dosage", const=True) - - additionalInstruction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="additionalInstruction", - title=( - 'Supplemental instruction or warnings to the patient - e.g. "with ' - 'meals", "may cause drowsiness"' - ), - description=( - "Supplemental instructions to the patient on how to take the medication" - ' (e.g. "with meals" or"take half to one hour before food") or ' - 'warnings for the patient about the medication (e.g. "may cause ' - 'drowsiness" or "avoid exposure of skin to direct sunlight or ' - 'sunlamps").' - ), - # if property is element of this resource. - element_property=True, - ) - - asNeededBoolean: bool = Field( - None, - alias="asNeededBoolean", - title='Take "as needed" (for x)', - description=( - "Indicates whether the Medication is only taken when needed within a " - "specific dosing schedule (Boolean option), or it indicates the " - "precondition for taking the Medication (CodeableConcept)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e asNeeded[x] - one_of_many="asNeeded", - one_of_many_required=False, - ) - asNeededBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_asNeededBoolean", title="Extension field for ``asNeededBoolean``." - ) - - asNeededCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="asNeededCodeableConcept", - title='Take "as needed" (for x)', - description=( - "Indicates whether the Medication is only taken when needed within a " - "specific dosing schedule (Boolean option), or it indicates the " - "precondition for taking the Medication (CodeableConcept)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e asNeeded[x] - one_of_many="asNeeded", - one_of_many_required=False, - ) - - doseAndRate: typing.List[fhirtypes.DosageDoseAndRateType] = Field( - None, - alias="doseAndRate", - title="Amount of medication administered", - description="The amount of medication administered.", - # if property is element of this resource. - element_property=True, - ) - - maxDosePerAdministration: fhirtypes.QuantityType = Field( - None, - alias="maxDosePerAdministration", - title="Upper limit on medication per administration", - description=None, - # if property is element of this resource. - element_property=True, - ) - - maxDosePerLifetime: fhirtypes.QuantityType = Field( - None, - alias="maxDosePerLifetime", - title="Upper limit on medication per lifetime of the patient", - description=None, - # if property is element of this resource. - element_property=True, - ) - - maxDosePerPeriod: fhirtypes.RatioType = Field( - None, - alias="maxDosePerPeriod", - title="Upper limit on medication per unit of time", - description=None, - # if property is element of this resource. - element_property=True, - ) - - method: fhirtypes.CodeableConceptType = Field( - None, - alias="method", - title="Technique for administering medication", - description=None, - # if property is element of this resource. - element_property=True, - ) - - patientInstruction: fhirtypes.String = Field( - None, - alias="patientInstruction", - title="Patient or consumer oriented instructions", - description="Instructions in terms that are understood by the patient or consumer.", - # if property is element of this resource. - element_property=True, - ) - patientInstruction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_patientInstruction", - title="Extension field for ``patientInstruction``.", - ) - - route: fhirtypes.CodeableConceptType = Field( - None, - alias="route", - title="How drug should enter body", - description=None, - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.Integer = Field( - None, - alias="sequence", - title="The order of the dosage instructions", - description=( - "Indicates the order in which the dosage instructions should be applied" - " or interpreted." - ), - # if property is element of this resource. - element_property=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - site: fhirtypes.CodeableConceptType = Field( - None, - alias="site", - title="Body site to administer to", - description=None, - # if property is element of this resource. - element_property=True, - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Free text dosage instructions e.g. SIG", - description=None, - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - timing: fhirtypes.TimingType = Field( - None, - alias="timing", - title="When medication should be administered", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Dosage`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "text", - "additionalInstruction", - "patientInstruction", - "timing", - "asNeededBoolean", - "asNeededCodeableConcept", - "site", - "route", - "method", - "doseAndRate", - "maxDosePerPeriod", - "maxDosePerAdministration", - "maxDosePerLifetime", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_764( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "asNeeded": ["asNeededBoolean", "asNeededCodeableConcept"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class DosageDoseAndRate(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Amount of medication administered. - The amount of medication administered. - """ - - resource_type = Field("DosageDoseAndRate", const=True) - - doseQuantity: fhirtypes.QuantityType = Field( - None, - alias="doseQuantity", - title="Amount of medication per dose", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e dose[x] - one_of_many="dose", - one_of_many_required=False, - ) - - doseRange: fhirtypes.RangeType = Field( - None, - alias="doseRange", - title="Amount of medication per dose", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e dose[x] - one_of_many="dose", - one_of_many_required=False, - ) - - rateQuantity: fhirtypes.QuantityType = Field( - None, - alias="rateQuantity", - title="Amount of medication per unit of time", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e rate[x] - one_of_many="rate", - one_of_many_required=False, - ) - - rateRange: fhirtypes.RangeType = Field( - None, - alias="rateRange", - title="Amount of medication per unit of time", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e rate[x] - one_of_many="rate", - one_of_many_required=False, - ) - - rateRatio: fhirtypes.RatioType = Field( - None, - alias="rateRatio", - title="Amount of medication per unit of time", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e rate[x] - one_of_many="rate", - one_of_many_required=False, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="The kind of dose or rate specified", - description=( - "The kind of dose or rate specified, for example, ordered or " "calculated." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``DosageDoseAndRate`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "type", - "doseRange", - "doseQuantity", - "rateRatio", - "rateRange", - "rateQuantity", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1830( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "dose": ["doseQuantity", "doseRange"], - "rate": ["rateQuantity", "rateRange", "rateRatio"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/duration.py b/fhir/resources/duration.py deleted file mode 100644 index 8fa184c6..00000000 --- a/fhir/resources/duration.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Duration -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import quantity - - -class Duration(quantity.Quantity): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A length of time. - """ - - resource_type = Field("Duration", const=True) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Duration`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "value", "comparator", "unit", "system", "code"] diff --git a/fhir/resources/effectevidencesynthesis.py b/fhir/resources/effectevidencesynthesis.py deleted file mode 100644 index f970c2e2..00000000 --- a/fhir/resources/effectevidencesynthesis.py +++ /dev/null @@ -1,1017 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EffectEvidenceSynthesis -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class EffectEvidenceSynthesis(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A quantified estimate of effect based on a body of evidence. - The EffectEvidenceSynthesis resource describes the difference in an outcome - between exposures states in a population where the effect estimate is - derived from a combination of research studies. - """ - - resource_type = Field("EffectEvidenceSynthesis", const=True) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the effect evidence synthesis was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - author: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="author", - title="Who authored the content", - description=( - "An individiual or organization primarily involved in the creation and " - "maintenance of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - certainty: typing.List[fhirtypes.EffectEvidenceSynthesisCertaintyType] = Field( - None, - alias="certainty", - title="How certain is the effect", - description="A description of the certainty of the effect estimate.", - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the effect evidence synthesis and/or" - " its contents. Copyright statements are generally legal restrictions " - "on the use and publishing of the effect evidence synthesis." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the effect evidence synthesis was" - " published. The date must change when the business version changes and" - " it must change if the status code changes. In addition, it should " - "change when the substantive content of the effect evidence synthesis " - "changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the effect evidence synthesis", - description=( - "A free text natural language description of the effect evidence " - "synthesis from a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - editor: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="editor", - title="Who edited the content", - description=( - "An individual or organization primarily responsible for internal " - "coherence of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - effectEstimate: typing.List[ - fhirtypes.EffectEvidenceSynthesisEffectEstimateType - ] = Field( - None, - alias="effectEstimate", - title="What was the estimated effect", - description="The estimated effect of the exposure variant.", - # if property is element of this resource. - element_property=True, - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the effect evidence synthesis is expected to be used", - description=( - "The period during which the effect evidence synthesis content was or " - "is planned to be in active use." - ), - # if property is element of this resource. - element_property=True, - ) - - endorser: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="endorser", - title="Who endorsed the content", - description=( - "An individual or organization responsible for officially endorsing the" - " content for use in some setting." - ), - # if property is element of this resource. - element_property=True, - ) - - exposure: fhirtypes.ReferenceType = Field( - ..., - alias="exposure", - title="What exposure?", - description=( - "A reference to a EvidenceVariable resource that defines the exposure " - "for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EvidenceVariable"], - ) - - exposureAlternative: fhirtypes.ReferenceType = Field( - ..., - alias="exposureAlternative", - title="What comparison exposure?", - description=( - "A reference to a EvidenceVariable resource that defines the comparison" - " exposure for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EvidenceVariable"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the effect evidence synthesis", - description=( - "A formal identifier that is used to identify this effect evidence " - "synthesis when it is represented in other formats, or referenced in a " - "specification, model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for effect evidence synthesis (if applicable)", - description=( - "A legal or geographic region in which the effect evidence synthesis is" - " intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the effect evidence synthesis was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this effect evidence synthesis (computer friendly)", - description=( - "A natural language name identifying the effect evidence synthesis. " - "This name should be usable as an identifier for the module by machine " - "processing applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Used for footnotes or explanatory notes", - description=( - "A human-readable string to clarify or explain concepts about the " - "resource." - ), - # if property is element of this resource. - element_property=True, - ) - - outcome: fhirtypes.ReferenceType = Field( - ..., - alias="outcome", - title="What outcome?", - description=( - "A reference to a EvidenceVariable resomece that defines the outcome " - "for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EvidenceVariable"], - ) - - population: fhirtypes.ReferenceType = Field( - ..., - alias="population", - title="What population?", - description=( - "A reference to a EvidenceVariable resource that defines the population" - " for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EvidenceVariable"], - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the effect " - "evidence synthesis." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="Additional documentation, citations, etc.", - description=( - "Related artifacts such as additional documentation, justification, or " - "bibliographic references." - ), - # if property is element of this resource. - element_property=True, - ) - - resultsByExposure: typing.List[ - fhirtypes.EffectEvidenceSynthesisResultsByExposureType - ] = Field( - None, - alias="resultsByExposure", - title="What was the result per exposure?", - description=( - "A description of the results for each exposure considered in the " - "effect estimate." - ), - # if property is element of this resource. - element_property=True, - ) - - reviewer: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="reviewer", - title="Who reviewed the content", - description=( - "An individual or organization primarily responsible for review of some" - " aspect of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - sampleSize: fhirtypes.EffectEvidenceSynthesisSampleSizeType = Field( - None, - alias="sampleSize", - title="What sample size was involved?", - description="A description of the size of the sample involved in the synthesis.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this effect evidence synthesis. Enables tracking the " - "life-cycle of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - studyType: fhirtypes.CodeableConceptType = Field( - None, - alias="studyType", - title="Type of study", - description="Type of study eg randomized trial.", - # if property is element of this resource. - element_property=True, - ) - - synthesisType: fhirtypes.CodeableConceptType = Field( - None, - alias="synthesisType", - title="Type of synthesis", - description="Type of synthesis eg meta-analysis.", - # if property is element of this resource. - element_property=True, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this effect evidence synthesis (human friendly)", - description=( - "A short, descriptive, user-friendly title for the effect evidence " - "synthesis." - ), - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="topic", - title=( - "The category of the EffectEvidenceSynthesis, such as Education, " - "Treatment, Assessment, etc." - ), - description=( - "Descriptive topics related to the content of the " - "EffectEvidenceSynthesis. Topics provide a high-level categorization " - "grouping types of EffectEvidenceSynthesiss that can be useful for " - "filtering and searching." - ), - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this effect evidence synthesis, represented " - "as a URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this effect evidence " - "synthesis when it is referenced in a specification, model, design or " - "an instance; also called its canonical identifier. This SHOULD be " - "globally unique and SHOULD be a literal address at which at which an " - "authoritative instance of this effect evidence synthesis is (or will " - "be) published. This URL can be the target of a canonical reference. It" - " SHALL remain the same when the effect evidence synthesis is stored on" - " different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate effect evidence synthesis " - "instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the effect evidence synthesis", - description=( - "The identifier that is used to identify this version of the effect " - "evidence synthesis when it is referenced in a specification, model, " - "design or instance. This is an arbitrary value managed by the effect " - "evidence synthesis author and is not expected to be globally unique. " - "For example, it might be a timestamp (e.g. yyyymmdd) if a managed " - "version is not available. There is also no expectation that versions " - "can be placed in a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EffectEvidenceSynthesis`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "status", - "date", - "publisher", - "contact", - "description", - "note", - "useContext", - "jurisdiction", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "topic", - "author", - "editor", - "reviewer", - "endorser", - "relatedArtifact", - "synthesisType", - "studyType", - "population", - "exposure", - "exposureAlternative", - "outcome", - "sampleSize", - "resultsByExposure", - "effectEstimate", - "certainty", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2546( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class EffectEvidenceSynthesisCertainty(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - How certain is the effect. - A description of the certainty of the effect estimate. - """ - - resource_type = Field("EffectEvidenceSynthesisCertainty", const=True) - - certaintySubcomponent: typing.List[ - fhirtypes.EffectEvidenceSynthesisCertaintyCertaintySubcomponentType - ] = Field( - None, - alias="certaintySubcomponent", - title="A component that contributes to the overall certainty", - description="A description of a component of the overall certainty.", - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Used for footnotes or explanatory notes", - description=( - "A human-readable string to clarify or explain concepts about the " - "resource." - ), - # if property is element of this resource. - element_property=True, - ) - - rating: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="rating", - title="Certainty rating", - description="A rating of the certainty of the effect estimate.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EffectEvidenceSynthesisCertainty`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "rating", - "note", - "certaintySubcomponent", - ] - - -class EffectEvidenceSynthesisCertaintyCertaintySubcomponent( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A component that contributes to the overall certainty. - A description of a component of the overall certainty. - """ - - resource_type = Field( - "EffectEvidenceSynthesisCertaintyCertaintySubcomponent", const=True - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Used for footnotes or explanatory notes", - description=( - "A human-readable string to clarify or explain concepts about the " - "resource." - ), - # if property is element of this resource. - element_property=True, - ) - - rating: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="rating", - title="Subcomponent certainty rating", - description="A rating of a subcomponent of rating certainty.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of subcomponent of certainty rating", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EffectEvidenceSynthesisCertaintyCertaintySubcomponent`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "rating", "note"] - - -class EffectEvidenceSynthesisEffectEstimate(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What was the estimated effect. - The estimated effect of the exposure variant. - """ - - resource_type = Field("EffectEvidenceSynthesisEffectEstimate", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Description of effect estimate", - description="Human-readable summary of effect estimate.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - precisionEstimate: typing.List[ - fhirtypes.EffectEvidenceSynthesisEffectEstimatePrecisionEstimateType - ] = Field( - None, - alias="precisionEstimate", - title="How precise the estimate is", - description="A description of the precision of the estimate for the effect.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of efffect estimate", - description="Examples include relative risk and mean difference.", - # if property is element of this resource. - element_property=True, - ) - - unitOfMeasure: fhirtypes.CodeableConceptType = Field( - None, - alias="unitOfMeasure", - title="What unit is the outcome described in?", - description="Specifies the UCUM unit for the outcome.", - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.Decimal = Field( - None, - alias="value", - title="Point estimate", - description="The point estimate of the effect estimate.", - # if property is element of this resource. - element_property=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - variantState: fhirtypes.CodeableConceptType = Field( - None, - alias="variantState", - title="Variant exposure states", - description="Used to define variant exposure states such as low-risk state.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EffectEvidenceSynthesisEffectEstimate`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "type", - "variantState", - "value", - "unitOfMeasure", - "precisionEstimate", - ] - - -class EffectEvidenceSynthesisEffectEstimatePrecisionEstimate( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - How precise the estimate is. - A description of the precision of the estimate for the effect. - """ - - resource_type = Field( - "EffectEvidenceSynthesisEffectEstimatePrecisionEstimate", const=True - ) - - from_fhir: fhirtypes.Decimal = Field( - None, - alias="from", - title="Lower bound", - description="Lower bound of confidence interval.", - # if property is element of this resource. - element_property=True, - ) - from__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_from", title="Extension field for ``from_fhir``." - ) - - level: fhirtypes.Decimal = Field( - None, - alias="level", - title="Level of confidence interval", - description="Use 95 for a 95% confidence interval.", - # if property is element of this resource. - element_property=True, - ) - level__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_level", title="Extension field for ``level``." - ) - - to: fhirtypes.Decimal = Field( - None, - alias="to", - title="Upper bound", - description="Upper bound of confidence interval.", - # if property is element of this resource. - element_property=True, - ) - to__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_to", title="Extension field for ``to``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of precision estimate", - description="Examples include confidence interval and interquartile range.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EffectEvidenceSynthesisEffectEstimatePrecisionEstimate`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "level", "from", "to"] - - -class EffectEvidenceSynthesisResultsByExposure(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What was the result per exposure?. - A description of the results for each exposure considered in the effect - estimate. - """ - - resource_type = Field("EffectEvidenceSynthesisResultsByExposure", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Description of results by exposure", - description="Human-readable summary of results by exposure state.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - exposureState: fhirtypes.Code = Field( - None, - alias="exposureState", - title="exposure | exposure-alternative", - description=( - "Whether these results are for the exposure state or alternative " - "exposure state." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["exposure", "exposure-alternative"], - ) - exposureState__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_exposureState", title="Extension field for ``exposureState``." - ) - - riskEvidenceSynthesis: fhirtypes.ReferenceType = Field( - ..., - alias="riskEvidenceSynthesis", - title="Risk evidence synthesis", - description="Reference to a RiskEvidenceSynthesis resource.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["RiskEvidenceSynthesis"], - ) - - variantState: fhirtypes.CodeableConceptType = Field( - None, - alias="variantState", - title="Variant exposure states", - description="Used to define variant exposure states such as low-risk state.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EffectEvidenceSynthesisResultsByExposure`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "exposureState", - "variantState", - "riskEvidenceSynthesis", - ] - - -class EffectEvidenceSynthesisSampleSize(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What sample size was involved?. - A description of the size of the sample involved in the synthesis. - """ - - resource_type = Field("EffectEvidenceSynthesisSampleSize", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Description of sample size", - description="Human-readable summary of sample size.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - numberOfParticipants: fhirtypes.Integer = Field( - None, - alias="numberOfParticipants", - title="How many participants?", - description="Number of participants included in this evidence synthesis.", - # if property is element of this resource. - element_property=True, - ) - numberOfParticipants__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_numberOfParticipants", - title="Extension field for ``numberOfParticipants``.", - ) - - numberOfStudies: fhirtypes.Integer = Field( - None, - alias="numberOfStudies", - title="How many studies?", - description="Number of studies included in this evidence synthesis.", - # if property is element of this resource. - element_property=True, - ) - numberOfStudies__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_numberOfStudies", title="Extension field for ``numberOfStudies``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EffectEvidenceSynthesisSampleSize`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "numberOfStudies", - "numberOfParticipants", - ] diff --git a/fhir/resources/element.py b/fhir/resources/element.py deleted file mode 100644 index e39e2d75..00000000 --- a/fhir/resources/element.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Element -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from fhir.resources.core import fhirabstractmodel - -from . import fhirtypes - - -class Element(fhirabstractmodel.FHIRAbstractModel): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Base for all elements. - Base definition for all elements in a resource. - """ - - resource_type = Field("Element", const=True) - - extension: typing.List[fhirtypes.ExtensionType] = Field( - None, - alias="extension", - title="Additional content defined by implementations", - description=( - "May be used to represent additional information that is not part of " - "the basic definition of the element. To make the use of extensions " - "safe and manageable, there is a strict set of governance applied to " - "the definition and use of extensions. Though any implementer can " - "define an extension, there is a set of requirements that SHALL be met " - "as part of the definition of the extension." - ), - # if property is element of this resource. - element_property=True, - ) - - id: fhirtypes.String = Field( - None, - alias="id", - title="Unique id for inter-element referencing", - description=( - "Unique id for the element within a resource (for internal references)." - " This may be any string value that does not contain spaces." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Element`` according specification, - with preserving original sequence order. - """ - return ["id", "extension"] diff --git a/fhir/resources/elementdefinition.py b/fhir/resources/elementdefinition.py deleted file mode 100644 index d45d65b5..00000000 --- a/fhir/resources/elementdefinition.py +++ /dev/null @@ -1,6606 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ElementDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, element, fhirtypes - - -class ElementDefinition(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Definition of an element in a resource or extension. - Captures constraints on each element within the resource, profile, or - extension. - """ - - resource_type = Field("ElementDefinition", const=True) - - alias: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="alias", - title="Other names", - description="Identifies additional names by which this element might also be known.", - # if property is element of this resource. - element_property=True, - ) - alias__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_alias", title="Extension field for ``alias``.") - - base: fhirtypes.ElementDefinitionBaseType = Field( - None, - alias="base", - title="Base definition information for tools", - description=( - "Information about the base definition of the element, provided to make" - " it unnecessary for tools to trace the deviation of the element " - "through the derived and related profiles. When the element definition " - "is not the original definition of an element - i.g. either in a " - "constraint on another type, or for elements from a super type in a " - "snap shot - then the information in provided in the element definition" - " may be different to the base definition. On the original definition " - "of the element, it will be same." - ), - # if property is element of this resource. - element_property=True, - ) - - binding: fhirtypes.ElementDefinitionBindingType = Field( - None, - alias="binding", - title="ValueSet details if this is coded", - description=( - "Binds to a value set if this element is coded (code, Coding, " - "CodeableConcept, Quantity), or the data types (string, uri)." - ), - # if property is element of this resource. - element_property=True, - ) - - code: typing.List[fhirtypes.CodingType] = Field( - None, - alias="code", - title="Corresponding codes in terminologies", - description=( - "A code that has the same meaning as the element in a particular " - "terminology." - ), - # if property is element of this resource. - element_property=True, - ) - - comment: fhirtypes.Markdown = Field( - None, - alias="comment", - title="Comments about the use of this element", - description=( - "Explanatory notes and implementation guidance about the data element, " - "including notes about how to use the data properly, exceptions to " - "proper use, etc. (Note: The text you are reading is specified in " - "ElementDefinition.comment)." - ), - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - condition: typing.List[fhirtypes.Id] = Field( - None, - alias="condition", - title="Reference to invariant about presence", - description=( - "A reference to an invariant that may make additional statements about " - "the cardinality or value in the instance." - ), - # if property is element of this resource. - element_property=True, - ) - condition__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_condition", title="Extension field for ``condition``.") - - constraint: typing.List[fhirtypes.ElementDefinitionConstraintType] = Field( - None, - alias="constraint", - title="Condition that must evaluate to true", - description=( - "Formal constraints such as co-occurrence and other constraints that " - "can be computationally evaluated within the context of the instance." - ), - # if property is element of this resource. - element_property=True, - ) - - contentReference: fhirtypes.Uri = Field( - None, - alias="contentReference", - title="Reference to definition of content for the element", - description=( - "Identifies an element defined elsewhere in the definition whose " - "content rules should be applied to the current element. " - "ContentReferences bring across all the rules that are in the " - "ElementDefinition for the element, including definitions, cardinality " - "constraints, bindings, invariants etc." - ), - # if property is element of this resource. - element_property=True, - ) - contentReference__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_contentReference", - title="Extension field for ``contentReference``.", - ) - - defaultValueAddress: fhirtypes.AddressType = Field( - None, - alias="defaultValueAddress", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueAge: fhirtypes.AgeType = Field( - None, - alias="defaultValueAge", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueAnnotation: fhirtypes.AnnotationType = Field( - None, - alias="defaultValueAnnotation", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="defaultValueAttachment", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueBase64Binary: fhirtypes.Base64Binary = Field( - None, - alias="defaultValueBase64Binary", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueBase64Binary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueBase64Binary", - title="Extension field for ``defaultValueBase64Binary``.", - ) - - defaultValueBoolean: bool = Field( - None, - alias="defaultValueBoolean", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueBoolean", - title="Extension field for ``defaultValueBoolean``.", - ) - - defaultValueCanonical: fhirtypes.Canonical = Field( - None, - alias="defaultValueCanonical", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueCanonical", - title="Extension field for ``defaultValueCanonical``.", - ) - - defaultValueCode: fhirtypes.Code = Field( - None, - alias="defaultValueCode", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueCode", - title="Extension field for ``defaultValueCode``.", - ) - - defaultValueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="defaultValueCodeableConcept", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueCoding: fhirtypes.CodingType = Field( - None, - alias="defaultValueCoding", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueContactDetail: fhirtypes.ContactDetailType = Field( - None, - alias="defaultValueContactDetail", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueContactPoint: fhirtypes.ContactPointType = Field( - None, - alias="defaultValueContactPoint", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueContributor: fhirtypes.ContributorType = Field( - None, - alias="defaultValueContributor", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueCount: fhirtypes.CountType = Field( - None, - alias="defaultValueCount", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueDataRequirement: fhirtypes.DataRequirementType = Field( - None, - alias="defaultValueDataRequirement", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueDate: fhirtypes.Date = Field( - None, - alias="defaultValueDate", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueDate", - title="Extension field for ``defaultValueDate``.", - ) - - defaultValueDateTime: fhirtypes.DateTime = Field( - None, - alias="defaultValueDateTime", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueDateTime", - title="Extension field for ``defaultValueDateTime``.", - ) - - defaultValueDecimal: fhirtypes.Decimal = Field( - None, - alias="defaultValueDecimal", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueDecimal", - title="Extension field for ``defaultValueDecimal``.", - ) - - defaultValueDistance: fhirtypes.DistanceType = Field( - None, - alias="defaultValueDistance", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueDosage: fhirtypes.DosageType = Field( - None, - alias="defaultValueDosage", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueDuration: fhirtypes.DurationType = Field( - None, - alias="defaultValueDuration", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueExpression: fhirtypes.ExpressionType = Field( - None, - alias="defaultValueExpression", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueHumanName: fhirtypes.HumanNameType = Field( - None, - alias="defaultValueHumanName", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueId: fhirtypes.Id = Field( - None, - alias="defaultValueId", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_defaultValueId", title="Extension field for ``defaultValueId``." - ) - - defaultValueIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="defaultValueIdentifier", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueInstant: fhirtypes.Instant = Field( - None, - alias="defaultValueInstant", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueInstant__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueInstant", - title="Extension field for ``defaultValueInstant``.", - ) - - defaultValueInteger: fhirtypes.Integer = Field( - None, - alias="defaultValueInteger", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueInteger", - title="Extension field for ``defaultValueInteger``.", - ) - - defaultValueMarkdown: fhirtypes.Markdown = Field( - None, - alias="defaultValueMarkdown", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueMarkdown__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueMarkdown", - title="Extension field for ``defaultValueMarkdown``.", - ) - - defaultValueMeta: fhirtypes.MetaType = Field( - None, - alias="defaultValueMeta", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueMoney: fhirtypes.MoneyType = Field( - None, - alias="defaultValueMoney", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueOid: fhirtypes.Oid = Field( - None, - alias="defaultValueOid", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueOid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_defaultValueOid", title="Extension field for ``defaultValueOid``." - ) - - defaultValueParameterDefinition: fhirtypes.ParameterDefinitionType = Field( - None, - alias="defaultValueParameterDefinition", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValuePeriod: fhirtypes.PeriodType = Field( - None, - alias="defaultValuePeriod", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValuePositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="defaultValuePositiveInt", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValuePositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValuePositiveInt", - title="Extension field for ``defaultValuePositiveInt``.", - ) - - defaultValueQuantity: fhirtypes.QuantityType = Field( - None, - alias="defaultValueQuantity", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueRange: fhirtypes.RangeType = Field( - None, - alias="defaultValueRange", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueRatio: fhirtypes.RatioType = Field( - None, - alias="defaultValueRatio", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueReference: fhirtypes.ReferenceType = Field( - None, - alias="defaultValueReference", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueRelatedArtifact: fhirtypes.RelatedArtifactType = Field( - None, - alias="defaultValueRelatedArtifact", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueSampledData: fhirtypes.SampledDataType = Field( - None, - alias="defaultValueSampledData", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueSignature: fhirtypes.SignatureType = Field( - None, - alias="defaultValueSignature", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueString: fhirtypes.String = Field( - None, - alias="defaultValueString", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueString", - title="Extension field for ``defaultValueString``.", - ) - - defaultValueTime: fhirtypes.Time = Field( - None, - alias="defaultValueTime", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueTime", - title="Extension field for ``defaultValueTime``.", - ) - - defaultValueTiming: fhirtypes.TimingType = Field( - None, - alias="defaultValueTiming", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueTriggerDefinition: fhirtypes.TriggerDefinitionType = Field( - None, - alias="defaultValueTriggerDefinition", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="defaultValueUnsignedInt", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueUnsignedInt", - title="Extension field for ``defaultValueUnsignedInt``.", - ) - - defaultValueUri: fhirtypes.Uri = Field( - None, - alias="defaultValueUri", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_defaultValueUri", title="Extension field for ``defaultValueUri``." - ) - - defaultValueUrl: fhirtypes.Url = Field( - None, - alias="defaultValueUrl", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_defaultValueUrl", title="Extension field for ``defaultValueUrl``." - ) - - defaultValueUsageContext: fhirtypes.UsageContextType = Field( - None, - alias="defaultValueUsageContext", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueUuid: fhirtypes.Uuid = Field( - None, - alias="defaultValueUuid", - title="Specified value if missing from instance", - description=( - "The value that should be used if there is no value stated in the " - "instance (e.g. 'if not otherwise specified, the abstract is false')." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueUuid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueUuid", - title="Extension field for ``defaultValueUuid``.", - ) - - definition: fhirtypes.Markdown = Field( - None, - alias="definition", - title="Full formal definition as narrative text", - description=( - "Provides a complete explanation of the meaning of the data element for" - " human readability. For the case of elements derived from existing " - "elements (e.g. constraints), the definition SHALL be consistent with " - "the base definition, but convey the meaning of the element in the " - "particular context of use of the resource. (Note: The text you are " - "reading is specified in ElementDefinition.definition)." - ), - # if property is element of this resource. - element_property=True, - ) - definition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_definition", title="Extension field for ``definition``." - ) - - example: typing.List[fhirtypes.ElementDefinitionExampleType] = Field( - None, - alias="example", - title="Example value (as defined for type)", - description=( - "A sample value for this element demonstrating the type of information " - "that would typically be found in the element." - ), - # if property is element of this resource. - element_property=True, - ) - - fixedAddress: fhirtypes.AddressType = Field( - None, - alias="fixedAddress", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedAge: fhirtypes.AgeType = Field( - None, - alias="fixedAge", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedAnnotation: fhirtypes.AnnotationType = Field( - None, - alias="fixedAnnotation", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedAttachment: fhirtypes.AttachmentType = Field( - None, - alias="fixedAttachment", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedBase64Binary: fhirtypes.Base64Binary = Field( - None, - alias="fixedBase64Binary", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedBase64Binary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_fixedBase64Binary", - title="Extension field for ``fixedBase64Binary``.", - ) - - fixedBoolean: bool = Field( - None, - alias="fixedBoolean", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedBoolean", title="Extension field for ``fixedBoolean``." - ) - - fixedCanonical: fhirtypes.Canonical = Field( - None, - alias="fixedCanonical", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedCanonical", title="Extension field for ``fixedCanonical``." - ) - - fixedCode: fhirtypes.Code = Field( - None, - alias="fixedCode", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedCode", title="Extension field for ``fixedCode``." - ) - - fixedCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="fixedCodeableConcept", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedCoding: fhirtypes.CodingType = Field( - None, - alias="fixedCoding", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedContactDetail: fhirtypes.ContactDetailType = Field( - None, - alias="fixedContactDetail", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedContactPoint: fhirtypes.ContactPointType = Field( - None, - alias="fixedContactPoint", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedContributor: fhirtypes.ContributorType = Field( - None, - alias="fixedContributor", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedCount: fhirtypes.CountType = Field( - None, - alias="fixedCount", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedDataRequirement: fhirtypes.DataRequirementType = Field( - None, - alias="fixedDataRequirement", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedDate: fhirtypes.Date = Field( - None, - alias="fixedDate", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedDate", title="Extension field for ``fixedDate``." - ) - - fixedDateTime: fhirtypes.DateTime = Field( - None, - alias="fixedDateTime", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedDateTime", title="Extension field for ``fixedDateTime``." - ) - - fixedDecimal: fhirtypes.Decimal = Field( - None, - alias="fixedDecimal", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedDecimal", title="Extension field for ``fixedDecimal``." - ) - - fixedDistance: fhirtypes.DistanceType = Field( - None, - alias="fixedDistance", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedDosage: fhirtypes.DosageType = Field( - None, - alias="fixedDosage", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedDuration: fhirtypes.DurationType = Field( - None, - alias="fixedDuration", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedExpression: fhirtypes.ExpressionType = Field( - None, - alias="fixedExpression", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedHumanName: fhirtypes.HumanNameType = Field( - None, - alias="fixedHumanName", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedId: fhirtypes.Id = Field( - None, - alias="fixedId", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedId", title="Extension field for ``fixedId``." - ) - - fixedIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="fixedIdentifier", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedInstant: fhirtypes.Instant = Field( - None, - alias="fixedInstant", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedInstant__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedInstant", title="Extension field for ``fixedInstant``." - ) - - fixedInteger: fhirtypes.Integer = Field( - None, - alias="fixedInteger", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedInteger", title="Extension field for ``fixedInteger``." - ) - - fixedMarkdown: fhirtypes.Markdown = Field( - None, - alias="fixedMarkdown", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedMarkdown__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedMarkdown", title="Extension field for ``fixedMarkdown``." - ) - - fixedMeta: fhirtypes.MetaType = Field( - None, - alias="fixedMeta", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedMoney: fhirtypes.MoneyType = Field( - None, - alias="fixedMoney", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedOid: fhirtypes.Oid = Field( - None, - alias="fixedOid", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedOid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedOid", title="Extension field for ``fixedOid``." - ) - - fixedParameterDefinition: fhirtypes.ParameterDefinitionType = Field( - None, - alias="fixedParameterDefinition", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedPeriod: fhirtypes.PeriodType = Field( - None, - alias="fixedPeriod", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedPositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="fixedPositiveInt", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedPositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_fixedPositiveInt", - title="Extension field for ``fixedPositiveInt``.", - ) - - fixedQuantity: fhirtypes.QuantityType = Field( - None, - alias="fixedQuantity", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedRange: fhirtypes.RangeType = Field( - None, - alias="fixedRange", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedRatio: fhirtypes.RatioType = Field( - None, - alias="fixedRatio", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedReference: fhirtypes.ReferenceType = Field( - None, - alias="fixedReference", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedRelatedArtifact: fhirtypes.RelatedArtifactType = Field( - None, - alias="fixedRelatedArtifact", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedSampledData: fhirtypes.SampledDataType = Field( - None, - alias="fixedSampledData", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedSignature: fhirtypes.SignatureType = Field( - None, - alias="fixedSignature", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedString: fhirtypes.String = Field( - None, - alias="fixedString", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedString", title="Extension field for ``fixedString``." - ) - - fixedTime: fhirtypes.Time = Field( - None, - alias="fixedTime", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedTime", title="Extension field for ``fixedTime``." - ) - - fixedTiming: fhirtypes.TimingType = Field( - None, - alias="fixedTiming", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedTriggerDefinition: fhirtypes.TriggerDefinitionType = Field( - None, - alias="fixedTriggerDefinition", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="fixedUnsignedInt", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_fixedUnsignedInt", - title="Extension field for ``fixedUnsignedInt``.", - ) - - fixedUri: fhirtypes.Uri = Field( - None, - alias="fixedUri", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedUri", title="Extension field for ``fixedUri``." - ) - - fixedUrl: fhirtypes.Url = Field( - None, - alias="fixedUrl", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedUrl", title="Extension field for ``fixedUrl``." - ) - - fixedUsageContext: fhirtypes.UsageContextType = Field( - None, - alias="fixedUsageContext", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - - fixedUuid: fhirtypes.Uuid = Field( - None, - alias="fixedUuid", - title="Value must be exactly this", - description=( - "Specifies a value that SHALL be exactly the value for this element in" - " the instance. For purposes of comparison, non-significant whitespace " - "is ignored, and all values must be an exact match (case and accent " - "sensitive). Missing elements/attributes must also be missing." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fixed[x] - one_of_many="fixed", - one_of_many_required=False, - ) - fixedUuid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fixedUuid", title="Extension field for ``fixedUuid``." - ) - - isModifier: bool = Field( - None, - alias="isModifier", - title="If this modifies the meaning of other elements", - description=( - "If true, the value of this element affects the interpretation of the " - "element or resource that contains it, and the value of the element " - "cannot be ignored. Typically, this is used for status, negation and " - "qualification codes. The effect of this is that the element cannot be " - "ignored by systems: they SHALL either recognize the element and " - "process it, and/or a pre-determination has been made that it is not " - "relevant to their particular system." - ), - # if property is element of this resource. - element_property=True, - ) - isModifier__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_isModifier", title="Extension field for ``isModifier``." - ) - - isModifierReason: fhirtypes.String = Field( - None, - alias="isModifierReason", - title="Reason that this element is marked as a modifier", - description=( - "Explains how that element affects the interpretation of the resource " - "or element that contains it." - ), - # if property is element of this resource. - element_property=True, - ) - isModifierReason__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_isModifierReason", - title="Extension field for ``isModifierReason``.", - ) - - isSummary: bool = Field( - None, - alias="isSummary", - title="Include when _summary = true?", - description=( - "Whether the element should be included if a client requests a search " - "with the parameter _summary=true." - ), - # if property is element of this resource. - element_property=True, - ) - isSummary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_isSummary", title="Extension field for ``isSummary``." - ) - - label: fhirtypes.String = Field( - None, - alias="label", - title="Name for element to display with or prompt for element", - description=( - "A single preferred label which is the text to display beside the " - "element indicating its meaning or to use to prompt for the element in " - "a user display or form." - ), - # if property is element of this resource. - element_property=True, - ) - label__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_label", title="Extension field for ``label``." - ) - - mapping: typing.List[fhirtypes.ElementDefinitionMappingType] = Field( - None, - alias="mapping", - title="Map element to another set of definitions", - description=( - "Identifies a concept from an external specification that roughly " - "corresponds to this element." - ), - # if property is element of this resource. - element_property=True, - ) - - max: fhirtypes.String = Field( - None, - alias="max", - title="Maximum Cardinality (a number or *)", - description=( - "The maximum number of times this element is permitted to appear in the" - " instance." - ), - # if property is element of this resource. - element_property=True, - ) - max__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_max", title="Extension field for ``max``." - ) - - maxLength: fhirtypes.Integer = Field( - None, - alias="maxLength", - title="Max length for strings", - description=( - "Indicates the maximum length in characters that is permitted to be " - "present in conformant instances and which is expected to be supported " - "by conformant consumers that support the element." - ), - # if property is element of this resource. - element_property=True, - ) - maxLength__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_maxLength", title="Extension field for ``maxLength``." - ) - - maxValueDate: fhirtypes.Date = Field( - None, - alias="maxValueDate", - title="Maximum Allowed Value (for some types)", - description=( - "The maximum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e maxValue[x] - one_of_many="maxValue", - one_of_many_required=False, - ) - maxValueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_maxValueDate", title="Extension field for ``maxValueDate``." - ) - - maxValueDateTime: fhirtypes.DateTime = Field( - None, - alias="maxValueDateTime", - title="Maximum Allowed Value (for some types)", - description=( - "The maximum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e maxValue[x] - one_of_many="maxValue", - one_of_many_required=False, - ) - maxValueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_maxValueDateTime", - title="Extension field for ``maxValueDateTime``.", - ) - - maxValueDecimal: fhirtypes.Decimal = Field( - None, - alias="maxValueDecimal", - title="Maximum Allowed Value (for some types)", - description=( - "The maximum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e maxValue[x] - one_of_many="maxValue", - one_of_many_required=False, - ) - maxValueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_maxValueDecimal", title="Extension field for ``maxValueDecimal``." - ) - - maxValueInstant: fhirtypes.Instant = Field( - None, - alias="maxValueInstant", - title="Maximum Allowed Value (for some types)", - description=( - "The maximum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e maxValue[x] - one_of_many="maxValue", - one_of_many_required=False, - ) - maxValueInstant__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_maxValueInstant", title="Extension field for ``maxValueInstant``." - ) - - maxValueInteger: fhirtypes.Integer = Field( - None, - alias="maxValueInteger", - title="Maximum Allowed Value (for some types)", - description=( - "The maximum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e maxValue[x] - one_of_many="maxValue", - one_of_many_required=False, - ) - maxValueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_maxValueInteger", title="Extension field for ``maxValueInteger``." - ) - - maxValuePositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="maxValuePositiveInt", - title="Maximum Allowed Value (for some types)", - description=( - "The maximum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e maxValue[x] - one_of_many="maxValue", - one_of_many_required=False, - ) - maxValuePositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_maxValuePositiveInt", - title="Extension field for ``maxValuePositiveInt``.", - ) - - maxValueQuantity: fhirtypes.QuantityType = Field( - None, - alias="maxValueQuantity", - title="Maximum Allowed Value (for some types)", - description=( - "The maximum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e maxValue[x] - one_of_many="maxValue", - one_of_many_required=False, - ) - - maxValueTime: fhirtypes.Time = Field( - None, - alias="maxValueTime", - title="Maximum Allowed Value (for some types)", - description=( - "The maximum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e maxValue[x] - one_of_many="maxValue", - one_of_many_required=False, - ) - maxValueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_maxValueTime", title="Extension field for ``maxValueTime``." - ) - - maxValueUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="maxValueUnsignedInt", - title="Maximum Allowed Value (for some types)", - description=( - "The maximum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e maxValue[x] - one_of_many="maxValue", - one_of_many_required=False, - ) - maxValueUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_maxValueUnsignedInt", - title="Extension field for ``maxValueUnsignedInt``.", - ) - - meaningWhenMissing: fhirtypes.Markdown = Field( - None, - alias="meaningWhenMissing", - title="Implicit meaning when this element is missing", - description=( - "The Implicit meaning that is to be understood when this element is " - "missing (e.g. 'when this element is missing, the period is ongoing')." - ), - # if property is element of this resource. - element_property=True, - ) - meaningWhenMissing__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_meaningWhenMissing", - title="Extension field for ``meaningWhenMissing``.", - ) - - min: fhirtypes.UnsignedInt = Field( - None, - alias="min", - title="Minimum Cardinality", - description="The minimum number of times this element SHALL appear in the instance.", - # if property is element of this resource. - element_property=True, - ) - min__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_min", title="Extension field for ``min``." - ) - - minValueDate: fhirtypes.Date = Field( - None, - alias="minValueDate", - title="Minimum Allowed Value (for some types)", - description=( - "The minimum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e minValue[x] - one_of_many="minValue", - one_of_many_required=False, - ) - minValueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_minValueDate", title="Extension field for ``minValueDate``." - ) - - minValueDateTime: fhirtypes.DateTime = Field( - None, - alias="minValueDateTime", - title="Minimum Allowed Value (for some types)", - description=( - "The minimum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e minValue[x] - one_of_many="minValue", - one_of_many_required=False, - ) - minValueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_minValueDateTime", - title="Extension field for ``minValueDateTime``.", - ) - - minValueDecimal: fhirtypes.Decimal = Field( - None, - alias="minValueDecimal", - title="Minimum Allowed Value (for some types)", - description=( - "The minimum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e minValue[x] - one_of_many="minValue", - one_of_many_required=False, - ) - minValueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_minValueDecimal", title="Extension field for ``minValueDecimal``." - ) - - minValueInstant: fhirtypes.Instant = Field( - None, - alias="minValueInstant", - title="Minimum Allowed Value (for some types)", - description=( - "The minimum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e minValue[x] - one_of_many="minValue", - one_of_many_required=False, - ) - minValueInstant__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_minValueInstant", title="Extension field for ``minValueInstant``." - ) - - minValueInteger: fhirtypes.Integer = Field( - None, - alias="minValueInteger", - title="Minimum Allowed Value (for some types)", - description=( - "The minimum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e minValue[x] - one_of_many="minValue", - one_of_many_required=False, - ) - minValueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_minValueInteger", title="Extension field for ``minValueInteger``." - ) - - minValuePositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="minValuePositiveInt", - title="Minimum Allowed Value (for some types)", - description=( - "The minimum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e minValue[x] - one_of_many="minValue", - one_of_many_required=False, - ) - minValuePositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_minValuePositiveInt", - title="Extension field for ``minValuePositiveInt``.", - ) - - minValueQuantity: fhirtypes.QuantityType = Field( - None, - alias="minValueQuantity", - title="Minimum Allowed Value (for some types)", - description=( - "The minimum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e minValue[x] - one_of_many="minValue", - one_of_many_required=False, - ) - - minValueTime: fhirtypes.Time = Field( - None, - alias="minValueTime", - title="Minimum Allowed Value (for some types)", - description=( - "The minimum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e minValue[x] - one_of_many="minValue", - one_of_many_required=False, - ) - minValueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_minValueTime", title="Extension field for ``minValueTime``." - ) - - minValueUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="minValueUnsignedInt", - title="Minimum Allowed Value (for some types)", - description=( - "The minimum allowed value for the element. The value is inclusive. " - "This is allowed for the types date, dateTime, instant, time, decimal, " - "integer, and Quantity." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e minValue[x] - one_of_many="minValue", - one_of_many_required=False, - ) - minValueUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_minValueUnsignedInt", - title="Extension field for ``minValueUnsignedInt``.", - ) - - mustSupport: bool = Field( - None, - alias="mustSupport", - title="If the element must be supported", - description=( - "If true, implementations that produce or consume resources SHALL " - 'provide "support" for the element in some meaningful way. If false, ' - "the element may be ignored and not supported. If false, whether to " - "populate or use the data element in any way is at the discretion of " - "the implementation." - ), - # if property is element of this resource. - element_property=True, - ) - mustSupport__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mustSupport", title="Extension field for ``mustSupport``." - ) - - orderMeaning: fhirtypes.String = Field( - None, - alias="orderMeaning", - title="What the order of the elements means", - description=( - "If present, indicates that the order of the repeating element has " - "meaning and describes what that meaning is. If absent, it means that " - "the order of the element has no meaning." - ), - # if property is element of this resource. - element_property=True, - ) - orderMeaning__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_orderMeaning", title="Extension field for ``orderMeaning``." - ) - - path: fhirtypes.String = Field( - None, - alias="path", - title="Path of the element in the hierarchy of elements", - description=( - 'The path identifies the element and is expressed as a "."-separated ' - "list of ancestor elements, beginning with the name of the resource or " - "extension." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_path", title="Extension field for ``path``." - ) - - patternAddress: fhirtypes.AddressType = Field( - None, - alias="patternAddress", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternAge: fhirtypes.AgeType = Field( - None, - alias="patternAge", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternAnnotation: fhirtypes.AnnotationType = Field( - None, - alias="patternAnnotation", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternAttachment: fhirtypes.AttachmentType = Field( - None, - alias="patternAttachment", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternBase64Binary: fhirtypes.Base64Binary = Field( - None, - alias="patternBase64Binary", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternBase64Binary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_patternBase64Binary", - title="Extension field for ``patternBase64Binary``.", - ) - - patternBoolean: bool = Field( - None, - alias="patternBoolean", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternBoolean", title="Extension field for ``patternBoolean``." - ) - - patternCanonical: fhirtypes.Canonical = Field( - None, - alias="patternCanonical", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_patternCanonical", - title="Extension field for ``patternCanonical``.", - ) - - patternCode: fhirtypes.Code = Field( - None, - alias="patternCode", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternCode", title="Extension field for ``patternCode``." - ) - - patternCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="patternCodeableConcept", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternCoding: fhirtypes.CodingType = Field( - None, - alias="patternCoding", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternContactDetail: fhirtypes.ContactDetailType = Field( - None, - alias="patternContactDetail", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternContactPoint: fhirtypes.ContactPointType = Field( - None, - alias="patternContactPoint", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternContributor: fhirtypes.ContributorType = Field( - None, - alias="patternContributor", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternCount: fhirtypes.CountType = Field( - None, - alias="patternCount", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternDataRequirement: fhirtypes.DataRequirementType = Field( - None, - alias="patternDataRequirement", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternDate: fhirtypes.Date = Field( - None, - alias="patternDate", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternDate", title="Extension field for ``patternDate``." - ) - - patternDateTime: fhirtypes.DateTime = Field( - None, - alias="patternDateTime", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternDateTime", title="Extension field for ``patternDateTime``." - ) - - patternDecimal: fhirtypes.Decimal = Field( - None, - alias="patternDecimal", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternDecimal", title="Extension field for ``patternDecimal``." - ) - - patternDistance: fhirtypes.DistanceType = Field( - None, - alias="patternDistance", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternDosage: fhirtypes.DosageType = Field( - None, - alias="patternDosage", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternDuration: fhirtypes.DurationType = Field( - None, - alias="patternDuration", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternExpression: fhirtypes.ExpressionType = Field( - None, - alias="patternExpression", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternHumanName: fhirtypes.HumanNameType = Field( - None, - alias="patternHumanName", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternId: fhirtypes.Id = Field( - None, - alias="patternId", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternId", title="Extension field for ``patternId``." - ) - - patternIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="patternIdentifier", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternInstant: fhirtypes.Instant = Field( - None, - alias="patternInstant", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternInstant__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternInstant", title="Extension field for ``patternInstant``." - ) - - patternInteger: fhirtypes.Integer = Field( - None, - alias="patternInteger", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternInteger", title="Extension field for ``patternInteger``." - ) - - patternMarkdown: fhirtypes.Markdown = Field( - None, - alias="patternMarkdown", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternMarkdown__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternMarkdown", title="Extension field for ``patternMarkdown``." - ) - - patternMeta: fhirtypes.MetaType = Field( - None, - alias="patternMeta", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternMoney: fhirtypes.MoneyType = Field( - None, - alias="patternMoney", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternOid: fhirtypes.Oid = Field( - None, - alias="patternOid", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternOid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternOid", title="Extension field for ``patternOid``." - ) - - patternParameterDefinition: fhirtypes.ParameterDefinitionType = Field( - None, - alias="patternParameterDefinition", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternPeriod: fhirtypes.PeriodType = Field( - None, - alias="patternPeriod", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternPositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="patternPositiveInt", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternPositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_patternPositiveInt", - title="Extension field for ``patternPositiveInt``.", - ) - - patternQuantity: fhirtypes.QuantityType = Field( - None, - alias="patternQuantity", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternRange: fhirtypes.RangeType = Field( - None, - alias="patternRange", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternRatio: fhirtypes.RatioType = Field( - None, - alias="patternRatio", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternReference: fhirtypes.ReferenceType = Field( - None, - alias="patternReference", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternRelatedArtifact: fhirtypes.RelatedArtifactType = Field( - None, - alias="patternRelatedArtifact", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternSampledData: fhirtypes.SampledDataType = Field( - None, - alias="patternSampledData", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternSignature: fhirtypes.SignatureType = Field( - None, - alias="patternSignature", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternString: fhirtypes.String = Field( - None, - alias="patternString", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternString", title="Extension field for ``patternString``." - ) - - patternTime: fhirtypes.Time = Field( - None, - alias="patternTime", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternTime", title="Extension field for ``patternTime``." - ) - - patternTiming: fhirtypes.TimingType = Field( - None, - alias="patternTiming", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternTriggerDefinition: fhirtypes.TriggerDefinitionType = Field( - None, - alias="patternTriggerDefinition", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="patternUnsignedInt", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_patternUnsignedInt", - title="Extension field for ``patternUnsignedInt``.", - ) - - patternUri: fhirtypes.Uri = Field( - None, - alias="patternUri", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternUri", title="Extension field for ``patternUri``." - ) - - patternUrl: fhirtypes.Url = Field( - None, - alias="patternUrl", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternUrl", title="Extension field for ``patternUrl``." - ) - - patternUsageContext: fhirtypes.UsageContextType = Field( - None, - alias="patternUsageContext", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - - patternUuid: fhirtypes.Uuid = Field( - None, - alias="patternUuid", - title="Value must have at least these property values", - description=( - "Specifies a value that the value in the instance SHALL follow - that " - "is, any value in the pattern must be found in the instance. Other " - "additional values may be found too. This is effectively constraint by " - "example. When pattern[x] is used to constrain a primitive, it means" - " that the value provided in the pattern[x] must match the instance " - "value exactly. When pattern[x] is used to constrain an array, it " - "means that each element provided in the pattern[x] array must " - "(recursively) match at least one element from the instance array. " - "When pattern[x] is used to constrain a complex object, it means that " - "each property in the pattern must be present in the complex object, " - "and its value must recursively match -- i.e., 1. If primitive: it " - "must match exactly the pattern value 2. If a complex object: it must " - "match (recursively) the pattern value 3. If an array: it must match " - "(recursively) the pattern value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e pattern[x] - one_of_many="pattern", - one_of_many_required=False, - ) - patternUuid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_patternUuid", title="Extension field for ``patternUuid``." - ) - - representation: typing.List[fhirtypes.Code] = Field( - None, - alias="representation", - title="xmlAttr | xmlText | typeAttr | cdaText | xhtml", - description=( - "Codes that define how this element is represented in instances, when " - "the deviation varies from the normal case." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["xmlAttr", "xmlText", "typeAttr", "cdaText", "xhtml"], - ) - representation__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_representation", title="Extension field for ``representation``." - ) - - requirements: fhirtypes.Markdown = Field( - None, - alias="requirements", - title="Why this resource has been created", - description=( - "This element is for traceability of why the element was created and " - "why the constraints exist as they do. This may be used to point to " - "source materials or specifications that drove the structure of this " - "element." - ), - # if property is element of this resource. - element_property=True, - ) - requirements__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_requirements", title="Extension field for ``requirements``." - ) - - short: fhirtypes.String = Field( - None, - alias="short", - title="Concise definition for space-constrained presentation", - description=( - "A concise description of what this element means (e.g. for use in " - "autogenerated summaries)." - ), - # if property is element of this resource. - element_property=True, - ) - short__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_short", title="Extension field for ``short``." - ) - - sliceIsConstraining: bool = Field( - None, - alias="sliceIsConstraining", - title=( - "If this slice definition constrains an inherited slice definition (or " - "not)" - ), - description=( - "If true, indicates that this slice definition is constraining a slice " - "definition with the same name in an inherited profile. If false, the " - "slice is not overriding any slice in an inherited profile. If missing," - " the slice might or might not be overriding a slice in an inherited " - "profile, depending on the sliceName." - ), - # if property is element of this resource. - element_property=True, - ) - sliceIsConstraining__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_sliceIsConstraining", - title="Extension field for ``sliceIsConstraining``.", - ) - - sliceName: fhirtypes.String = Field( - None, - alias="sliceName", - title="Name for this particular element (in a set of slices)", - description=( - "The name of this element definition slice, when slicing is working. " - "The name must be a token with no dots or spaces. This is a unique name" - " referring to a specific set of constraints applied to this element, " - "used to provide a name to different slices of the same element." - ), - # if property is element of this resource. - element_property=True, - ) - sliceName__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sliceName", title="Extension field for ``sliceName``." - ) - - slicing: fhirtypes.ElementDefinitionSlicingType = Field( - None, - alias="slicing", - title="This element is sliced - slices follow", - description=( - "Indicates that the element is sliced into a set of alternative " - "definitions (i.e. in a structure definition, there are multiple " - "different constraints on a single element in the base resource). " - "Slicing can be used in any resource that has cardinality ..* on the " - "base resource, or any resource with a choice of types. The set of " - "slices is any elements that come after this in the element sequence " - "that have the same path, until a shorter path occurs (the shorter path" - " terminates the set)." - ), - # if property is element of this resource. - element_property=True, - ) - - type: typing.List[fhirtypes.ElementDefinitionTypeType] = Field( - None, - alias="type", - title="Data type and Profile for this element", - description=( - "The data type or resource that the value of this element is permitted " - "to be." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ElementDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "path", - "representation", - "sliceName", - "sliceIsConstraining", - "label", - "code", - "slicing", - "short", - "definition", - "comment", - "requirements", - "alias", - "min", - "max", - "base", - "contentReference", - "type", - "defaultValueBase64Binary", - "defaultValueBoolean", - "defaultValueCanonical", - "defaultValueCode", - "defaultValueDate", - "defaultValueDateTime", - "defaultValueDecimal", - "defaultValueId", - "defaultValueInstant", - "defaultValueInteger", - "defaultValueMarkdown", - "defaultValueOid", - "defaultValuePositiveInt", - "defaultValueString", - "defaultValueTime", - "defaultValueUnsignedInt", - "defaultValueUri", - "defaultValueUrl", - "defaultValueUuid", - "defaultValueAddress", - "defaultValueAge", - "defaultValueAnnotation", - "defaultValueAttachment", - "defaultValueCodeableConcept", - "defaultValueCoding", - "defaultValueContactPoint", - "defaultValueCount", - "defaultValueDistance", - "defaultValueDuration", - "defaultValueHumanName", - "defaultValueIdentifier", - "defaultValueMoney", - "defaultValuePeriod", - "defaultValueQuantity", - "defaultValueRange", - "defaultValueRatio", - "defaultValueReference", - "defaultValueSampledData", - "defaultValueSignature", - "defaultValueTiming", - "defaultValueContactDetail", - "defaultValueContributor", - "defaultValueDataRequirement", - "defaultValueExpression", - "defaultValueParameterDefinition", - "defaultValueRelatedArtifact", - "defaultValueTriggerDefinition", - "defaultValueUsageContext", - "defaultValueDosage", - "defaultValueMeta", - "meaningWhenMissing", - "orderMeaning", - "fixedBase64Binary", - "fixedBoolean", - "fixedCanonical", - "fixedCode", - "fixedDate", - "fixedDateTime", - "fixedDecimal", - "fixedId", - "fixedInstant", - "fixedInteger", - "fixedMarkdown", - "fixedOid", - "fixedPositiveInt", - "fixedString", - "fixedTime", - "fixedUnsignedInt", - "fixedUri", - "fixedUrl", - "fixedUuid", - "fixedAddress", - "fixedAge", - "fixedAnnotation", - "fixedAttachment", - "fixedCodeableConcept", - "fixedCoding", - "fixedContactPoint", - "fixedCount", - "fixedDistance", - "fixedDuration", - "fixedHumanName", - "fixedIdentifier", - "fixedMoney", - "fixedPeriod", - "fixedQuantity", - "fixedRange", - "fixedRatio", - "fixedReference", - "fixedSampledData", - "fixedSignature", - "fixedTiming", - "fixedContactDetail", - "fixedContributor", - "fixedDataRequirement", - "fixedExpression", - "fixedParameterDefinition", - "fixedRelatedArtifact", - "fixedTriggerDefinition", - "fixedUsageContext", - "fixedDosage", - "fixedMeta", - "patternBase64Binary", - "patternBoolean", - "patternCanonical", - "patternCode", - "patternDate", - "patternDateTime", - "patternDecimal", - "patternId", - "patternInstant", - "patternInteger", - "patternMarkdown", - "patternOid", - "patternPositiveInt", - "patternString", - "patternTime", - "patternUnsignedInt", - "patternUri", - "patternUrl", - "patternUuid", - "patternAddress", - "patternAge", - "patternAnnotation", - "patternAttachment", - "patternCodeableConcept", - "patternCoding", - "patternContactPoint", - "patternCount", - "patternDistance", - "patternDuration", - "patternHumanName", - "patternIdentifier", - "patternMoney", - "patternPeriod", - "patternQuantity", - "patternRange", - "patternRatio", - "patternReference", - "patternSampledData", - "patternSignature", - "patternTiming", - "patternContactDetail", - "patternContributor", - "patternDataRequirement", - "patternExpression", - "patternParameterDefinition", - "patternRelatedArtifact", - "patternTriggerDefinition", - "patternUsageContext", - "patternDosage", - "patternMeta", - "example", - "minValueDate", - "minValueDateTime", - "minValueInstant", - "minValueTime", - "minValueDecimal", - "minValueInteger", - "minValuePositiveInt", - "minValueUnsignedInt", - "minValueQuantity", - "maxValueDate", - "maxValueDateTime", - "maxValueInstant", - "maxValueTime", - "maxValueDecimal", - "maxValueInteger", - "maxValuePositiveInt", - "maxValueUnsignedInt", - "maxValueQuantity", - "maxLength", - "condition", - "constraint", - "mustSupport", - "isModifier", - "isModifierReason", - "isSummary", - "binding", - "mapping", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1926( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("path", "path__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1926( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "defaultValue": [ - "defaultValueAddress", - "defaultValueAge", - "defaultValueAnnotation", - "defaultValueAttachment", - "defaultValueBase64Binary", - "defaultValueBoolean", - "defaultValueCanonical", - "defaultValueCode", - "defaultValueCodeableConcept", - "defaultValueCoding", - "defaultValueContactDetail", - "defaultValueContactPoint", - "defaultValueContributor", - "defaultValueCount", - "defaultValueDataRequirement", - "defaultValueDate", - "defaultValueDateTime", - "defaultValueDecimal", - "defaultValueDistance", - "defaultValueDosage", - "defaultValueDuration", - "defaultValueExpression", - "defaultValueHumanName", - "defaultValueId", - "defaultValueIdentifier", - "defaultValueInstant", - "defaultValueInteger", - "defaultValueMarkdown", - "defaultValueMeta", - "defaultValueMoney", - "defaultValueOid", - "defaultValueParameterDefinition", - "defaultValuePeriod", - "defaultValuePositiveInt", - "defaultValueQuantity", - "defaultValueRange", - "defaultValueRatio", - "defaultValueReference", - "defaultValueRelatedArtifact", - "defaultValueSampledData", - "defaultValueSignature", - "defaultValueString", - "defaultValueTime", - "defaultValueTiming", - "defaultValueTriggerDefinition", - "defaultValueUnsignedInt", - "defaultValueUri", - "defaultValueUrl", - "defaultValueUsageContext", - "defaultValueUuid", - ], - "fixed": [ - "fixedAddress", - "fixedAge", - "fixedAnnotation", - "fixedAttachment", - "fixedBase64Binary", - "fixedBoolean", - "fixedCanonical", - "fixedCode", - "fixedCodeableConcept", - "fixedCoding", - "fixedContactDetail", - "fixedContactPoint", - "fixedContributor", - "fixedCount", - "fixedDataRequirement", - "fixedDate", - "fixedDateTime", - "fixedDecimal", - "fixedDistance", - "fixedDosage", - "fixedDuration", - "fixedExpression", - "fixedHumanName", - "fixedId", - "fixedIdentifier", - "fixedInstant", - "fixedInteger", - "fixedMarkdown", - "fixedMeta", - "fixedMoney", - "fixedOid", - "fixedParameterDefinition", - "fixedPeriod", - "fixedPositiveInt", - "fixedQuantity", - "fixedRange", - "fixedRatio", - "fixedReference", - "fixedRelatedArtifact", - "fixedSampledData", - "fixedSignature", - "fixedString", - "fixedTime", - "fixedTiming", - "fixedTriggerDefinition", - "fixedUnsignedInt", - "fixedUri", - "fixedUrl", - "fixedUsageContext", - "fixedUuid", - ], - "maxValue": [ - "maxValueDate", - "maxValueDateTime", - "maxValueDecimal", - "maxValueInstant", - "maxValueInteger", - "maxValuePositiveInt", - "maxValueQuantity", - "maxValueTime", - "maxValueUnsignedInt", - ], - "minValue": [ - "minValueDate", - "minValueDateTime", - "minValueDecimal", - "minValueInstant", - "minValueInteger", - "minValuePositiveInt", - "minValueQuantity", - "minValueTime", - "minValueUnsignedInt", - ], - "pattern": [ - "patternAddress", - "patternAge", - "patternAnnotation", - "patternAttachment", - "patternBase64Binary", - "patternBoolean", - "patternCanonical", - "patternCode", - "patternCodeableConcept", - "patternCoding", - "patternContactDetail", - "patternContactPoint", - "patternContributor", - "patternCount", - "patternDataRequirement", - "patternDate", - "patternDateTime", - "patternDecimal", - "patternDistance", - "patternDosage", - "patternDuration", - "patternExpression", - "patternHumanName", - "patternId", - "patternIdentifier", - "patternInstant", - "patternInteger", - "patternMarkdown", - "patternMeta", - "patternMoney", - "patternOid", - "patternParameterDefinition", - "patternPeriod", - "patternPositiveInt", - "patternQuantity", - "patternRange", - "patternRatio", - "patternReference", - "patternRelatedArtifact", - "patternSampledData", - "patternSignature", - "patternString", - "patternTime", - "patternTiming", - "patternTriggerDefinition", - "patternUnsignedInt", - "patternUri", - "patternUrl", - "patternUsageContext", - "patternUuid", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ElementDefinitionBase(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Base definition information for tools. - Information about the base definition of the element, provided to make it - unnecessary for tools to trace the deviation of the element through the - derived and related profiles. When the element definition is not the - original definition of an element - i.g. either in a constraint on another - type, or for elements from a super type in a snap shot - then the - information in provided in the element definition may be different to the - base definition. On the original definition of the element, it will be - same. - """ - - resource_type = Field("ElementDefinitionBase", const=True) - - max: fhirtypes.String = Field( - None, - alias="max", - title="Max cardinality of the base element", - description="Maximum cardinality of the base element identified by the path.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - max__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_max", title="Extension field for ``max``." - ) - - min: fhirtypes.UnsignedInt = Field( - None, - alias="min", - title="Min cardinality of the base element", - description="Minimum cardinality of the base element identified by the path.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - min__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_min", title="Extension field for ``min``." - ) - - path: fhirtypes.String = Field( - None, - alias="path", - title="Path that identifies the base element", - description=( - "The Path that identifies the base element - this matches the " - "ElementDefinition.path for that element. Across FHIR, there is only " - "one base definition of any element - that is, an element definition on" - " a [StructureDefinition](structuredefinition.html#) without a " - "StructureDefinition.base." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_path", title="Extension field for ``path``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ElementDefinitionBase`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "path", "min", "max"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2296( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("max", "max__ext"), - ("min", "min__ext"), - ("path", "path__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ElementDefinitionBinding(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - ValueSet details if this is coded. - Binds to a value set if this element is coded (code, Coding, - CodeableConcept, Quantity), or the data types (string, uri). - """ - - resource_type = Field("ElementDefinitionBinding", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Human explanation of the value set", - description="Describes the intended use of this particular set of codes.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - strength: fhirtypes.Code = Field( - None, - alias="strength", - title="required | extensible | preferred | example", - description=( - "Indicates the degree of conformance expectations associated with this " - "binding - that is, the degree to which the provided value set must be " - "adhered to in the instances." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["required", "extensible", "preferred", "example"], - ) - strength__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_strength", title="Extension field for ``strength``." - ) - - valueSet: fhirtypes.Canonical = Field( - None, - alias="valueSet", - title="Source of value set", - description=( - "Refers to the value set that identifies the set of codes the binding " - "refers to." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - valueSet__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueSet", title="Extension field for ``valueSet``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ElementDefinitionBinding`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "strength", "description", "valueSet"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2618( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("strength", "strength__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ElementDefinitionConstraint(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Condition that must evaluate to true. - Formal constraints such as co-occurrence and other constraints that can be - computationally evaluated within the context of the instance. - """ - - resource_type = Field("ElementDefinitionConstraint", const=True) - - expression: fhirtypes.String = Field( - None, - alias="expression", - title="FHIRPath expression of constraint", - description=( - "A [FHIRPath](fhirpath.html) expression of constraint that can be " - "executed to see if this constraint is met." - ), - # if property is element of this resource. - element_property=True, - ) - expression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expression", title="Extension field for ``expression``." - ) - - human: fhirtypes.String = Field( - None, - alias="human", - title="Human description of constraint", - description=( - "Text that can be used to describe the constraint in messages " - "identifying that the constraint has been violated." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - human__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_human", title="Extension field for ``human``." - ) - - key: fhirtypes.Id = Field( - None, - alias="key", - title="Target of 'condition' reference above", - description=( - "Allows identification of which elements have their cardinalities " - "impacted by the constraint. Will not be referenced for constraints " - "that do not affect cardinality." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - key__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_key", title="Extension field for ``key``." - ) - - requirements: fhirtypes.String = Field( - None, - alias="requirements", - title="Why this constraint is necessary or appropriate", - description="Description of why this constraint is necessary or appropriate.", - # if property is element of this resource. - element_property=True, - ) - requirements__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_requirements", title="Extension field for ``requirements``." - ) - - severity: fhirtypes.Code = Field( - None, - alias="severity", - title="error | warning", - description=( - "Identifies the impact constraint violation has on the conformance of " - "the instance." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["error", "warning"], - ) - severity__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_severity", title="Extension field for ``severity``." - ) - - source: fhirtypes.Canonical = Field( - None, - alias="source", - title="Reference to original source of constraint", - description=( - "A reference to the original source of the constraint, for traceability" - " purposes." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - source__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_source", title="Extension field for ``source``." - ) - - xpath: fhirtypes.String = Field( - None, - alias="xpath", - title="XPath expression of constraint", - description=( - "An XPath expression of constraint that can be executed to see if this " - "constraint is met." - ), - # if property is element of this resource. - element_property=True, - ) - xpath__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_xpath", title="Extension field for ``xpath``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ElementDefinitionConstraint`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "key", - "requirements", - "severity", - "human", - "expression", - "xpath", - "source", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2993( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("human", "human__ext"), - ("key", "key__ext"), - ("severity", "severity__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ElementDefinitionExample(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Example value (as defined for type). - A sample value for this element demonstrating the type of information that - would typically be found in the element. - """ - - resource_type = Field("ElementDefinitionExample", const=True) - - label: fhirtypes.String = Field( - None, - alias="label", - title="Describes the purpose of this example", - description="Describes the purpose of this example amoung the set of examples.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - label__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_label", title="Extension field for ``label``." - ) - - valueAddress: fhirtypes.AddressType = Field( - None, - alias="valueAddress", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueAge: fhirtypes.AgeType = Field( - None, - alias="valueAge", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueAnnotation: fhirtypes.AnnotationType = Field( - None, - alias="valueAnnotation", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="valueAttachment", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueBase64Binary: fhirtypes.Base64Binary = Field( - None, - alias="valueBase64Binary", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBase64Binary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valueBase64Binary", - title="Extension field for ``valueBase64Binary``.", - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCanonical: fhirtypes.Canonical = Field( - None, - alias="valueCanonical", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueCanonical", title="Extension field for ``valueCanonical``." - ) - - valueCode: fhirtypes.Code = Field( - None, - alias="valueCode", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueCode", title="Extension field for ``valueCode``." - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueCoding: fhirtypes.CodingType = Field( - None, - alias="valueCoding", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueContactDetail: fhirtypes.ContactDetailType = Field( - None, - alias="valueContactDetail", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueContactPoint: fhirtypes.ContactPointType = Field( - None, - alias="valueContactPoint", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueContributor: fhirtypes.ContributorType = Field( - None, - alias="valueContributor", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueCount: fhirtypes.CountType = Field( - None, - alias="valueCount", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDataRequirement: fhirtypes.DataRequirementType = Field( - None, - alias="valueDataRequirement", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDate: fhirtypes.Date = Field( - None, - alias="valueDate", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDate", title="Extension field for ``valueDate``." - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueDecimal: fhirtypes.Decimal = Field( - None, - alias="valueDecimal", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDecimal", title="Extension field for ``valueDecimal``." - ) - - valueDistance: fhirtypes.DistanceType = Field( - None, - alias="valueDistance", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDosage: fhirtypes.DosageType = Field( - None, - alias="valueDosage", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDuration: fhirtypes.DurationType = Field( - None, - alias="valueDuration", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueExpression: fhirtypes.ExpressionType = Field( - None, - alias="valueExpression", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueHumanName: fhirtypes.HumanNameType = Field( - None, - alias="valueHumanName", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueId: fhirtypes.Id = Field( - None, - alias="valueId", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueId", title="Extension field for ``valueId``." - ) - - valueIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="valueIdentifier", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueInstant: fhirtypes.Instant = Field( - None, - alias="valueInstant", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueInstant__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInstant", title="Extension field for ``valueInstant``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valueMarkdown: fhirtypes.Markdown = Field( - None, - alias="valueMarkdown", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueMarkdown__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueMarkdown", title="Extension field for ``valueMarkdown``." - ) - - valueMeta: fhirtypes.MetaType = Field( - None, - alias="valueMeta", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueMoney: fhirtypes.MoneyType = Field( - None, - alias="valueMoney", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueOid: fhirtypes.Oid = Field( - None, - alias="valueOid", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueOid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueOid", title="Extension field for ``valueOid``." - ) - - valueParameterDefinition: fhirtypes.ParameterDefinitionType = Field( - None, - alias="valueParameterDefinition", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valuePeriod: fhirtypes.PeriodType = Field( - None, - alias="valuePeriod", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valuePositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="valuePositiveInt", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valuePositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valuePositiveInt", - title="Extension field for ``valuePositiveInt``.", - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueRange: fhirtypes.RangeType = Field( - None, - alias="valueRange", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueRatio: fhirtypes.RatioType = Field( - None, - alias="valueRatio", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueRelatedArtifact: fhirtypes.RelatedArtifactType = Field( - None, - alias="valueRelatedArtifact", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueSampledData: fhirtypes.SampledDataType = Field( - None, - alias="valueSampledData", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueSignature: fhirtypes.SignatureType = Field( - None, - alias="valueSignature", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - valueTime: fhirtypes.Time = Field( - None, - alias="valueTime", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueTime", title="Extension field for ``valueTime``." - ) - - valueTiming: fhirtypes.TimingType = Field( - None, - alias="valueTiming", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueTriggerDefinition: fhirtypes.TriggerDefinitionType = Field( - None, - alias="valueTriggerDefinition", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="valueUnsignedInt", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valueUnsignedInt", - title="Extension field for ``valueUnsignedInt``.", - ) - - valueUri: fhirtypes.Uri = Field( - None, - alias="valueUri", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUri", title="Extension field for ``valueUri``." - ) - - valueUrl: fhirtypes.Url = Field( - None, - alias="valueUrl", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUrl", title="Extension field for ``valueUrl``." - ) - - valueUsageContext: fhirtypes.UsageContextType = Field( - None, - alias="valueUsageContext", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueUuid: fhirtypes.Uuid = Field( - None, - alias="valueUuid", - title="Value of Example (one of allowed types)", - description=( - "The actual value for the element, which must be one of the types " - "allowed for this element." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUuid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUuid", title="Extension field for ``valueUuid``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ElementDefinitionExample`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "label", - "valueBase64Binary", - "valueBoolean", - "valueCanonical", - "valueCode", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueId", - "valueInstant", - "valueInteger", - "valueMarkdown", - "valueOid", - "valuePositiveInt", - "valueString", - "valueTime", - "valueUnsignedInt", - "valueUri", - "valueUrl", - "valueUuid", - "valueAddress", - "valueAge", - "valueAnnotation", - "valueAttachment", - "valueCodeableConcept", - "valueCoding", - "valueContactPoint", - "valueCount", - "valueDistance", - "valueDuration", - "valueHumanName", - "valueIdentifier", - "valueMoney", - "valuePeriod", - "valueQuantity", - "valueRange", - "valueRatio", - "valueReference", - "valueSampledData", - "valueSignature", - "valueTiming", - "valueContactDetail", - "valueContributor", - "valueDataRequirement", - "valueExpression", - "valueParameterDefinition", - "valueRelatedArtifact", - "valueTriggerDefinition", - "valueUsageContext", - "valueDosage", - "valueMeta", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2633( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("label", "label__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2633( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueAddress", - "valueAge", - "valueAnnotation", - "valueAttachment", - "valueBase64Binary", - "valueBoolean", - "valueCanonical", - "valueCode", - "valueCodeableConcept", - "valueCoding", - "valueContactDetail", - "valueContactPoint", - "valueContributor", - "valueCount", - "valueDataRequirement", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueDistance", - "valueDosage", - "valueDuration", - "valueExpression", - "valueHumanName", - "valueId", - "valueIdentifier", - "valueInstant", - "valueInteger", - "valueMarkdown", - "valueMeta", - "valueMoney", - "valueOid", - "valueParameterDefinition", - "valuePeriod", - "valuePositiveInt", - "valueQuantity", - "valueRange", - "valueRatio", - "valueReference", - "valueRelatedArtifact", - "valueSampledData", - "valueSignature", - "valueString", - "valueTime", - "valueTiming", - "valueTriggerDefinition", - "valueUnsignedInt", - "valueUri", - "valueUrl", - "valueUsageContext", - "valueUuid", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ElementDefinitionMapping(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Map element to another set of definitions. - Identifies a concept from an external specification that roughly - corresponds to this element. - """ - - resource_type = Field("ElementDefinitionMapping", const=True) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Comments about the mapping or its use", - description="Comments that provide information about the mapping or its use.", - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - identity: fhirtypes.Id = Field( - None, - alias="identity", - title="Reference to mapping declaration", - description="An internal reference to the definition of a mapping.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - identity__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_identity", title="Extension field for ``identity``." - ) - - language: fhirtypes.Code = Field( - None, - alias="language", - title="Computable language of mapping", - description="Identifies the computable language in which mapping.map is expressed.", - # if property is element of this resource. - element_property=True, - ) - language__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_language", title="Extension field for ``language``." - ) - - map: fhirtypes.String = Field( - None, - alias="map", - title="Details of the mapping", - description=( - "Expresses what part of the target specification corresponds to this " - "element." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - map__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_map", title="Extension field for ``map``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ElementDefinitionMapping`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "identity", "language", "map", "comment"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2635( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("identity", "identity__ext"), ("map", "map__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ElementDefinitionSlicing(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - This element is sliced - slices follow. - Indicates that the element is sliced into a set of alternative definitions - (i.e. in a structure definition, there are multiple different constraints - on a single element in the base resource). Slicing can be used in any - resource that has cardinality ..* on the base resource, or any resource - with a choice of types. The set of slices is any elements that come after - this in the element sequence that have the same path, until a shorter path - occurs (the shorter path terminates the set). - """ - - resource_type = Field("ElementDefinitionSlicing", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Text description of how slicing works (or not)", - description=( - "A human-readable text description of how the slicing works. If there " - "is no discriminator, this is required to be present to provide " - "whatever information is possible about how the slices can be " - "differentiated." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - discriminator: typing.List[ - fhirtypes.ElementDefinitionSlicingDiscriminatorType - ] = Field( - None, - alias="discriminator", - title="Element values that are used to distinguish the slices", - description=( - "Designates which child elements are used to discriminate between the " - "slices when processing an instance. If one or more discriminators are " - "provided, the value of the child elements in the instance data SHALL " - "completely distinguish which slice the element in the resource matches" - " based on the allowed values for those elements in each of the slices." - ), - # if property is element of this resource. - element_property=True, - ) - - ordered: bool = Field( - None, - alias="ordered", - title="If elements must be in same order as slices", - description=( - "If the matching elements have to occur in the same order as defined in" - " the profile." - ), - # if property is element of this resource. - element_property=True, - ) - ordered__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_ordered", title="Extension field for ``ordered``." - ) - - rules: fhirtypes.Code = Field( - None, - alias="rules", - title="closed | open | openAtEnd", - description=( - "Whether additional slices are allowed or not. When the slices are " - "ordered, profile authors can also say that additional slices are only " - "allowed at the end." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["closed", "open", "openAtEnd"], - ) - rules__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_rules", title="Extension field for ``rules``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ElementDefinitionSlicing`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "discriminator", "description", "ordered", "rules"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2632( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("rules", "rules__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ElementDefinitionSlicingDiscriminator(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Element values that are used to distinguish the slices. - Designates which child elements are used to discriminate between the slices - when processing an instance. If one or more discriminators are provided, - the value of the child elements in the instance data SHALL completely - distinguish which slice the element in the resource matches based on the - allowed values for those elements in each of the slices. - """ - - resource_type = Field("ElementDefinitionSlicingDiscriminator", const=True) - - path: fhirtypes.String = Field( - None, - alias="path", - title="Path to element value", - description=( - "A FHIRPath expression, using [the simple subset of " - "FHIRPath](fhirpath.html#simple), that is used to identify the element " - "on which discrimination is based." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_path", title="Extension field for ``path``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="value | exists | pattern | type | profile", - description="How the element value is interpreted when discrimination is evaluated.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["value", "exists", "pattern", "type", "profile"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ElementDefinitionSlicingDiscriminator`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "type", "path"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4011( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("path", "path__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ElementDefinitionType(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Data type and Profile for this element. - The data type or resource that the value of this element is permitted to - be. - """ - - resource_type = Field("ElementDefinitionType", const=True) - - aggregation: typing.List[fhirtypes.Code] = Field( - None, - alias="aggregation", - title="contained | referenced | bundled - how aggregated", - description=( - "If the type is a reference to another resource, how the resource is or" - " can be aggregated - is it a contained resource, or a reference, and " - "if the context is a bundle, is it included in the bundle." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["contained", "referenced", "bundled"], - ) - aggregation__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_aggregation", title="Extension field for ``aggregation``.") - - code: fhirtypes.Uri = Field( - None, - alias="code", - title="Data type or Resource (reference to definition)", - description=( - "URL of Data type or Resource that is a(or the) type used for this " - "element. References are URLs that are relative to " - 'http://hl7.org/fhir/StructureDefinition e.g. "string" is a reference ' - "to http://hl7.org/fhir/StructureDefinition/string. Absolute URLs are " - "only allowed in logical models." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - profile: typing.List[fhirtypes.Canonical] = Field( - None, - alias="profile", - title="Profiles (StructureDefinition or IG) - one must apply", - description=( - "Identifies a profile structure or implementation Guide that applies to" - " the datatype this element refers to. If any profiles are specified, " - "then the content must conform to at least one of them. The URL can be " - "a local reference - to a contained StructureDefinition, or a reference" - " to another StructureDefinition or Implementation Guide by a canonical" - " URL. When an implementation guide is specified, the type SHALL " - "conform to at least one profile defined in the implementation guide." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition", "ImplementationGuide"], - ) - profile__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_profile", title="Extension field for ``profile``.") - - targetProfile: typing.List[fhirtypes.Canonical] = Field( - None, - alias="targetProfile", - title=( - "Profile (StructureDefinition or IG) on the Reference/canonical target " - "- one must apply" - ), - description=( - 'Used when the type is "Reference" or "canonical", and identifies a ' - "profile structure or implementation Guide that applies to the target " - "of the reference this element refers to. If any profiles are " - "specified, then the content must conform to at least one of them. The " - "URL can be a local reference - to a contained StructureDefinition, or " - "a reference to another StructureDefinition or Implementation Guide by " - "a canonical URL. When an implementation guide is specified, the target" - " resource SHALL conform to at least one profile defined in the " - "implementation guide." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition", "ImplementationGuide"], - ) - targetProfile__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_targetProfile", title="Extension field for ``targetProfile``." - ) - - versioning: fhirtypes.Code = Field( - None, - alias="versioning", - title="either | independent | specific", - description=( - "Whether this reference needs to be version specific or version " - "independent, or whether either can be used." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["either", "independent", "specific"], - ) - versioning__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_versioning", title="Extension field for ``versioning``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ElementDefinitionType`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "code", - "profile", - "targetProfile", - "aggregation", - "versioning", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2335( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/encounter.py b/fhir/resources/encounter.py deleted file mode 100644 index fcb75115..00000000 --- a/fhir/resources/encounter.py +++ /dev/null @@ -1,909 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Encounter -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Encounter(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An interaction during which services are provided to the patient. - An interaction between a patient and healthcare provider(s) for the purpose - of providing healthcare service(s) or assessing the health status of a - patient. - """ - - resource_type = Field("Encounter", const=True) - - account: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="account", - title="The set of accounts that may be used for billing for this Encounter", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Account"], - ) - - appointment: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="appointment", - title="The appointment that scheduled this encounter", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Appointment"], - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="The ServiceRequest that initiated this encounter", - description=( - "The request this encounter satisfies (e.g. incoming referral or " - "procedure request)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ServiceRequest"], - ) - - classHistory: typing.List[fhirtypes.EncounterClassHistoryType] = Field( - None, - alias="classHistory", - title="List of past encounter classes", - description=( - "The class history permits the tracking of the encounters transitions " - "without needing to go through the resource history. This would be " - "used for a case where an admission starts of as an emergency " - "encounter, then transitions into an inpatient scenario. Doing this and" - " not restarting a new encounter ensures that any lab/diagnostic " - "results can more easily follow the patient and not require re-" - "processing and not get lost or cancelled during a kind of discharge " - "from emergency to inpatient." - ), - # if property is element of this resource. - element_property=True, - ) - - class_fhir: fhirtypes.CodingType = Field( - ..., - alias="class", - title="Classification of patient encounter", - description=( - "Concepts representing classification of patient encounter such as " - "ambulatory (outpatient), inpatient, emergency, home health or others " - "due to local variations." - ), - # if property is element of this resource. - element_property=True, - ) - - diagnosis: typing.List[fhirtypes.EncounterDiagnosisType] = Field( - None, - alias="diagnosis", - title="The list of diagnosis relevant to this encounter", - description=None, - # if property is element of this resource. - element_property=True, - ) - - episodeOfCare: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="episodeOfCare", - title="Episode(s) of care that this encounter should be recorded against", - description=( - "Where a specific encounter should be classified as a part of a " - "specific episode(s) of care this field should be used. This " - "association can facilitate grouping of related encounters together for" - " a specific purpose, such as government reporting, issue tracking, " - "association via a common problem. The association is recorded on the " - "encounter as these are typically created after the episode of care and" - " grouped on entry rather than editing the episode of care to append " - "another encounter to it (the episode of care could span years)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EpisodeOfCare"], - ) - - hospitalization: fhirtypes.EncounterHospitalizationType = Field( - None, - alias="hospitalization", - title="Details about the admission to a healthcare service", - description=None, - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Identifier(s) by which this encounter is known", - description=None, - # if property is element of this resource. - element_property=True, - ) - - length: fhirtypes.DurationType = Field( - None, - alias="length", - title="Quantity of time the encounter lasted (less time absent)", - description=( - "Quantity of time the encounter lasted. This excludes the time during " - "leaves of absence." - ), - # if property is element of this resource. - element_property=True, - ) - - location: typing.List[fhirtypes.EncounterLocationType] = Field( - None, - alias="location", - title="List of locations where the patient has been", - description="List of locations where the patient has been during this encounter.", - # if property is element of this resource. - element_property=True, - ) - - partOf: fhirtypes.ReferenceType = Field( - None, - alias="partOf", - title="Another Encounter this encounter is part of", - description=( - "Another Encounter of which this encounter is a part of " - "(administratively or in time)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - participant: typing.List[fhirtypes.EncounterParticipantType] = Field( - None, - alias="participant", - title="List of participants involved in the encounter", - description="The list of people responsible for providing the service.", - # if property is element of this resource. - element_property=True, - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="The start and end time of the encounter", - description=None, - # if property is element of this resource. - element_property=True, - ) - - priority: fhirtypes.CodeableConceptType = Field( - None, - alias="priority", - title="Indicates the urgency of the encounter", - description=None, - # if property is element of this resource. - element_property=True, - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Coded reason the encounter takes place", - description=( - "Reason the encounter takes place, expressed as a code. For admissions," - " this can be used for a coded admission diagnosis." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Reason the encounter takes place (reference)", - description=( - "Reason the encounter takes place, expressed as a code. For admissions," - " this can be used for a coded admission diagnosis." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Procedure", - "Observation", - "ImmunizationRecommendation", - ], - ) - - serviceProvider: fhirtypes.ReferenceType = Field( - None, - alias="serviceProvider", - title="The organization (facility) responsible for this encounter", - description=( - "The organization that is primarily responsible for this Encounter's " - "services. This MAY be the same as the organization on the Patient " - "record, however it could be different, such as if the actor performing" - " the services was from an external organization (which may be billed " - "seperately) for an external consultation. Refer to the example bundle" - " showing an abbreviated set of Encounters for a colonoscopy." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - serviceType: fhirtypes.CodeableConceptType = Field( - None, - alias="serviceType", - title="Specific type of service", - description=( - "Broad categorization of the service that is to be provided (e.g. " - "cardiology)." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "planned | arrived | triaged | in-progress | onleave | finished | " - "cancelled +" - ), - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "planned", - "arrived", - "triaged", - "in-progress", - "onleave", - "finished", - "cancelled", - "+", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusHistory: typing.List[fhirtypes.EncounterStatusHistoryType] = Field( - None, - alias="statusHistory", - title="List of past encounter statuses", - description=( - "The status history permits the encounter resource to contain the " - "status history without needing to read through the historical versions" - " of the resource, or even have the server store them." - ), - # if property is element of this resource. - element_property=True, - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="The patient or group present at the encounter", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Specific type of encounter", - description=( - "Specific type of encounter (e.g. e-mail consultation, surgical day-" - "care, skilled nursing, rehabilitation)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Encounter`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "statusHistory", - "class", - "classHistory", - "type", - "serviceType", - "priority", - "subject", - "episodeOfCare", - "basedOn", - "participant", - "appointment", - "period", - "length", - "reasonCode", - "reasonReference", - "diagnosis", - "account", - "hospitalization", - "location", - "serviceProvider", - "partOf", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1130( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class EncounterClassHistory(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - List of past encounter classes. - The class history permits the tracking of the encounters transitions - without needing to go through the resource history. This would be used - for a case where an admission starts of as an emergency encounter, then - transitions into an inpatient scenario. Doing this and not restarting a new - encounter ensures that any lab/diagnostic results can more easily follow - the patient and not require re-processing and not get lost or cancelled - during a kind of discharge from emergency to inpatient. - """ - - resource_type = Field("EncounterClassHistory", const=True) - - class_fhir: fhirtypes.CodingType = Field( - ..., - alias="class", - title="inpatient | outpatient | ambulatory | emergency +", - description=None, - # if property is element of this resource. - element_property=True, - ) - - period: fhirtypes.PeriodType = Field( - ..., - alias="period", - title="The time that the episode was in the specified class", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EncounterClassHistory`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "class", "period"] - - -class EncounterDiagnosis(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The list of diagnosis relevant to this encounter. - """ - - resource_type = Field("EncounterDiagnosis", const=True) - - condition: fhirtypes.ReferenceType = Field( - ..., - alias="condition", - title="The diagnosis or procedure relevant to the encounter", - description=( - "Reason the encounter takes place, as specified using information from " - "another resource. For admissions, this is the admission diagnosis. The" - " indication will typically be a Condition (with other resources " - "referenced in the evidence.detail), or a Procedure." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition", "Procedure"], - ) - - rank: fhirtypes.PositiveInt = Field( - None, - alias="rank", - title="Ranking of the diagnosis (for each role type)", - description=None, - # if property is element of this resource. - element_property=True, - ) - rank__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_rank", title="Extension field for ``rank``." - ) - - use: fhirtypes.CodeableConceptType = Field( - None, - alias="use", - title=( - "Role that this diagnosis has within the encounter (e.g. admission, " - "billing, discharge \u2026)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EncounterDiagnosis`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "condition", "use", "rank"] - - -class EncounterHospitalization(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Details about the admission to a healthcare service. - """ - - resource_type = Field("EncounterHospitalization", const=True) - - admitSource: fhirtypes.CodeableConceptType = Field( - None, - alias="admitSource", - title="From where patient was admitted (physician referral, transfer)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - destination: fhirtypes.ReferenceType = Field( - None, - alias="destination", - title="Location/organization to which the patient is discharged", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location", "Organization"], - ) - - dietPreference: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="dietPreference", - title="Diet preferences reported by the patient", - description=None, - # if property is element of this resource. - element_property=True, - ) - - dischargeDisposition: fhirtypes.CodeableConceptType = Field( - None, - alias="dischargeDisposition", - title="Category or kind of location after discharge", - description=None, - # if property is element of this resource. - element_property=True, - ) - - origin: fhirtypes.ReferenceType = Field( - None, - alias="origin", - title="The location/organization from which the patient came before admission", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location", "Organization"], - ) - - preAdmissionIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="preAdmissionIdentifier", - title="Pre-admission identifier", - description=None, - # if property is element of this resource. - element_property=True, - ) - - reAdmission: fhirtypes.CodeableConceptType = Field( - None, - alias="reAdmission", - title=( - "The type of hospital re-admission that has occurred (if any). If the " - "value is absent, then this is not identified as a readmission" - ), - description="Whether this hospitalization is a readmission and why if known.", - # if property is element of this resource. - element_property=True, - ) - - specialArrangement: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="specialArrangement", - title="Wheelchair, translator, stretcher, etc.", - description=( - "Any special requests that have been made for this hospitalization " - "encounter, such as the provision of specific equipment or other " - "things." - ), - # if property is element of this resource. - element_property=True, - ) - - specialCourtesy: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="specialCourtesy", - title="Special courtesies (VIP, board member)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EncounterHospitalization`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "preAdmissionIdentifier", - "origin", - "admitSource", - "reAdmission", - "dietPreference", - "specialCourtesy", - "specialArrangement", - "destination", - "dischargeDisposition", - ] - - -class EncounterLocation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - List of locations where the patient has been. - List of locations where the patient has been during this encounter. - """ - - resource_type = Field("EncounterLocation", const=True) - - location: fhirtypes.ReferenceType = Field( - ..., - alias="location", - title="Location the encounter takes place", - description="The location where the encounter takes place.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Time period during which the patient was present at the location", - description=None, - # if property is element of this resource. - element_property=True, - ) - - physicalType: fhirtypes.CodeableConceptType = Field( - None, - alias="physicalType", - title=( - "The physical type of the location (usually the level in the location " - "hierachy - bed room ward etc.)" - ), - description=( - "This will be used to specify the required levels (bed/ward/room/etc.) " - "desired to be recorded to simplify either messaging or query." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="planned | active | reserved | completed", - description=( - "The status of the participants' presence at the specified location " - "during the period specified. If the participant is no longer at the " - "location, then the period will have an end date/time." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["planned", "active", "reserved", "completed"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EncounterLocation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "location", - "status", - "physicalType", - "period", - ] - - -class EncounterParticipant(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - List of participants involved in the encounter. - The list of people responsible for providing the service. - """ - - resource_type = Field("EncounterParticipant", const=True) - - individual: fhirtypes.ReferenceType = Field( - None, - alias="individual", - title="Persons involved in the encounter other than the patient", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "RelatedPerson"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Period of time during the encounter that the participant participated", - description=( - "The period of time that the specified participant participated in the " - "encounter. These can overlap or be sub-sets of the overall encounter's" - " period." - ), - # if property is element of this resource. - element_property=True, - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Role of participant in encounter", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EncounterParticipant`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "period", "individual"] - - -class EncounterStatusHistory(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - List of past encounter statuses. - The status history permits the encounter resource to contain the status - history without needing to read through the historical versions of the - resource, or even have the server store them. - """ - - resource_type = Field("EncounterStatusHistory", const=True) - - period: fhirtypes.PeriodType = Field( - ..., - alias="period", - title="The time that the episode was in the specified status", - description=None, - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "planned | arrived | triaged | in-progress | onleave | finished | " - "cancelled +" - ), - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "planned", - "arrived", - "triaged", - "in-progress", - "onleave", - "finished", - "cancelled", - "+", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EncounterStatusHistory`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "status", "period"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2535( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/endpoint.py b/fhir/resources/endpoint.py deleted file mode 100644 index 670f568c..00000000 --- a/fhir/resources/endpoint.py +++ /dev/null @@ -1,271 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Endpoint -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class Endpoint(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The technical details of an endpoint that can be used for electronic - services. - The technical details of an endpoint that can be used for electronic - services, such as for web services providing XDS.b or a REST endpoint for - another FHIR server. This may include any security context information. - """ - - resource_type = Field("Endpoint", const=True) - - address: fhirtypes.Url = Field( - None, - alias="address", - title="The technical base address for connecting to this endpoint", - description="The uri that describes the actual end-point to connect to.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - address__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_address", title="Extension field for ``address``." - ) - - connectionType: fhirtypes.CodingType = Field( - ..., - alias="connectionType", - title="Protocol/Profile/Standard to be used with this endpoint connection", - description=( - "A coded value that represents the technical details of the usage of " - "this endpoint, such as what WSDLs should be used in what way. (e.g. " - "XDS.b/DICOM/cds-hook)." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="contact", - title="Contact details for source (e.g. troubleshooting)", - description=( - "Contact details for a human to contact about the subscription. The " - "primary use of this for system administrator troubleshooting." - ), - # if property is element of this resource. - element_property=True, - ) - - header: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="header", - title="Usage depends on the channel type", - description="Additional headers / information to send as part of the notification.", - # if property is element of this resource. - element_property=True, - ) - header__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_header", title="Extension field for ``header``.") - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Identifies this endpoint across multiple systems", - description=( - "Identifier for the organization that is used to identify the endpoint " - "across multiple disparate systems." - ), - # if property is element of this resource. - element_property=True, - ) - - managingOrganization: fhirtypes.ReferenceType = Field( - None, - alias="managingOrganization", - title=( - "Organization that manages this endpoint (might not be the organization" - " that exposes the endpoint)" - ), - description=( - "The organization that manages this endpoint (even if technically " - "another organization is hosting this in the cloud, it is the " - "organization associated with the data)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="A name that this endpoint can be identified by", - description="A friendly name that this endpoint can be referred to with.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - payloadMimeType: typing.List[fhirtypes.Code] = Field( - None, - alias="payloadMimeType", - title=( - "Mimetype to send. If not specified, the content could be anything " - "(including no payload, if the connectionType defined this)" - ), - description=( - "The mime type to send the payload in - e.g. application/fhir+xml, " - "application/fhir+json. If the mime type is not specified, then the " - "sender could send any content (including no content depending on the " - "connectionType)." - ), - # if property is element of this resource. - element_property=True, - ) - payloadMimeType__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_payloadMimeType", title="Extension field for ``payloadMimeType``." - ) - - payloadType: typing.List[fhirtypes.CodeableConceptType] = Field( - ..., - alias="payloadType", - title=( - "The type of content that may be used at this endpoint (e.g. XDS " - "Discharge summaries)" - ), - description=( - "The payload type describes the acceptable content that can be " - "communicated on the endpoint." - ), - # if property is element of this resource. - element_property=True, - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Interval the endpoint is expected to be operational", - description="The interval during which the endpoint is expected to be operational.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | suspended | error | off | entered-in-error | test", - description="active | suspended | error | off | test.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "suspended", "error", "off", "entered-in-error", "test"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Endpoint`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "connectionType", - "name", - "managingOrganization", - "contact", - "period", - "payloadType", - "payloadMimeType", - "address", - "header", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1018( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("address", "address__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/enrollmentrequest.py b/fhir/resources/enrollmentrequest.py deleted file mode 100644 index 8a668556..00000000 --- a/fhir/resources/enrollmentrequest.py +++ /dev/null @@ -1,133 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EnrollmentRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import domainresource, fhirtypes - - -class EnrollmentRequest(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Enroll in coverage. - This resource provides the insurance enrollment details to the insurer - regarding a specified coverage. - """ - - resource_type = Field("EnrollmentRequest", const=True) - - candidate: fhirtypes.ReferenceType = Field( - None, - alias="candidate", - title="The subject to be enrolled", - description="Patient Resource.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - coverage: fhirtypes.ReferenceType = Field( - None, - alias="coverage", - title="Insurance information", - description="Reference to the program or plan identification, underwriter or payor.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Coverage"], - ) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="Creation date", - description="The date when this resource was created.", - # if property is element of this resource. - element_property=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier", - description="The Response business identifier.", - # if property is element of this resource. - element_property=True, - ) - - insurer: fhirtypes.ReferenceType = Field( - None, - alias="insurer", - title="Target", - description="The Insurer who is target of the request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - provider: fhirtypes.ReferenceType = Field( - None, - alias="provider", - title="Responsible practitioner", - description=( - "The practitioner who is responsible for the services rendered to the " - "patient." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | cancelled | draft | entered-in-error", - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "cancelled", "draft", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EnrollmentRequest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "created", - "insurer", - "provider", - "candidate", - "coverage", - ] diff --git a/fhir/resources/enrollmentresponse.py b/fhir/resources/enrollmentresponse.py deleted file mode 100644 index 8150950c..00000000 --- a/fhir/resources/enrollmentresponse.py +++ /dev/null @@ -1,153 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EnrollmentResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import domainresource, fhirtypes - - -class EnrollmentResponse(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - EnrollmentResponse resource. - This resource provides enrollment and plan details from the processing of - an EnrollmentRequest resource. - """ - - resource_type = Field("EnrollmentResponse", const=True) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="Creation date", - description=( - "The date when the enclosed suite of services were performed or " - "completed." - ), - # if property is element of this resource. - element_property=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - disposition: fhirtypes.String = Field( - None, - alias="disposition", - title="Disposition Message", - description="A description of the status of the adjudication.", - # if property is element of this resource. - element_property=True, - ) - disposition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_disposition", title="Extension field for ``disposition``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier", - description="The Response business identifier.", - # if property is element of this resource. - element_property=True, - ) - - organization: fhirtypes.ReferenceType = Field( - None, - alias="organization", - title="Insurer", - description="The Insurer who produced this adjudicated response.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - outcome: fhirtypes.Code = Field( - None, - alias="outcome", - title="queued | complete | error | partial", - description="Processing status: error, complete.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["queued", "complete", "error", "partial"], - ) - outcome__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_outcome", title="Extension field for ``outcome``." - ) - - request: fhirtypes.ReferenceType = Field( - None, - alias="request", - title="Claim reference", - description="Original request resource reference.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EnrollmentRequest"], - ) - - requestProvider: fhirtypes.ReferenceType = Field( - None, - alias="requestProvider", - title="Responsible practitioner", - description=( - "The practitioner who is responsible for the services rendered to the " - "patient." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | cancelled | draft | entered-in-error", - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "cancelled", "draft", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EnrollmentResponse`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "request", - "outcome", - "disposition", - "created", - "organization", - "requestProvider", - ] diff --git a/fhir/resources/episodeofcare.py b/fhir/resources/episodeofcare.py deleted file mode 100644 index 9eedeed6..00000000 --- a/fhir/resources/episodeofcare.py +++ /dev/null @@ -1,462 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EpisodeOfCare -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class EpisodeOfCare(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An association of a Patient with an Organization and Healthcare - Provider(s) for a period of time that the Organization assumes some level - of responsibility. - An association between a patient and an organization / healthcare - provider(s) during which time encounters may occur. The managing - organization assumes a level of responsibility for the patient during this - time. - """ - - resource_type = Field("EpisodeOfCare", const=True) - - account: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="account", - title=( - "The set of accounts that may be used for billing for this " "EpisodeOfCare" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Account"], - ) - - careManager: fhirtypes.ReferenceType = Field( - None, - alias="careManager", - title="Care manager/care coordinator for the patient", - description=( - "The practitioner that is the care manager/care coordinator for this " - "patient." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - diagnosis: typing.List[fhirtypes.EpisodeOfCareDiagnosisType] = Field( - None, - alias="diagnosis", - title="The list of diagnosis relevant to this episode of care", - description=None, - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier(s) relevant for this EpisodeOfCare", - description=( - "The EpisodeOfCare may be known by different identifiers for different " - "contexts of use, such as when an external agency is tracking the " - "Episode for funding purposes." - ), - # if property is element of this resource. - element_property=True, - ) - - managingOrganization: fhirtypes.ReferenceType = Field( - None, - alias="managingOrganization", - title="Organization that assumes care", - description=( - "The organization that has assumed the specific responsibilities for " - "the specified duration." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="The patient who is the focus of this episode of care", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Interval during responsibility is assumed", - description=( - "The interval during which the managing organization assumes the " - "defined responsibility." - ), - # if property is element of this resource. - element_property=True, - ) - - referralRequest: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="referralRequest", - title="Originating Referral Request(s)", - description=( - "Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming" - " referrals." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ServiceRequest"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "planned | waitlist | active | onhold | finished | cancelled | entered-" - "in-error" - ), - description="planned | waitlist | active | onhold | finished | cancelled.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "planned", - "waitlist", - "active", - "onhold", - "finished", - "cancelled", - "entered-in-error", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusHistory: typing.List[fhirtypes.EpisodeOfCareStatusHistoryType] = Field( - None, - alias="statusHistory", - title=( - "Past list of status codes (the current status may be included to cover" - " the start date of the status)" - ), - description=( - "The history of statuses that the EpisodeOfCare has been through " - "(without requiring processing the history of the resource)." - ), - # if property is element of this resource. - element_property=True, - ) - - team: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="team", - title="Other practitioners facilitating this episode of care", - description=( - "The list of practitioners that may be facilitating this episode of " - "care for specific purposes." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CareTeam"], - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Type/class - e.g. specialist referral, disease management", - description=( - "A classification of the type of episode of care; e.g. specialist " - "referral, disease management, type of funded care." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EpisodeOfCare`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "statusHistory", - "type", - "diagnosis", - "patient", - "managingOrganization", - "period", - "referralRequest", - "careManager", - "team", - "account", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1443( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class EpisodeOfCareDiagnosis(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The list of diagnosis relevant to this episode of care. - """ - - resource_type = Field("EpisodeOfCareDiagnosis", const=True) - - condition: fhirtypes.ReferenceType = Field( - ..., - alias="condition", - title="Conditions/problems/diagnoses this episode of care is for", - description=( - "A list of conditions/problems/diagnoses that this episode of care is " - "intended to be providing care for." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition"], - ) - - rank: fhirtypes.PositiveInt = Field( - None, - alias="rank", - title="Ranking of the diagnosis (for each role type)", - description=None, - # if property is element of this resource. - element_property=True, - ) - rank__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_rank", title="Extension field for ``rank``." - ) - - role: fhirtypes.CodeableConceptType = Field( - None, - alias="role", - title=( - "Role that this diagnosis has within the episode of care (e.g. " - "admission, billing, discharge \u2026)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EpisodeOfCareDiagnosis`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "condition", "role", "rank"] - - -class EpisodeOfCareStatusHistory(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Past list of status codes (the current status may be included to cover the - start date of the status). - The history of statuses that the EpisodeOfCare has been through (without - requiring processing the history of the resource). - """ - - resource_type = Field("EpisodeOfCareStatusHistory", const=True) - - period: fhirtypes.PeriodType = Field( - ..., - alias="period", - title="Duration the EpisodeOfCare was in the specified status", - description="The period during this EpisodeOfCare that the specific status applied.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "planned | waitlist | active | onhold | finished | cancelled | entered-" - "in-error" - ), - description="planned | waitlist | active | onhold | finished | cancelled.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "planned", - "waitlist", - "active", - "onhold", - "finished", - "cancelled", - "entered-in-error", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EpisodeOfCareStatusHistory`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "status", "period"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2861( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/eventdefinition.py b/fhir/resources/eventdefinition.py deleted file mode 100644 index cca0daba..00000000 --- a/fhir/resources/eventdefinition.py +++ /dev/null @@ -1,599 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EventDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class EventDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A description of when an event can occur. - The EventDefinition resource provides a reusable description of when a - particular event can occur. - """ - - resource_type = Field("EventDefinition", const=True) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the event definition was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - author: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="author", - title="Who authored the content", - description=( - "An individiual or organization primarily involved in the creation and " - "maintenance of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the event definition and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the event definition." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the event definition was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the event definition changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the event definition", - description=( - "A free text natural language description of the event definition from " - "a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - editor: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="editor", - title="Who edited the content", - description=( - "An individual or organization primarily responsible for internal " - "coherence of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the event definition is expected to be used", - description=( - "The period during which the event definition content was or is planned" - " to be in active use." - ), - # if property is element of this resource. - element_property=True, - ) - - endorser: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="endorser", - title="Who endorsed the content", - description=( - "An individual or organization responsible for officially endorsing the" - " content for use in some setting." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this event definition is authored for" - " testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the event definition", - description=( - "A formal identifier that is used to identify this event definition " - "when it is represented in other formats, or referenced in a " - "specification, model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for event definition (if applicable)", - description=( - "A legal or geographic region in which the event definition is intended" - " to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the event definition was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this event definition (computer friendly)", - description=( - "A natural language name identifying the event definition. This name " - "should be usable as an identifier for the module by machine processing" - " applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the event " - "definition." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this event definition is defined", - description=( - "Explanation of why this event definition is needed and why it has been" - " designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="Additional documentation, citations, etc.", - description=( - "Related resources such as additional documentation, justification, or " - "bibliographic references." - ), - # if property is element of this resource. - element_property=True, - ) - - reviewer: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="reviewer", - title="Who reviewed the content", - description=( - "An individual or organization primarily responsible for review of some" - " aspect of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this event definition. Enables tracking the life-cycle " - "of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subjectCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="subjectCodeableConcept", - title="Type of individual the event definition is focused on", - description=( - "A code or group definition that describes the intended subject of the " - "event definition." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - ) - - subjectReference: fhirtypes.ReferenceType = Field( - None, - alias="subjectReference", - title="Type of individual the event definition is focused on", - description=( - "A code or group definition that describes the intended subject of the " - "event definition." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Group"], - ) - - subtitle: fhirtypes.String = Field( - None, - alias="subtitle", - title="Subordinate title of the event definition", - description=( - "An explanatory or alternate title for the event definition giving " - "additional information about its content." - ), - # if property is element of this resource. - element_property=True, - ) - subtitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subtitle", title="Extension field for ``subtitle``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this event definition (human friendly)", - description="A short, descriptive, user-friendly title for the event definition.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="topic", - title="E.g. Education, Treatment, Assessment, etc.", - description=( - "Descriptive topics related to the module. Topics provide a high-level " - "categorization of the module that can be useful for filtering and " - "searching." - ), - # if property is element of this resource. - element_property=True, - ) - - trigger: typing.List[fhirtypes.TriggerDefinitionType] = Field( - ..., - alias="trigger", - title="\"when\" the event occurs (multiple = 'or')", - description=( - "The trigger element defines when the event occurs. If more than one " - "trigger condition is specified, the event fires whenever any one of " - "the trigger conditions is met." - ), - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this event definition, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this event definition when it" - " is referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this event definition is (or will be) published. This URL " - "can be the target of a canonical reference. It SHALL remain the same " - "when the event definition is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - usage: fhirtypes.String = Field( - None, - alias="usage", - title="Describes the clinical usage of the event definition", - description=( - "A detailed description of how the event definition is used from a " - "clinical perspective." - ), - # if property is element of this resource. - element_property=True, - ) - usage__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_usage", title="Extension field for ``usage``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate event definition instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the event definition", - description=( - "The identifier that is used to identify this version of the event " - "definition when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the event definition " - "author and is not expected to be globally unique. For example, it " - "might be a timestamp (e.g. yyyymmdd) if a managed version is not " - "available. There is also no expectation that versions can be placed in" - " a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EventDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "subtitle", - "status", - "experimental", - "subjectCodeableConcept", - "subjectReference", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "usage", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "topic", - "author", - "editor", - "reviewer", - "endorser", - "relatedArtifact", - "trigger", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1726( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1726( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"subject": ["subjectCodeableConcept", "subjectReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/evidence.py b/fhir/resources/evidence.py deleted file mode 100644 index 239d0edc..00000000 --- a/fhir/resources/evidence.py +++ /dev/null @@ -1,545 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Evidence -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class Evidence(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A research context or question. - The Evidence resource describes the conditional state (population and any - exposures being compared within the population) and outcome (if specified) - that the knowledge (evidence, assertion, recommendation) is about. - """ - - resource_type = Field("Evidence", const=True) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the evidence was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - author: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="author", - title="Who authored the content", - description=( - "An individiual or organization primarily involved in the creation and " - "maintenance of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the evidence and/or its contents. " - "Copyright statements are generally legal restrictions on the use and " - "publishing of the evidence." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the evidence was published. The " - "date must change when the business version changes and it must change " - "if the status code changes. In addition, it should change when the " - "substantive content of the evidence changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the evidence", - description=( - "A free text natural language description of the evidence from a " - "consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - editor: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="editor", - title="Who edited the content", - description=( - "An individual or organization primarily responsible for internal " - "coherence of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the evidence is expected to be used", - description=( - "The period during which the evidence content was or is planned to be " - "in active use." - ), - # if property is element of this resource. - element_property=True, - ) - - endorser: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="endorser", - title="Who endorsed the content", - description=( - "An individual or organization responsible for officially endorsing the" - " content for use in some setting." - ), - # if property is element of this resource. - element_property=True, - ) - - exposureBackground: fhirtypes.ReferenceType = Field( - ..., - alias="exposureBackground", - title="What population?", - description=( - "A reference to a EvidenceVariable resource that defines the population" - " for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EvidenceVariable"], - ) - - exposureVariant: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="exposureVariant", - title="What exposure?", - description=( - "A reference to a EvidenceVariable resource that defines the exposure " - "for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EvidenceVariable"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the evidence", - description=( - "A formal identifier that is used to identify this evidence when it is " - "represented in other formats, or referenced in a specification, model," - " design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for evidence (if applicable)", - description=( - "A legal or geographic region in which the evidence is intended to be " - "used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the evidence was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this evidence (computer friendly)", - description=( - "A natural language name identifying the evidence. This name should be " - "usable as an identifier for the module by machine processing " - "applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Used for footnotes or explanatory notes", - description=( - "A human-readable string to clarify or explain concepts about the " - "resource." - ), - # if property is element of this resource. - element_property=True, - ) - - outcome: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="outcome", - title="What outcome?", - description=( - "A reference to a EvidenceVariable resomece that defines the outcome " - "for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EvidenceVariable"], - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the " "evidence." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="Additional documentation, citations, etc.", - description=( - "Related artifacts such as additional documentation, justification, or " - "bibliographic references." - ), - # if property is element of this resource. - element_property=True, - ) - - reviewer: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="reviewer", - title="Who reviewed the content", - description=( - "An individual or organization primarily responsible for review of some" - " aspect of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - shortTitle: fhirtypes.String = Field( - None, - alias="shortTitle", - title="Title for use in informal contexts", - description=( - "The short title provides an alternate title for use in informal " - "descriptive contexts where the full, formal title is not necessary." - ), - # if property is element of this resource. - element_property=True, - ) - shortTitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_shortTitle", title="Extension field for ``shortTitle``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this evidence. Enables tracking the life-cycle of the " - "content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subtitle: fhirtypes.String = Field( - None, - alias="subtitle", - title="Subordinate title of the Evidence", - description=( - "An explanatory or alternate title for the Evidence giving additional " - "information about its content." - ), - # if property is element of this resource. - element_property=True, - ) - subtitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subtitle", title="Extension field for ``subtitle``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this evidence (human friendly)", - description="A short, descriptive, user-friendly title for the evidence.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="topic", - title=( - "The category of the Evidence, such as Education, Treatment, " - "Assessment, etc." - ), - description=( - "Descriptive topics related to the content of the Evidence. Topics " - "provide a high-level categorization grouping types of Evidences that " - "can be useful for filtering and searching." - ), - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this evidence, represented as a URI (globally" - " unique)" - ), - description=( - "An absolute URI that is used to identify this evidence when it is " - "referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this evidence is (or will be) published. This URL can be " - "the target of a canonical reference. It SHALL remain the same when the" - " evidence is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate evidence instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the evidence", - description=( - "The identifier that is used to identify this version of the evidence " - "when it is referenced in a specification, model, design or instance. " - "This is an arbitrary value managed by the evidence author and is not " - "expected to be globally unique. For example, it might be a timestamp " - "(e.g. yyyymmdd) if a managed version is not available. There is also " - "no expectation that versions can be placed in a lexicographical " - "sequence. To provide a version consistent with the Decision Support " - "Service specification, use the format Major.Minor.Revision (e.g. " - "1.0.0). For more information on versioning knowledge assets, refer to " - "the Decision Support Service specification. Note that a version is " - "required for non-experimental active artifacts." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Evidence`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "shortTitle", - "subtitle", - "status", - "date", - "publisher", - "contact", - "description", - "note", - "useContext", - "jurisdiction", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "topic", - "author", - "editor", - "reviewer", - "endorser", - "relatedArtifact", - "exposureBackground", - "exposureVariant", - "outcome", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_973( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/evidencevariable.py b/fhir/resources/evidencevariable.py deleted file mode 100644 index 062b5cd6..00000000 --- a/fhir/resources/evidencevariable.py +++ /dev/null @@ -1,868 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EvidenceVariable -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class EvidenceVariable(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A population, intervention, or exposure definition. - The EvidenceVariable resource describes a "PICO" element that knowledge - (evidence, assertion, recommendation) is about. - """ - - resource_type = Field("EvidenceVariable", const=True) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the evidence variable was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - author: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="author", - title="Who authored the content", - description=( - "An individiual or organization primarily involved in the creation and " - "maintenance of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - characteristic: typing.List[fhirtypes.EvidenceVariableCharacteristicType] = Field( - ..., - alias="characteristic", - title="What defines the members of the evidence element", - description=( - "A characteristic that defines the members of the evidence element. " - 'Multiple characteristics are applied with "and" semantics.' - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the evidence variable and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the evidence variable." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the evidence variable was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the evidence variable changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the evidence variable", - description=( - "A free text natural language description of the evidence variable from" - " a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - editor: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="editor", - title="Who edited the content", - description=( - "An individual or organization primarily responsible for internal " - "coherence of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the evidence variable is expected to be used", - description=( - "The period during which the evidence variable content was or is " - "planned to be in active use." - ), - # if property is element of this resource. - element_property=True, - ) - - endorser: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="endorser", - title="Who endorsed the content", - description=( - "An individual or organization responsible for officially endorsing the" - " content for use in some setting." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the evidence variable", - description=( - "A formal identifier that is used to identify this evidence variable " - "when it is represented in other formats, or referenced in a " - "specification, model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for evidence variable (if applicable)", - description=( - "A legal or geographic region in which the evidence variable is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the evidence variable was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this evidence variable (computer friendly)", - description=( - "A natural language name identifying the evidence variable. This name " - "should be usable as an identifier for the module by machine processing" - " applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Used for footnotes or explanatory notes", - description=( - "A human-readable string to clarify or explain concepts about the " - "resource." - ), - # if property is element of this resource. - element_property=True, - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the evidence" - " variable." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="Additional documentation, citations, etc.", - description=( - "Related artifacts such as additional documentation, justification, or " - "bibliographic references." - ), - # if property is element of this resource. - element_property=True, - ) - - reviewer: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="reviewer", - title="Who reviewed the content", - description=( - "An individual or organization primarily responsible for review of some" - " aspect of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - shortTitle: fhirtypes.String = Field( - None, - alias="shortTitle", - title="Title for use in informal contexts", - description=( - "The short title provides an alternate title for use in informal " - "descriptive contexts where the full, formal title is not necessary." - ), - # if property is element of this resource. - element_property=True, - ) - shortTitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_shortTitle", title="Extension field for ``shortTitle``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this evidence variable. Enables tracking the life-cycle " - "of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subtitle: fhirtypes.String = Field( - None, - alias="subtitle", - title="Subordinate title of the EvidenceVariable", - description=( - "An explanatory or alternate title for the EvidenceVariable giving " - "additional information about its content." - ), - # if property is element of this resource. - element_property=True, - ) - subtitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subtitle", title="Extension field for ``subtitle``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this evidence variable (human friendly)", - description="A short, descriptive, user-friendly title for the evidence variable.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="topic", - title=( - "The category of the EvidenceVariable, such as Education, Treatment, " - "Assessment, etc." - ), - description=( - "Descriptive topics related to the content of the EvidenceVariable. " - "Topics provide a high-level categorization grouping types of " - "EvidenceVariables that can be useful for filtering and searching." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="dichotomous | continuous | descriptive", - description=( - "The type of evidence element, a population, an exposure, or an " "outcome." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["dichotomous", "continuous", "descriptive"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this evidence variable, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this evidence variable when " - "it is referenced in a specification, model, design or an instance; " - "also called its canonical identifier. This SHOULD be globally unique " - "and SHOULD be a literal address at which at which an authoritative " - "instance of this evidence variable is (or will be) published. This URL" - " can be the target of a canonical reference. It SHALL remain the same " - "when the evidence variable is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate evidence variable instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the evidence variable", - description=( - "The identifier that is used to identify this version of the evidence " - "variable when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the evidence variable " - "author and is not expected to be globally unique. For example, it " - "might be a timestamp (e.g. yyyymmdd) if a managed version is not " - "available. There is also no expectation that versions can be placed in" - " a lexicographical sequence. To provide a version consistent with the " - "Decision Support Service specification, use the format " - "Major.Minor.Revision (e.g. 1.0.0). For more information on versioning " - "knowledge assets, refer to the Decision Support Service specification." - " Note that a version is required for non-experimental active " - "artifacts." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EvidenceVariable`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "shortTitle", - "subtitle", - "status", - "date", - "publisher", - "contact", - "description", - "note", - "useContext", - "jurisdiction", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "topic", - "author", - "editor", - "reviewer", - "endorser", - "relatedArtifact", - "type", - "characteristic", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1779( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class EvidenceVariableCharacteristic(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What defines the members of the evidence element. - A characteristic that defines the members of the evidence element. Multiple - characteristics are applied with "and" semantics. - """ - - resource_type = Field("EvidenceVariableCharacteristic", const=True) - - definitionCanonical: fhirtypes.Canonical = Field( - None, - alias="definitionCanonical", - title="What code or expression defines members?", - description=( - "Define members of the evidence element using Codes (such as condition," - " medication, or observation), Expressions ( using an expression " - "language such as FHIRPath or CQL) or DataRequirements (such as " - "Diabetes diagnosis onset in the last year)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ActivityDefinition"], - ) - definitionCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_definitionCanonical", - title="Extension field for ``definitionCanonical``.", - ) - - definitionCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="definitionCodeableConcept", - title="What code or expression defines members?", - description=( - "Define members of the evidence element using Codes (such as condition," - " medication, or observation), Expressions ( using an expression " - "language such as FHIRPath or CQL) or DataRequirements (such as " - "Diabetes diagnosis onset in the last year)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=True, - ) - - definitionDataRequirement: fhirtypes.DataRequirementType = Field( - None, - alias="definitionDataRequirement", - title="What code or expression defines members?", - description=( - "Define members of the evidence element using Codes (such as condition," - " medication, or observation), Expressions ( using an expression " - "language such as FHIRPath or CQL) or DataRequirements (such as " - "Diabetes diagnosis onset in the last year)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=True, - ) - - definitionExpression: fhirtypes.ExpressionType = Field( - None, - alias="definitionExpression", - title="What code or expression defines members?", - description=( - "Define members of the evidence element using Codes (such as condition," - " medication, or observation), Expressions ( using an expression " - "language such as FHIRPath or CQL) or DataRequirements (such as " - "Diabetes diagnosis onset in the last year)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=True, - ) - - definitionReference: fhirtypes.ReferenceType = Field( - None, - alias="definitionReference", - title="What code or expression defines members?", - description=( - "Define members of the evidence element using Codes (such as condition," - " medication, or observation), Expressions ( using an expression " - "language such as FHIRPath or CQL) or DataRequirements (such as " - "Diabetes diagnosis onset in the last year)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Group"], - ) - - definitionTriggerDefinition: fhirtypes.TriggerDefinitionType = Field( - None, - alias="definitionTriggerDefinition", - title="What code or expression defines members?", - description=( - "Define members of the evidence element using Codes (such as condition," - " medication, or observation), Expressions ( using an expression " - "language such as FHIRPath or CQL) or DataRequirements (such as " - "Diabetes diagnosis onset in the last year)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Natural language description of the characteristic", - description=( - "A short, natural language description of the characteristic that could" - " be used to communicate the criteria to an end-user." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - exclude: bool = Field( - None, - alias="exclude", - title="Whether the characteristic includes or excludes members", - description=( - "When true, members with this characteristic are excluded from the " - "element." - ), - # if property is element of this resource. - element_property=True, - ) - exclude__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_exclude", title="Extension field for ``exclude``." - ) - - groupMeasure: fhirtypes.Code = Field( - None, - alias="groupMeasure", - title=( - "mean | median | mean-of-mean | mean-of-median | median-of-mean | " - "median-of-median" - ), - description=( - "Indicates how elements are aggregated within the study effective " - "period." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "mean", - "median", - "mean-of-mean", - "mean-of-median", - "median-of-mean", - "median-of-median", - ], - ) - groupMeasure__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_groupMeasure", title="Extension field for ``groupMeasure``." - ) - - participantEffectiveDateTime: fhirtypes.DateTime = Field( - None, - alias="participantEffectiveDateTime", - title="What time period do participants cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e participantEffective[x] - one_of_many="participantEffective", - one_of_many_required=False, - ) - participantEffectiveDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_participantEffectiveDateTime", - title="Extension field for ``participantEffectiveDateTime``.", - ) - - participantEffectiveDuration: fhirtypes.DurationType = Field( - None, - alias="participantEffectiveDuration", - title="What time period do participants cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e participantEffective[x] - one_of_many="participantEffective", - one_of_many_required=False, - ) - - participantEffectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="participantEffectivePeriod", - title="What time period do participants cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e participantEffective[x] - one_of_many="participantEffective", - one_of_many_required=False, - ) - - participantEffectiveTiming: fhirtypes.TimingType = Field( - None, - alias="participantEffectiveTiming", - title="What time period do participants cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e participantEffective[x] - one_of_many="participantEffective", - one_of_many_required=False, - ) - - timeFromStart: fhirtypes.DurationType = Field( - None, - alias="timeFromStart", - title="Observation time from study start", - description="Indicates duration from the participant's study entry.", - # if property is element of this resource. - element_property=True, - ) - - usageContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="usageContext", - title="What code/value pairs define members?", - description=( - "Use UsageContext to define the members of the population, such as Age " - "Ranges, Genders, Settings." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``EvidenceVariableCharacteristic`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "definitionReference", - "definitionCanonical", - "definitionCodeableConcept", - "definitionExpression", - "definitionDataRequirement", - "definitionTriggerDefinition", - "usageContext", - "exclude", - "participantEffectiveDateTime", - "participantEffectivePeriod", - "participantEffectiveDuration", - "participantEffectiveTiming", - "timeFromStart", - "groupMeasure", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3226( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "definition": [ - "definitionCanonical", - "definitionCodeableConcept", - "definitionDataRequirement", - "definitionExpression", - "definitionReference", - "definitionTriggerDefinition", - ], - "participantEffective": [ - "participantEffectiveDateTime", - "participantEffectiveDuration", - "participantEffectivePeriod", - "participantEffectiveTiming", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/examplescenario.py b/fhir/resources/examplescenario.py deleted file mode 100644 index fdbebc3a..00000000 --- a/fhir/resources/examplescenario.py +++ /dev/null @@ -1,1429 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ExampleScenario -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ExampleScenario(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Example of workflow instance. - """ - - resource_type = Field("ExampleScenario", const=True) - - actor: typing.List[fhirtypes.ExampleScenarioActorType] = Field( - None, - alias="actor", - title="Actor participating in the resource", - description=None, - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the example scenario and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the example scenario." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the example scenario was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the example scenario changes. " - "(e.g. the 'content logical definition')." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this example scenario is authored for" - " testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the example scenario", - description=( - "A formal identifier that is used to identify this example scenario " - "when it is represented in other formats, or referenced in a " - "specification, model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - instance: typing.List[fhirtypes.ExampleScenarioInstanceType] = Field( - None, - alias="instance", - title="Each resource and each version that is present in the workflow", - description=None, - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for example scenario (if applicable)", - description=( - "A legal or geographic region in which the example scenario is intended" - " to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this example scenario (computer friendly)", - description=( - "A natural language name identifying the example scenario. This name " - "should be usable as an identifier for the module by machine processing" - " applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - process: typing.List[fhirtypes.ExampleScenarioProcessType] = Field( - None, - alias="process", - title="Each major process - a group of operations", - description=None, - # if property is element of this resource. - element_property=True, - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the example " - "scenario." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="The purpose of the example, e.g. to illustrate a scenario", - description=( - "What the example scenario resource is created for. This should not be " - "used to show the business purpose of the scenario itself, but the " - "purpose of documenting a scenario." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this example scenario. Enables tracking the life-cycle " - "of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this example scenario, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this example scenario when it" - " is referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this example scenario is (or will be) published. This URL " - "can be the target of a canonical reference. It SHALL remain the same " - "when the example scenario is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate example scenario instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the example scenario", - description=( - "The identifier that is used to identify this version of the example " - "scenario when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the example scenario " - "author and is not expected to be globally unique. For example, it " - "might be a timestamp (e.g. yyyymmdd) if a managed version is not " - "available. There is also no expectation that versions can be placed in" - " a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - workflow: typing.List[fhirtypes.Canonical] = Field( - None, - alias="workflow", - title="Another nested workflow", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ExampleScenario"], - ) - workflow__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_workflow", title="Extension field for ``workflow``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExampleScenario`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "status", - "experimental", - "date", - "publisher", - "contact", - "useContext", - "jurisdiction", - "copyright", - "purpose", - "actor", - "instance", - "process", - "workflow", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1716( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExampleScenarioActor(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Actor participating in the resource. - """ - - resource_type = Field("ExampleScenarioActor", const=True) - - actorId: fhirtypes.String = Field( - None, - alias="actorId", - title="ID or acronym of the actor", - description="ID or acronym of actor.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - actorId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_actorId", title="Extension field for ``actorId``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="The description of the actor", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="The name of the actor as shown in the page", - description=None, - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="person | entity", - description="The type of actor - person or system.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["person", "entity"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExampleScenarioActor`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "actorId", - "type", - "name", - "description", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2224( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("actorId", "actorId__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExampleScenarioInstance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Each resource and each version that is present in the workflow. - """ - - resource_type = Field("ExampleScenarioInstance", const=True) - - containedInstance: typing.List[ - fhirtypes.ExampleScenarioInstanceContainedInstanceType - ] = Field( - None, - alias="containedInstance", - title="Resources contained in the instance", - description=( - "Resources contained in the instance (e.g. the observations contained " - "in a bundle)." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Human-friendly description of the resource instance", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="A short name for the resource instance", - description=None, - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - resourceId: fhirtypes.String = Field( - None, - alias="resourceId", - title="The id of the resource for referencing", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - resourceId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_resourceId", title="Extension field for ``resourceId``." - ) - - resourceType: fhirtypes.Code = Field( - None, - alias="resourceType", - title="The type of the resource", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - resourceType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_resourceType", title="Extension field for ``resourceType``." - ) - - version: typing.List[fhirtypes.ExampleScenarioInstanceVersionType] = Field( - None, - alias="version", - title="A specific version of the resource", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExampleScenarioInstance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "resourceId", - "resourceType", - "name", - "description", - "version", - "containedInstance", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2527( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("resourceId", "resourceId__ext"), - ("resourceType", "resourceType__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExampleScenarioInstanceContainedInstance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Resources contained in the instance. - Resources contained in the instance (e.g. the observations contained in a - bundle). - """ - - resource_type = Field("ExampleScenarioInstanceContainedInstance", const=True) - - resourceId: fhirtypes.String = Field( - None, - alias="resourceId", - title="Each resource contained in the instance", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - resourceId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_resourceId", title="Extension field for ``resourceId``." - ) - - versionId: fhirtypes.String = Field( - None, - alias="versionId", - title="A specific version of a resource contained in the instance", - description=None, - # if property is element of this resource. - element_property=True, - ) - versionId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_versionId", title="Extension field for ``versionId``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExampleScenarioInstanceContainedInstance`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "resourceId", "versionId"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4265( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("resourceId", "resourceId__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExampleScenarioInstanceVersion(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A specific version of the resource. - """ - - resource_type = Field("ExampleScenarioInstanceVersion", const=True) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="The description of the resource version", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - versionId: fhirtypes.String = Field( - None, - alias="versionId", - title="The identifier of a specific version of a resource", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - versionId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_versionId", title="Extension field for ``versionId``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExampleScenarioInstanceVersion`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "versionId", "description"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3278( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("description", "description__ext"), - ("versionId", "versionId__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExampleScenarioProcess(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Each major process - a group of operations. - """ - - resource_type = Field("ExampleScenarioProcess", const=True) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="A longer description of the group of operations", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - postConditions: fhirtypes.Markdown = Field( - None, - alias="postConditions", - title="Description of final status after the process ends", - description=None, - # if property is element of this resource. - element_property=True, - ) - postConditions__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_postConditions", title="Extension field for ``postConditions``." - ) - - preConditions: fhirtypes.Markdown = Field( - None, - alias="preConditions", - title="Description of initial status before the process starts", - description=None, - # if property is element of this resource. - element_property=True, - ) - preConditions__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_preConditions", title="Extension field for ``preConditions``." - ) - - step: typing.List[fhirtypes.ExampleScenarioProcessStepType] = Field( - None, - alias="step", - title="Each step of the process", - description=None, - # if property is element of this resource. - element_property=True, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="The diagram title of the group of operations", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExampleScenarioProcess`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "title", - "description", - "preConditions", - "postConditions", - "step", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2455( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("title", "title__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExampleScenarioProcessStep(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Each step of the process. - """ - - resource_type = Field("ExampleScenarioProcessStep", const=True) - - alternative: typing.List[ - fhirtypes.ExampleScenarioProcessStepAlternativeType - ] = Field( - None, - alias="alternative", - title="Alternate non-typical step action", - description=( - "Indicates an alternative step that can be taken instead of the " - "operations on the base step in exceptional/atypical circumstances." - ), - # if property is element of this resource. - element_property=True, - ) - - operation: fhirtypes.ExampleScenarioProcessStepOperationType = Field( - None, - alias="operation", - title="Each interaction or action", - description=None, - # if property is element of this resource. - element_property=True, - ) - - pause: bool = Field( - None, - alias="pause", - title="If there is a pause in the flow", - description=None, - # if property is element of this resource. - element_property=True, - ) - pause__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_pause", title="Extension field for ``pause``." - ) - - process: typing.List[fhirtypes.ExampleScenarioProcessType] = Field( - None, - alias="process", - title="Nested process", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExampleScenarioProcessStep`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "process", - "pause", - "operation", - "alternative", - ] - - -class ExampleScenarioProcessStepAlternative(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Alternate non-typical step action. - Indicates an alternative step that can be taken instead of the operations - on the base step in exceptional/atypical circumstances. - """ - - resource_type = Field("ExampleScenarioProcessStepAlternative", const=True) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="A human-readable description of each option", - description=( - "A human-readable description of the alternative explaining when the " - "alternative should occur rather than the base step." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - step: typing.List[fhirtypes.ExampleScenarioProcessStepType] = Field( - None, - alias="step", - title="What happens in each alternative option", - description=None, - # if property is element of this resource. - element_property=True, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Label for alternative", - description=( - "The label to display for the alternative that gives a sense of the " - "circumstance in which the alternative should be invoked." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExampleScenarioProcessStepAlternative`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "title", "description", "step"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4004( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("title", "title__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExampleScenarioProcessStepOperation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Each interaction or action. - """ - - resource_type = Field("ExampleScenarioProcessStepOperation", const=True) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="A comment to be inserted in the diagram", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - initiator: fhirtypes.String = Field( - None, - alias="initiator", - title="Who starts the transaction", - description=None, - # if property is element of this resource. - element_property=True, - ) - initiator__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_initiator", title="Extension field for ``initiator``." - ) - - initiatorActive: bool = Field( - None, - alias="initiatorActive", - title="Whether the initiator is deactivated right after the transaction", - description=None, - # if property is element of this resource. - element_property=True, - ) - initiatorActive__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_initiatorActive", title="Extension field for ``initiatorActive``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="The human-friendly name of the interaction", - description=None, - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - number: fhirtypes.String = Field( - None, - alias="number", - title="The sequential number of the interaction", - description="The sequential number of the interaction, e.g. 1.2.5.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - number__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_number", title="Extension field for ``number``." - ) - - receiver: fhirtypes.String = Field( - None, - alias="receiver", - title="Who receives the transaction", - description=None, - # if property is element of this resource. - element_property=True, - ) - receiver__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_receiver", title="Extension field for ``receiver``." - ) - - receiverActive: bool = Field( - None, - alias="receiverActive", - title="Whether the receiver is deactivated right after the transaction", - description=None, - # if property is element of this resource. - element_property=True, - ) - receiverActive__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_receiverActive", title="Extension field for ``receiverActive``." - ) - - request: fhirtypes.ExampleScenarioInstanceContainedInstanceType = Field( - None, - alias="request", - title="Each resource instance used by the initiator", - description=None, - # if property is element of this resource. - element_property=True, - ) - - response: fhirtypes.ExampleScenarioInstanceContainedInstanceType = Field( - None, - alias="response", - title="Each resource instance used by the responder", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.String = Field( - None, - alias="type", - title="The type of operation - CRUD", - description=None, - # if property is element of this resource. - element_property=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExampleScenarioProcessStepOperation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "number", - "type", - "name", - "initiator", - "receiver", - "description", - "initiatorActive", - "receiverActive", - "request", - "response", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3807( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("number", "number__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/explanationofbenefit.py b/fhir/resources/explanationofbenefit.py deleted file mode 100644 index d2f932de..00000000 --- a/fhir/resources/explanationofbenefit.py +++ /dev/null @@ -1,4184 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ExplanationOfBenefit -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ExplanationOfBenefit(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Explanation of Benefit resource. - This resource provides: the claim details; adjudication details from the - processing of a Claim; and optionally account balance information, for - informing the subscriber of the benefits provided. - """ - - resource_type = Field("ExplanationOfBenefit", const=True) - - accident: fhirtypes.ExplanationOfBenefitAccidentType = Field( - None, - alias="accident", - title="Details of the event", - description=( - "Details of a accident which resulted in injuries which required the " - "products and services listed in the claim." - ), - # if property is element of this resource. - element_property=True, - ) - - addItem: typing.List[fhirtypes.ExplanationOfBenefitAddItemType] = Field( - None, - alias="addItem", - title="Insurer added line items", - description=( - "The first-tier service adjudications for payor added product or " - "service lines." - ), - # if property is element of this resource. - element_property=True, - ) - - adjudication: typing.List[ - fhirtypes.ExplanationOfBenefitItemAdjudicationType - ] = Field( - None, - alias="adjudication", - title="Header-level adjudication", - description=( - "The adjudication results which are presented at the header level " - "rather than at the line-item or add-item levels." - ), - # if property is element of this resource. - element_property=True, - ) - - benefitBalance: typing.List[ - fhirtypes.ExplanationOfBenefitBenefitBalanceType - ] = Field( - None, - alias="benefitBalance", - title="Balance by Benefit Category", - description=None, - # if property is element of this resource. - element_property=True, - ) - - benefitPeriod: fhirtypes.PeriodType = Field( - None, - alias="benefitPeriod", - title="When the benefits are applicable", - description="The term of the benefits documented in this response.", - # if property is element of this resource. - element_property=True, - ) - - billablePeriod: fhirtypes.PeriodType = Field( - None, - alias="billablePeriod", - title="Relevant time frame for the claim", - description="The period for which charges are being submitted.", - # if property is element of this resource. - element_property=True, - ) - - careTeam: typing.List[fhirtypes.ExplanationOfBenefitCareTeamType] = Field( - None, - alias="careTeam", - title="Care Team members", - description="The members of the team who provided the products and services.", - # if property is element of this resource. - element_property=True, - ) - - claim: fhirtypes.ReferenceType = Field( - None, - alias="claim", - title="Claim reference", - description=( - "The business identifier for the instance of the adjudication request: " - "claim predetermination or preauthorization." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Claim"], - ) - - claimResponse: fhirtypes.ReferenceType = Field( - None, - alias="claimResponse", - title="Claim response reference", - description=( - "The business identifier for the instance of the adjudication response:" - " claim, predetermination or preauthorization response." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ClaimResponse"], - ) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="Response creation date", - description="The date this resource was created.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - diagnosis: typing.List[fhirtypes.ExplanationOfBenefitDiagnosisType] = Field( - None, - alias="diagnosis", - title="Pertinent diagnosis information", - description="Information about diagnoses relevant to the claim items.", - # if property is element of this resource. - element_property=True, - ) - - disposition: fhirtypes.String = Field( - None, - alias="disposition", - title="Disposition Message", - description="A human readable description of the status of the adjudication.", - # if property is element of this resource. - element_property=True, - ) - disposition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_disposition", title="Extension field for ``disposition``." - ) - - enterer: fhirtypes.ReferenceType = Field( - None, - alias="enterer", - title="Author of the claim", - description=( - "Individual who created the claim, predetermination or " "preauthorization." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - facility: fhirtypes.ReferenceType = Field( - None, - alias="facility", - title="Servicing Facility", - description="Facility where the services were provided.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - form: fhirtypes.AttachmentType = Field( - None, - alias="form", - title="Printed reference or actual form", - description=( - "The actual form, by reference or inclusion, for printing the content " - "or an EOB." - ), - # if property is element of this resource. - element_property=True, - ) - - formCode: fhirtypes.CodeableConceptType = Field( - None, - alias="formCode", - title="Printed form identifier", - description="A code for the form to be used for printing the content.", - # if property is element of this resource. - element_property=True, - ) - - fundsReserve: fhirtypes.CodeableConceptType = Field( - None, - alias="fundsReserve", - title="Funds reserved status", - description=( - "A code, used only on a response to a preauthorization, to indicate " - "whether the benefits payable have been reserved and for whom." - ), - # if property is element of this resource. - element_property=True, - ) - - fundsReserveRequested: fhirtypes.CodeableConceptType = Field( - None, - alias="fundsReserveRequested", - title="For whom to reserve funds", - description=( - "A code to indicate whether and for whom funds are to be reserved for " - "future claims." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for the resource", - description="A unique identifier assigned to this explanation of benefit.", - # if property is element of this resource. - element_property=True, - ) - - insurance: typing.List[fhirtypes.ExplanationOfBenefitInsuranceType] = Field( - ..., - alias="insurance", - title="Patient insurance information", - description=( - "Financial instruments for reimbursement for the health care products " - "and services specified on the claim." - ), - # if property is element of this resource. - element_property=True, - ) - - insurer: fhirtypes.ReferenceType = Field( - ..., - alias="insurer", - title="Party responsible for reimbursement", - description=( - "The party responsible for authorization, adjudication and " - "reimbursement." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - item: typing.List[fhirtypes.ExplanationOfBenefitItemType] = Field( - None, - alias="item", - title="Product or service provided", - description=( - "A claim line. Either a simple (a product or service) or a 'group' of " - "details which can also be a simple items or groups of sub-details." - ), - # if property is element of this resource. - element_property=True, - ) - - originalPrescription: fhirtypes.ReferenceType = Field( - None, - alias="originalPrescription", - title="Original prescription if superceded by fulfiller", - description=( - "Original prescription which has been superseded by this prescription " - "to support the dispensing of pharmacy services, medications or " - "products." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicationRequest"], - ) - - outcome: fhirtypes.Code = Field( - None, - alias="outcome", - title="queued | complete | error | partial", - description=( - "The outcome of the claim, predetermination, or preauthorization " - "processing." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["queued", "complete", "error", "partial"], - ) - outcome__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_outcome", title="Extension field for ``outcome``." - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="The recipient of the products and services", - description=( - "The party to whom the professional services and/or products have been " - "supplied or are being considered and for whom actual for forecast " - "reimbursement is sought." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - payee: fhirtypes.ExplanationOfBenefitPayeeType = Field( - None, - alias="payee", - title="Recipient of benefits payable", - description=( - "The party to be reimbursed for cost of the products and services " - "according to the terms of the policy." - ), - # if property is element of this resource. - element_property=True, - ) - - payment: fhirtypes.ExplanationOfBenefitPaymentType = Field( - None, - alias="payment", - title="Payment Details", - description="Payment details for the adjudication of the claim.", - # if property is element of this resource. - element_property=True, - ) - - preAuthRef: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="preAuthRef", - title="Preauthorization reference", - description=( - "Reference from the Insurer which is used in later communications which" - " refers to this adjudication." - ), - # if property is element of this resource. - element_property=True, - ) - preAuthRef__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_preAuthRef", title="Extension field for ``preAuthRef``.") - - preAuthRefPeriod: typing.List[fhirtypes.PeriodType] = Field( - None, - alias="preAuthRefPeriod", - title="Preauthorization in-effect period", - description=( - "The timeframe during which the supplied preauthorization reference may" - " be quoted on claims to obtain the adjudication as provided." - ), - # if property is element of this resource. - element_property=True, - ) - - precedence: fhirtypes.PositiveInt = Field( - None, - alias="precedence", - title="Precedence (primary, secondary, etc.)", - description=( - "This indicates the relative order of a series of EOBs related to " - "different coverages for the same suite of services." - ), - # if property is element of this resource. - element_property=True, - ) - precedence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_precedence", title="Extension field for ``precedence``." - ) - - prescription: fhirtypes.ReferenceType = Field( - None, - alias="prescription", - title="Prescription authorizing services or products", - description=( - "Prescription to support the dispensing of pharmacy, device or vision " - "products." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicationRequest", "VisionPrescription"], - ) - - priority: fhirtypes.CodeableConceptType = Field( - None, - alias="priority", - title="Desired processing urgency", - description=( - "The provider-required urgency of processing the request. Typical " - "values include: stat, routine deferred." - ), - # if property is element of this resource. - element_property=True, - ) - - procedure: typing.List[fhirtypes.ExplanationOfBenefitProcedureType] = Field( - None, - alias="procedure", - title="Clinical procedures performed", - description=( - "Procedures performed on the patient relevant to the billing items with" - " the claim." - ), - # if property is element of this resource. - element_property=True, - ) - - processNote: typing.List[fhirtypes.ExplanationOfBenefitProcessNoteType] = Field( - None, - alias="processNote", - title="Note concerning adjudication", - description=( - "A note that describes or explains adjudication results in a human " - "readable form." - ), - # if property is element of this resource. - element_property=True, - ) - - provider: fhirtypes.ReferenceType = Field( - ..., - alias="provider", - title="Party responsible for the claim", - description=( - "The provider which is responsible for the claim, predetermination or " - "preauthorization." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - referral: fhirtypes.ReferenceType = Field( - None, - alias="referral", - title="Treatment Referral", - description="A reference to a referral resource.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ServiceRequest"], - ) - - related: typing.List[fhirtypes.ExplanationOfBenefitRelatedType] = Field( - None, - alias="related", - title="Prior or corollary claims", - description=( - "Other claims which are related to this claim such as prior submissions" - " or claims for related services or for the same event." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | cancelled | draft | entered-in-error", - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "cancelled", "draft", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subType: fhirtypes.CodeableConceptType = Field( - None, - alias="subType", - title="More granular claim type", - description=( - "A finer grained suite of claim type codes which may convey additional " - "information such as Inpatient vs Outpatient and/or a specialty " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - supportingInfo: typing.List[ - fhirtypes.ExplanationOfBenefitSupportingInfoType - ] = Field( - None, - alias="supportingInfo", - title="Supporting information", - description=( - "Additional information codes regarding exceptions, special " - "considerations, the condition, situation, prior or concurrent issues." - ), - # if property is element of this resource. - element_property=True, - ) - - total: typing.List[fhirtypes.ExplanationOfBenefitTotalType] = Field( - None, - alias="total", - title="Adjudication totals", - description="Categorized monetary totals for the adjudication.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Category or discipline", - description=( - "The category of claim, e.g. oral, pharmacy, vision, institutional, " - "professional." - ), - # if property is element of this resource. - element_property=True, - ) - - use: fhirtypes.Code = Field( - None, - alias="use", - title="claim | preauthorization | predetermination", - description=( - "A code to indicate whether the nature of the request is: to request " - "adjudication of products and services previously rendered; or " - "requesting authorization and adjudication for provision in the future;" - " or requesting the non-binding adjudication of the listed products and" - " services which could be provided in the future." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["claim", "preauthorization", "predetermination"], - ) - use__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_use", title="Extension field for ``use``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefit`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "type", - "subType", - "use", - "patient", - "billablePeriod", - "created", - "enterer", - "insurer", - "provider", - "priority", - "fundsReserveRequested", - "fundsReserve", - "related", - "prescription", - "originalPrescription", - "payee", - "referral", - "facility", - "claim", - "claimResponse", - "outcome", - "disposition", - "preAuthRef", - "preAuthRefPeriod", - "careTeam", - "supportingInfo", - "diagnosis", - "procedure", - "precedence", - "insurance", - "accident", - "item", - "addItem", - "adjudication", - "total", - "payment", - "formCode", - "form", - "processNote", - "benefitPeriod", - "benefitBalance", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2222( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("created", "created__ext"), - ("outcome", "outcome__ext"), - ("status", "status__ext"), - ("use", "use__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExplanationOfBenefitAccident(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Details of the event. - Details of a accident which resulted in injuries which required the - products and services listed in the claim. - """ - - resource_type = Field("ExplanationOfBenefitAccident", const=True) - - date: fhirtypes.Date = Field( - None, - alias="date", - title="When the incident occurred", - description=( - "Date of an accident event related to the products and services " - "contained in the claim." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - locationAddress: fhirtypes.AddressType = Field( - None, - alias="locationAddress", - title="Where the event occurred", - description="The physical location of the accident event.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - ) - - locationReference: fhirtypes.ReferenceType = Field( - None, - alias="locationReference", - title="Where the event occurred", - description="The physical location of the accident event.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="The nature of the accident", - description=( - "The type or context of the accident event for the purposes of " - "selection of potential insurance coverages and determination of " - "coordination between insurers." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitAccident`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "date", - "type", - "locationAddress", - "locationReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3017( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"location": ["locationAddress", "locationReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ExplanationOfBenefitAddItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Insurer added line items. - The first-tier service adjudications for payor added product or service - lines. - """ - - resource_type = Field("ExplanationOfBenefitAddItem", const=True) - - adjudication: typing.List[ - fhirtypes.ExplanationOfBenefitItemAdjudicationType - ] = Field( - None, - alias="adjudication", - title="Added items adjudication", - description="The adjudication results.", - # if property is element of this resource. - element_property=True, - ) - - bodySite: fhirtypes.CodeableConceptType = Field( - None, - alias="bodySite", - title="Anatomical location", - description="Physical service site on the patient (limb, tooth, etc.).", - # if property is element of this resource. - element_property=True, - ) - - detail: typing.List[fhirtypes.ExplanationOfBenefitAddItemDetailType] = Field( - None, - alias="detail", - title="Insurer added line items", - description="The second-tier service adjudications for payor added services.", - # if property is element of this resource. - element_property=True, - ) - - detailSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="detailSequence", - title="Detail sequence number", - description=( - "The sequence number of the details within the claim item which this " - "line is intended to replace." - ), - # if property is element of this resource. - element_property=True, - ) - detailSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_detailSequence", title="Extension field for ``detailSequence``." - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - itemSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="itemSequence", - title="Item sequence number", - description="Claim items which this service line is intended to replace.", - # if property is element of this resource. - element_property=True, - ) - itemSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_itemSequence", title="Extension field for ``itemSequence``." - ) - - locationAddress: fhirtypes.AddressType = Field( - None, - alias="locationAddress", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - ) - - locationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="locationCodeableConcept", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - ) - - locationReference: fhirtypes.ReferenceType = Field( - None, - alias="locationReference", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Service/Product billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - programCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="programCode", - title="Program the product or service is provided under", - description="Identifies the program under which this may be recovered.", - # if property is element of this resource. - element_property=True, - ) - - provider: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="provider", - title="Authorized providers", - description=( - "The providers who are authorized for the services rendered to the " - "patient." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - servicedDate: fhirtypes.Date = Field( - None, - alias="servicedDate", - title="Date or dates of service or product delivery", - description=( - "The date or dates when the service or product was supplied, performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - servicedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_servicedDate", title="Extension field for ``servicedDate``." - ) - - servicedPeriod: fhirtypes.PeriodType = Field( - None, - alias="servicedPeriod", - title="Date or dates of service or product delivery", - description=( - "The date or dates when the service or product was supplied, performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - - subDetailSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="subDetailSequence", - title="Subdetail sequence number", - description=( - "The sequence number of the sub-details woithin the details within the " - "claim item which this line is intended to replace." - ), - # if property is element of this resource. - element_property=True, - ) - subDetailSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_subDetailSequence", - title="Extension field for ``subDetailSequence``.", - ) - - subSite: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="subSite", - title="Anatomical sub-location", - description=( - "A region or surface of the bodySite, e.g. limb region or tooth " - "surface(s)." - ), - # if property is element of this resource. - element_property=True, - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitAddItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "itemSequence", - "detailSequence", - "subDetailSequence", - "provider", - "productOrService", - "modifier", - "programCode", - "servicedDate", - "servicedPeriod", - "locationCodeableConcept", - "locationAddress", - "locationReference", - "quantity", - "unitPrice", - "factor", - "net", - "bodySite", - "subSite", - "noteNumber", - "adjudication", - "detail", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2879( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "location": [ - "locationAddress", - "locationCodeableConcept", - "locationReference", - ], - "serviced": ["servicedDate", "servicedPeriod"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ExplanationOfBenefitAddItemDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Insurer added line items. - The second-tier service adjudications for payor added services. - """ - - resource_type = Field("ExplanationOfBenefitAddItemDetail", const=True) - - adjudication: typing.List[ - fhirtypes.ExplanationOfBenefitItemAdjudicationType - ] = Field( - None, - alias="adjudication", - title="Added items adjudication", - description="The adjudication results.", - # if property is element of this resource. - element_property=True, - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Service/Product billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - subDetail: typing.List[ - fhirtypes.ExplanationOfBenefitAddItemDetailSubDetailType - ] = Field( - None, - alias="subDetail", - title="Insurer added line items", - description="The third-tier service adjudications for payor added services.", - # if property is element of this resource. - element_property=True, - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitAddItemDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "productOrService", - "modifier", - "quantity", - "unitPrice", - "factor", - "net", - "noteNumber", - "adjudication", - "subDetail", - ] - - -class ExplanationOfBenefitAddItemDetailSubDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Insurer added line items. - The third-tier service adjudications for payor added services. - """ - - resource_type = Field("ExplanationOfBenefitAddItemDetailSubDetail", const=True) - - adjudication: typing.List[ - fhirtypes.ExplanationOfBenefitItemAdjudicationType - ] = Field( - None, - alias="adjudication", - title="Added items adjudication", - description="The adjudication results.", - # if property is element of this resource. - element_property=True, - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Service/Product billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitAddItemDetailSubDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "productOrService", - "modifier", - "quantity", - "unitPrice", - "factor", - "net", - "noteNumber", - "adjudication", - ] - - -class ExplanationOfBenefitBenefitBalance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Balance by Benefit Category. - """ - - resource_type = Field("ExplanationOfBenefitBenefitBalance", const=True) - - category: fhirtypes.CodeableConceptType = Field( - ..., - alias="category", - title="Benefit classification", - description=( - "Code to identify the general type of benefits under which products and" - " services are provided." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Description of the benefit or services covered", - description="A richer description of the benefit or services covered.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - excluded: bool = Field( - None, - alias="excluded", - title="Excluded from the plan", - description=( - "True if the indicated class of service is excluded from the plan, " - "missing or False indicates the product or service is included in the " - "coverage." - ), - # if property is element of this resource. - element_property=True, - ) - excluded__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_excluded", title="Extension field for ``excluded``." - ) - - financial: typing.List[ - fhirtypes.ExplanationOfBenefitBenefitBalanceFinancialType - ] = Field( - None, - alias="financial", - title="Benefit Summary", - description="Benefits Used to date.", - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Short name for the benefit", - description="A short name or tag for the benefit.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - network: fhirtypes.CodeableConceptType = Field( - None, - alias="network", - title="In or out of network", - description=( - "Is a flag to indicate whether the benefits refer to in-network " - "providers or out-of-network providers." - ), - # if property is element of this resource. - element_property=True, - ) - - term: fhirtypes.CodeableConceptType = Field( - None, - alias="term", - title="Annual or lifetime", - description=( - "The term or period of the values such as 'maximum lifetime benefit' or" - " 'maximum annual visits'." - ), - # if property is element of this resource. - element_property=True, - ) - - unit: fhirtypes.CodeableConceptType = Field( - None, - alias="unit", - title="Individual or family", - description="Indicates if the benefits apply to an individual or to the family.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitBenefitBalance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "category", - "excluded", - "name", - "description", - "network", - "unit", - "term", - "financial", - ] - - -class ExplanationOfBenefitBenefitBalanceFinancial(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Benefit Summary. - Benefits Used to date. - """ - - resource_type = Field("ExplanationOfBenefitBenefitBalanceFinancial", const=True) - - allowedMoney: fhirtypes.MoneyType = Field( - None, - alias="allowedMoney", - title="Benefits allowed", - description="The quantity of the benefit which is permitted under the coverage.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e allowed[x] - one_of_many="allowed", - one_of_many_required=False, - ) - - allowedString: fhirtypes.String = Field( - None, - alias="allowedString", - title="Benefits allowed", - description="The quantity of the benefit which is permitted under the coverage.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e allowed[x] - one_of_many="allowed", - one_of_many_required=False, - ) - allowedString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_allowedString", title="Extension field for ``allowedString``." - ) - - allowedUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="allowedUnsignedInt", - title="Benefits allowed", - description="The quantity of the benefit which is permitted under the coverage.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e allowed[x] - one_of_many="allowed", - one_of_many_required=False, - ) - allowedUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_allowedUnsignedInt", - title="Extension field for ``allowedUnsignedInt``.", - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Benefit classification", - description="Classification of benefit being provided.", - # if property is element of this resource. - element_property=True, - ) - - usedMoney: fhirtypes.MoneyType = Field( - None, - alias="usedMoney", - title="Benefits used", - description="The quantity of the benefit which have been consumed to date.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e used[x] - one_of_many="used", - one_of_many_required=False, - ) - - usedUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="usedUnsignedInt", - title="Benefits used", - description="The quantity of the benefit which have been consumed to date.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e used[x] - one_of_many="used", - one_of_many_required=False, - ) - usedUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_usedUnsignedInt", title="Extension field for ``usedUnsignedInt``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitBenefitBalanceFinancial`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "allowedUnsignedInt", - "allowedString", - "allowedMoney", - "usedUnsignedInt", - "usedMoney", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4494( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "allowed": ["allowedMoney", "allowedString", "allowedUnsignedInt"], - "used": ["usedMoney", "usedUnsignedInt"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ExplanationOfBenefitCareTeam(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Care Team members. - The members of the team who provided the products and services. - """ - - resource_type = Field("ExplanationOfBenefitCareTeam", const=True) - - provider: fhirtypes.ReferenceType = Field( - ..., - alias="provider", - title="Practitioner or organization", - description="Member of the team who provided the product or service.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - qualification: fhirtypes.CodeableConceptType = Field( - None, - alias="qualification", - title="Practitioner credential or specialization", - description=( - "The qualification of the practitioner which is applicable for this " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - responsible: bool = Field( - None, - alias="responsible", - title="Indicator of the lead practitioner", - description=( - "The party who is billing and/or responsible for the claimed products " - "or services." - ), - # if property is element of this resource. - element_property=True, - ) - responsible__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_responsible", title="Extension field for ``responsible``." - ) - - role: fhirtypes.CodeableConceptType = Field( - None, - alias="role", - title="Function within the team", - description=( - "The lead, assisting or supervising practitioner and their discipline " - "if a multidisciplinary team." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Order of care team", - description="A number to uniquely identify care team entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitCareTeam`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "provider", - "responsible", - "role", - "qualification", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2985( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExplanationOfBenefitDiagnosis(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Pertinent diagnosis information. - Information about diagnoses relevant to the claim items. - """ - - resource_type = Field("ExplanationOfBenefitDiagnosis", const=True) - - diagnosisCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="diagnosisCodeableConcept", - title="Nature of illness or problem", - description=( - "The nature of illness or problem in a coded form or as a reference to " - "an external defined Condition." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e diagnosis[x] - one_of_many="diagnosis", - one_of_many_required=True, - ) - - diagnosisReference: fhirtypes.ReferenceType = Field( - None, - alias="diagnosisReference", - title="Nature of illness or problem", - description=( - "The nature of illness or problem in a coded form or as a reference to " - "an external defined Condition." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e diagnosis[x] - one_of_many="diagnosis", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition"], - ) - - onAdmission: fhirtypes.CodeableConceptType = Field( - None, - alias="onAdmission", - title="Present on admission", - description=( - "Indication of whether the diagnosis was present on admission to a " - "facility." - ), - # if property is element of this resource. - element_property=True, - ) - - packageCode: fhirtypes.CodeableConceptType = Field( - None, - alias="packageCode", - title="Package billing code", - description=( - "A package billing code or bundle code used to group products and " - "services to a particular health condition (such as heart attack) which" - " is based on a predetermined grouping code system." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Diagnosis instance identifier", - description="A number to uniquely identify diagnosis entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Timing or nature of the diagnosis", - description="When the condition was observed or the relative ranking.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitDiagnosis`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "diagnosisCodeableConcept", - "diagnosisReference", - "type", - "onAdmission", - "packageCode", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3150( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3150( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "diagnosis": ["diagnosisCodeableConcept", "diagnosisReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ExplanationOfBenefitInsurance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Patient insurance information. - Financial instruments for reimbursement for the health care products and - services specified on the claim. - """ - - resource_type = Field("ExplanationOfBenefitInsurance", const=True) - - coverage: fhirtypes.ReferenceType = Field( - ..., - alias="coverage", - title="Insurance information", - description=( - "Reference to the insurance card level information contained in the " - "Coverage resource. The coverage issuing insurer will use these details" - " to locate the patient's actual coverage within the insurer's " - "information system." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Coverage"], - ) - - focal: bool = Field( - None, - alias="focal", - title="Coverage to be used for adjudication", - description=( - "A flag to indicate that this Coverage is to be used for adjudication " - "of this claim when set to true." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - focal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_focal", title="Extension field for ``focal``." - ) - - preAuthRef: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="preAuthRef", - title="Prior authorization reference number", - description=( - "Reference numbers previously provided by the insurer to the provider " - "to be quoted on subsequent claims containing services or products " - "related to the prior authorization." - ), - # if property is element of this resource. - element_property=True, - ) - preAuthRef__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_preAuthRef", title="Extension field for ``preAuthRef``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitInsurance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "focal", - "coverage", - "preAuthRef", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3143( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("focal", "focal__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExplanationOfBenefitItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Product or service provided. - A claim line. Either a simple (a product or service) or a 'group' of - details which can also be a simple items or groups of sub-details. - """ - - resource_type = Field("ExplanationOfBenefitItem", const=True) - - adjudication: typing.List[ - fhirtypes.ExplanationOfBenefitItemAdjudicationType - ] = Field( - None, - alias="adjudication", - title="Adjudication details", - description=( - "If this item is a group then the values here are a summary of the " - "adjudication of the detail items. If this item is a simple product or " - "service then this is the result of the adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - - bodySite: fhirtypes.CodeableConceptType = Field( - None, - alias="bodySite", - title="Anatomical location", - description="Physical service site on the patient (limb, tooth, etc.).", - # if property is element of this resource. - element_property=True, - ) - - careTeamSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="careTeamSequence", - title="Applicable care team members", - description="Care team members related to this service or product.", - # if property is element of this resource. - element_property=True, - ) - careTeamSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_careTeamSequence", - title="Extension field for ``careTeamSequence``.", - ) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Benefit classification", - description=( - "Code to identify the general type of benefits under which products and" - " services are provided." - ), - # if property is element of this resource. - element_property=True, - ) - - detail: typing.List[fhirtypes.ExplanationOfBenefitItemDetailType] = Field( - None, - alias="detail", - title="Additional items", - description="Second-tier of goods and services.", - # if property is element of this resource. - element_property=True, - ) - - diagnosisSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="diagnosisSequence", - title="Applicable diagnoses", - description="Diagnoses applicable for this service or product.", - # if property is element of this resource. - element_property=True, - ) - diagnosisSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_diagnosisSequence", - title="Extension field for ``diagnosisSequence``.", - ) - - encounter: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="encounter", - title="Encounters related to this billed item", - description=( - "A billed item may include goods or services provided in multiple " - "encounters." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - informationSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="informationSequence", - title="Applicable exception and supporting information", - description=( - "Exceptions, special conditions and supporting information applicable " - "for this service or product." - ), - # if property is element of this resource. - element_property=True, - ) - informationSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_informationSequence", - title="Extension field for ``informationSequence``.", - ) - - locationAddress: fhirtypes.AddressType = Field( - None, - alias="locationAddress", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - ) - - locationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="locationCodeableConcept", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - ) - - locationReference: fhirtypes.ReferenceType = Field( - None, - alias="locationReference", - title="Place of service or where product was supplied", - description="Where the product or service was provided.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e location[x] - one_of_many="location", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Product or service billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - procedureSequence: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="procedureSequence", - title="Applicable procedures", - description="Procedures applicable for this service or product.", - # if property is element of this resource. - element_property=True, - ) - procedureSequence__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_procedureSequence", - title="Extension field for ``procedureSequence``.", - ) - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - programCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="programCode", - title="Program the product or service is provided under", - description="Identifies the program under which this may be recovered.", - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - revenue: fhirtypes.CodeableConceptType = Field( - None, - alias="revenue", - title="Revenue or cost center code", - description=( - "The type of revenue or cost center providing the product and/or " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Item instance identifier", - description="A number to uniquely identify item entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - servicedDate: fhirtypes.Date = Field( - None, - alias="servicedDate", - title="Date or dates of service or product delivery", - description=( - "The date or dates when the service or product was supplied, performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - servicedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_servicedDate", title="Extension field for ``servicedDate``." - ) - - servicedPeriod: fhirtypes.PeriodType = Field( - None, - alias="servicedPeriod", - title="Date or dates of service or product delivery", - description=( - "The date or dates when the service or product was supplied, performed " - "or completed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e serviced[x] - one_of_many="serviced", - one_of_many_required=False, - ) - - subSite: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="subSite", - title="Anatomical sub-location", - description=( - "A region or surface of the bodySite, e.g. limb region or tooth " - "surface(s)." - ), - # if property is element of this resource. - element_property=True, - ) - - udi: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="udi", - title="Unique device identifier", - description="Unique Device Identifiers associated with this line item.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "careTeamSequence", - "diagnosisSequence", - "procedureSequence", - "informationSequence", - "revenue", - "category", - "productOrService", - "modifier", - "programCode", - "servicedDate", - "servicedPeriod", - "locationCodeableConcept", - "locationAddress", - "locationReference", - "quantity", - "unitPrice", - "factor", - "net", - "udi", - "bodySite", - "subSite", - "encounter", - "noteNumber", - "adjudication", - "detail", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2614( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2614( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "location": [ - "locationAddress", - "locationCodeableConcept", - "locationReference", - ], - "serviced": ["servicedDate", "servicedPeriod"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ExplanationOfBenefitItemAdjudication(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Adjudication details. - If this item is a group then the values here are a summary of the - adjudication of the detail items. If this item is a simple product or - service then this is the result of the adjudication of this item. - """ - - resource_type = Field("ExplanationOfBenefitItemAdjudication", const=True) - - amount: fhirtypes.MoneyType = Field( - None, - alias="amount", - title="Monetary amount", - description="Monetary amount associated with the category.", - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.CodeableConceptType = Field( - ..., - alias="category", - title="Type of adjudication information", - description=( - "A code to indicate the information type of this adjudication record. " - "Information types may include: the value submitted, maximum values or " - "percentages allowed or payable under the plan, amounts that the " - "patient is responsible for in-aggregate or pertaining to this item, " - "amounts paid by other coverages, and the benefit payable for this " - "item." - ), - # if property is element of this resource. - element_property=True, - ) - - reason: fhirtypes.CodeableConceptType = Field( - None, - alias="reason", - title="Explanation of adjudication outcome", - description=( - "A code supporting the understanding of the adjudication result and " - "explaining variance from expected amount." - ), - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.Decimal = Field( - None, - alias="value", - title="Non-monitary value", - description=( - "A non-monetary value associated with the category. Mutually exclusive " - "to the amount element above." - ), - # if property is element of this resource. - element_property=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitItemAdjudication`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "category", - "reason", - "amount", - "value", - ] - - -class ExplanationOfBenefitItemDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Additional items. - Second-tier of goods and services. - """ - - resource_type = Field("ExplanationOfBenefitItemDetail", const=True) - - adjudication: typing.List[ - fhirtypes.ExplanationOfBenefitItemAdjudicationType - ] = Field( - None, - alias="adjudication", - title="Detail level adjudication details", - description="The adjudication results.", - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Benefit classification", - description=( - "Code to identify the general type of benefits under which products and" - " services are provided." - ), - # if property is element of this resource. - element_property=True, - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Service/Product billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - programCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="programCode", - title="Program the product or service is provided under", - description="Identifies the program under which this may be recovered.", - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - revenue: fhirtypes.CodeableConceptType = Field( - None, - alias="revenue", - title="Revenue or cost center code", - description=( - "The type of revenue or cost center providing the product and/or " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Product or service provided", - description=( - "A claim detail line. Either a simple (a product or service) or a " - "'group' of sub-details which are simple items." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - subDetail: typing.List[ - fhirtypes.ExplanationOfBenefitItemDetailSubDetailType - ] = Field( - None, - alias="subDetail", - title="Additional items", - description="Third-tier of goods and services.", - # if property is element of this resource. - element_property=True, - ) - - udi: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="udi", - title="Unique device identifier", - description="Unique Device Identifiers associated with this line item.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitItemDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "revenue", - "category", - "productOrService", - "modifier", - "programCode", - "quantity", - "unitPrice", - "factor", - "net", - "udi", - "noteNumber", - "adjudication", - "subDetail", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3208( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExplanationOfBenefitItemDetailSubDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Additional items. - Third-tier of goods and services. - """ - - resource_type = Field("ExplanationOfBenefitItemDetailSubDetail", const=True) - - adjudication: typing.List[ - fhirtypes.ExplanationOfBenefitItemAdjudicationType - ] = Field( - None, - alias="adjudication", - title="Subdetail level adjudication details", - description="The adjudication results.", - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Benefit classification", - description=( - "Code to identify the general type of benefits under which products and" - " services are provided." - ), - # if property is element of this resource. - element_property=True, - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Price scaling factor", - description=( - "A real number that represents a multiplier used in determining the " - "overall value of services delivered and/or goods received. The concept" - " of a Factor allows for a discount or surcharge multiplier to be " - "applied to a monetary amount." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - modifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="modifier", - title="Service/Product billing modifiers", - description=( - "Item typification or modifiers codes to convey additional context for " - "the product or service." - ), - # if property is element of this resource. - element_property=True, - ) - - net: fhirtypes.MoneyType = Field( - None, - alias="net", - title="Total item cost", - description=( - "The quantity times the unit price for an additional service or product" - " or charge." - ), - # if property is element of this resource. - element_property=True, - ) - - noteNumber: typing.List[fhirtypes.PositiveInt] = Field( - None, - alias="noteNumber", - title="Applicable note numbers", - description=( - "The numbers associated with notes below which apply to the " - "adjudication of this item." - ), - # if property is element of this resource. - element_property=True, - ) - noteNumber__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_noteNumber", title="Extension field for ``noteNumber``.") - - productOrService: fhirtypes.CodeableConceptType = Field( - ..., - alias="productOrService", - title="Billing, service, product, or drug code", - description=( - "When the value is a group code then this item collects a set of " - "related claim details, otherwise this contains the product, service, " - "drug or other billing code for the item." - ), - # if property is element of this resource. - element_property=True, - ) - - programCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="programCode", - title="Program the product or service is provided under", - description="Identifies the program under which this may be recovered.", - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Count of products or services", - description="The number of repetitions of a service or product.", - # if property is element of this resource. - element_property=True, - ) - - revenue: fhirtypes.CodeableConceptType = Field( - None, - alias="revenue", - title="Revenue or cost center code", - description=( - "The type of revenue or cost center providing the product and/or " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Product or service provided", - description=( - "A claim detail line. Either a simple (a product or service) or a " - "'group' of sub-details which are simple items." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - udi: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="udi", - title="Unique device identifier", - description="Unique Device Identifiers associated with this line item.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - unitPrice: fhirtypes.MoneyType = Field( - None, - alias="unitPrice", - title="Fee, charge or cost per item", - description=( - "If the item is not a group then this is the fee for the product or " - "service, otherwise this is the total of the fees for the details of " - "the group." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitItemDetailSubDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "revenue", - "category", - "productOrService", - "modifier", - "programCode", - "quantity", - "unitPrice", - "factor", - "net", - "udi", - "noteNumber", - "adjudication", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4101( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ExplanationOfBenefitPayee(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Recipient of benefits payable. - The party to be reimbursed for cost of the products and services according - to the terms of the policy. - """ - - resource_type = Field("ExplanationOfBenefitPayee", const=True) - - party: fhirtypes.ReferenceType = Field( - None, - alias="party", - title="Recipient reference", - description=( - "Reference to the individual or organization to whom any payment will " - "be made." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Patient", - "RelatedPerson", - ], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Category of recipient", - description="Type of Party to be reimbursed: Subscriber, provider, other.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitPayee`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "party"] - - -class ExplanationOfBenefitPayment(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Payment Details. - Payment details for the adjudication of the claim. - """ - - resource_type = Field("ExplanationOfBenefitPayment", const=True) - - adjustment: fhirtypes.MoneyType = Field( - None, - alias="adjustment", - title="Payment adjustment for non-claim issues", - description=( - "Total amount of all adjustments to this payment included in this " - "transaction which are not related to this claim's adjudication." - ), - # if property is element of this resource. - element_property=True, - ) - - adjustmentReason: fhirtypes.CodeableConceptType = Field( - None, - alias="adjustmentReason", - title="Explanation for the variance", - description="Reason for the payment adjustment.", - # if property is element of this resource. - element_property=True, - ) - - amount: fhirtypes.MoneyType = Field( - None, - alias="amount", - title="Payable amount after adjustment", - description="Benefits payable less any payment adjustment.", - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.Date = Field( - None, - alias="date", - title="Expected date of payment", - description=( - "Estimated date the payment will be issued or the actual issue date of " - "payment." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Business identifier for the payment", - description="Issuer's unique identifier for the payment instrument.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Partial or complete payment", - description=( - "Whether this represents partial or complete payment of the benefits " - "payable." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitPayment`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "adjustment", - "adjustmentReason", - "date", - "amount", - "identifier", - ] - - -class ExplanationOfBenefitProcedure(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Clinical procedures performed. - Procedures performed on the patient relevant to the billing items with the - claim. - """ - - resource_type = Field("ExplanationOfBenefitProcedure", const=True) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="When the procedure was performed", - description="Date and optionally time the procedure was performed.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - procedureCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="procedureCodeableConcept", - title="Specific clinical procedure", - description=( - "The code or reference to a Procedure resource which identifies the " - "clinical intervention performed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e procedure[x] - one_of_many="procedure", - one_of_many_required=True, - ) - - procedureReference: fhirtypes.ReferenceType = Field( - None, - alias="procedureReference", - title="Specific clinical procedure", - description=( - "The code or reference to a Procedure resource which identifies the " - "clinical intervention performed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e procedure[x] - one_of_many="procedure", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Procedure"], - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Procedure instance identifier", - description="A number to uniquely identify procedure entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Category of Procedure", - description="When the condition was observed or the relative ranking.", - # if property is element of this resource. - element_property=True, - ) - - udi: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="udi", - title="Unique device identifier", - description="Unique Device Identifiers associated with this line item.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitProcedure`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "type", - "date", - "procedureCodeableConcept", - "procedureReference", - "udi", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3144( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3144( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "procedure": ["procedureCodeableConcept", "procedureReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ExplanationOfBenefitProcessNote(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Note concerning adjudication. - A note that describes or explains adjudication results in a human readable - form. - """ - - resource_type = Field("ExplanationOfBenefitProcessNote", const=True) - - language: fhirtypes.CodeableConceptType = Field( - None, - alias="language", - title="Language of the text", - description="A code to define the language used in the text of the note.", - # if property is element of this resource. - element_property=True, - ) - - number: fhirtypes.PositiveInt = Field( - None, - alias="number", - title="Note instance identifier", - description="A number to uniquely identify a note entry.", - # if property is element of this resource. - element_property=True, - ) - number__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_number", title="Extension field for ``number``." - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Note explanatory text", - description="The explanation or description associated with the processing.", - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="display | print | printoper", - description="The business purpose of the note text.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["display", "print", "printoper"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitProcessNote`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "number", - "type", - "text", - "language", - ] - - -class ExplanationOfBenefitRelated(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Prior or corollary claims. - Other claims which are related to this claim such as prior submissions or - claims for related services or for the same event. - """ - - resource_type = Field("ExplanationOfBenefitRelated", const=True) - - claim: fhirtypes.ReferenceType = Field( - None, - alias="claim", - title="Reference to the related claim", - description="Reference to a related claim.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Claim"], - ) - - reference: fhirtypes.IdentifierType = Field( - None, - alias="reference", - title="File or case reference", - description=( - "An alternate organizational reference to the case or file to which " - "this particular claim pertains." - ), - # if property is element of this resource. - element_property=True, - ) - - relationship: fhirtypes.CodeableConceptType = Field( - None, - alias="relationship", - title="How the reference claim is related", - description="A code to convey how the claims are related.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitRelated`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "claim", - "relationship", - "reference", - ] - - -class ExplanationOfBenefitSupportingInfo(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Supporting information. - Additional information codes regarding exceptions, special considerations, - the condition, situation, prior or concurrent issues. - """ - - resource_type = Field("ExplanationOfBenefitSupportingInfo", const=True) - - category: fhirtypes.CodeableConceptType = Field( - ..., - alias="category", - title="Classification of the supplied information", - description=( - "The general class of the information supplied: information; exception;" - " accident, employment; onset, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Type of information", - description=( - "System and code pertaining to the specific information regarding " - "special conditions relating to the setting, treatment or patient for " - "which care is sought." - ), - # if property is element of this resource. - element_property=True, - ) - - reason: fhirtypes.CodingType = Field( - None, - alias="reason", - title="Explanation for the information", - description=( - "Provides the reason in the situation where a reason code is required " - "in addition to the content." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Information instance identifier", - description="A number to uniquely identify supporting information entries.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - timingDate: fhirtypes.Date = Field( - None, - alias="timingDate", - title="When it occurred", - description="The date when or period to which this information refers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - timingDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timingDate", title="Extension field for ``timingDate``." - ) - - timingPeriod: fhirtypes.PeriodType = Field( - None, - alias="timingPeriod", - title="When it occurred", - description="The date when or period to which this information refers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - valueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="valueAttachment", - title="Data to be provided", - description=( - "Additional data or information such as resources, documents, images " - "etc. including references to the data or the actual inclusion of the " - "data." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Data to be provided", - description=( - "Additional data or information such as resources, documents, images " - "etc. including references to the data or the actual inclusion of the " - "data." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Data to be provided", - description=( - "Additional data or information such as resources, documents, images " - "etc. including references to the data or the actual inclusion of the " - "data." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="Data to be provided", - description=( - "Additional data or information such as resources, documents, images " - "etc. including references to the data or the actual inclusion of the " - "data." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Data to be provided", - description=( - "Additional data or information such as resources, documents, images " - "etc. including references to the data or the actual inclusion of the " - "data." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitSupportingInfo`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "category", - "code", - "timingDate", - "timingPeriod", - "valueBoolean", - "valueString", - "valueQuantity", - "valueAttachment", - "valueReference", - "reason", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3696( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("sequence", "sequence__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3696( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "timing": ["timingDate", "timingPeriod"], - "value": [ - "valueAttachment", - "valueBoolean", - "valueQuantity", - "valueReference", - "valueString", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ExplanationOfBenefitTotal(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Adjudication totals. - Categorized monetary totals for the adjudication. - """ - - resource_type = Field("ExplanationOfBenefitTotal", const=True) - - amount: fhirtypes.MoneyType = Field( - ..., - alias="amount", - title="Financial total for the category", - description="Monetary total amount associated with the category.", - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.CodeableConceptType = Field( - ..., - alias="category", - title="Type of adjudication information", - description=( - "A code to indicate the information type of this adjudication record. " - "Information types may include: the value submitted, maximum values or " - "percentages allowed or payable under the plan, amounts that the " - "patient is responsible for in aggregate or pertaining to this item, " - "amounts paid by other coverages, and the benefit payable for this " - "item." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ExplanationOfBenefitTotal`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "category", "amount"] diff --git a/fhir/resources/expression.py b/fhir/resources/expression.py deleted file mode 100644 index bb0bfa71..00000000 --- a/fhir/resources/expression.py +++ /dev/null @@ -1,174 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Expression -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import element, fhirtypes - - -class Expression(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An expression that can be used to generate a value. - A expression that is evaluated in a specified context and returns a value. - The context of use of the expression must specify the context in which the - expression is evaluated, and how the result of the expression is used. - """ - - resource_type = Field("Expression", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Natural language description of the condition", - description=( - "A brief, natural language description of the condition that " - "effectively communicates the intended semantics." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - expression: fhirtypes.String = Field( - None, - alias="expression", - title="Expression in specified language", - description="An expression in the specified language that returns a value.", - # if property is element of this resource. - element_property=True, - ) - expression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expression", title="Extension field for ``expression``." - ) - - language: fhirtypes.Code = Field( - None, - alias="language", - title="text/cql | text/fhirpath | application/x-fhir-query | etc.", - description="The media type of the language for the expression.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["text/cql", "text/fhirpath", "application/x-fhir-query", "etc."], - ) - language__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_language", title="Extension field for ``language``." - ) - - name: fhirtypes.Id = Field( - None, - alias="name", - title="Short name assigned to expression for reuse", - description=( - "A short name assigned to the expression to allow for multiple reuse of" - " the expression in the context where it is defined." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - reference: fhirtypes.Uri = Field( - None, - alias="reference", - title="Where the expression is found", - description="A URI that defines where the expression is found.", - # if property is element of this resource. - element_property=True, - ) - reference__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_reference", title="Extension field for ``reference``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Expression`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "description", - "name", - "language", - "expression", - "reference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1251( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("language", "language__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/extension.py b/fhir/resources/extension.py deleted file mode 100644 index 5cc64f9f..00000000 --- a/fhir/resources/extension.py +++ /dev/null @@ -1,941 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Extension -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import element, fhirtypes - - -class Extension(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Optional Extensions Element. - Optional Extension Element - found in all resources. - """ - - resource_type = Field("Extension", const=True) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title="identifies the meaning of the extension", - description=( - "Source of the definition for the extension code - a logical name or a " - "URL." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - - valueAddress: fhirtypes.AddressType = Field( - None, - alias="valueAddress", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueAge: fhirtypes.AgeType = Field( - None, - alias="valueAge", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueAnnotation: fhirtypes.AnnotationType = Field( - None, - alias="valueAnnotation", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="valueAttachment", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueBase64Binary: fhirtypes.Base64Binary = Field( - None, - alias="valueBase64Binary", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueCanonical: fhirtypes.Canonical = Field( - None, - alias="valueCanonical", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueCode: fhirtypes.Code = Field( - None, - alias="valueCode", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueCoding: fhirtypes.CodingType = Field( - None, - alias="valueCoding", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueContactDetail: fhirtypes.ContactDetailType = Field( - None, - alias="valueContactDetail", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueContactPoint: fhirtypes.ContactPointType = Field( - None, - alias="valueContactPoint", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueContributor: fhirtypes.ContributorType = Field( - None, - alias="valueContributor", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueCount: fhirtypes.CountType = Field( - None, - alias="valueCount", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDataRequirement: fhirtypes.DataRequirementType = Field( - None, - alias="valueDataRequirement", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDate: fhirtypes.Date = Field( - None, - alias="valueDate", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDecimal: fhirtypes.Decimal = Field( - None, - alias="valueDecimal", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDistance: fhirtypes.DistanceType = Field( - None, - alias="valueDistance", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDosage: fhirtypes.DosageType = Field( - None, - alias="valueDosage", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDuration: fhirtypes.DurationType = Field( - None, - alias="valueDuration", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueExpression: fhirtypes.ExpressionType = Field( - None, - alias="valueExpression", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueHumanName: fhirtypes.HumanNameType = Field( - None, - alias="valueHumanName", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueId: fhirtypes.Id = Field( - None, - alias="valueId", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="valueIdentifier", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueInstant: fhirtypes.Instant = Field( - None, - alias="valueInstant", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueMarkdown: fhirtypes.Markdown = Field( - None, - alias="valueMarkdown", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueMeta: fhirtypes.MetaType = Field( - None, - alias="valueMeta", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueMoney: fhirtypes.MoneyType = Field( - None, - alias="valueMoney", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueOid: fhirtypes.Oid = Field( - None, - alias="valueOid", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueParameterDefinition: fhirtypes.ParameterDefinitionType = Field( - None, - alias="valueParameterDefinition", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valuePeriod: fhirtypes.PeriodType = Field( - None, - alias="valuePeriod", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valuePositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="valuePositiveInt", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRange: fhirtypes.RangeType = Field( - None, - alias="valueRange", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRatio: fhirtypes.RatioType = Field( - None, - alias="valueRatio", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRelatedArtifact: fhirtypes.RelatedArtifactType = Field( - None, - alias="valueRelatedArtifact", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueSampledData: fhirtypes.SampledDataType = Field( - None, - alias="valueSampledData", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueSignature: fhirtypes.SignatureType = Field( - None, - alias="valueSignature", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueTime: fhirtypes.Time = Field( - None, - alias="valueTime", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueTiming: fhirtypes.TimingType = Field( - None, - alias="valueTiming", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueTriggerDefinition: fhirtypes.TriggerDefinitionType = Field( - None, - alias="valueTriggerDefinition", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="valueUnsignedInt", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueUri: fhirtypes.Uri = Field( - None, - alias="valueUri", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueUrl: fhirtypes.Url = Field( - None, - alias="valueUrl", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueUsageContext: fhirtypes.UsageContextType = Field( - None, - alias="valueUsageContext", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueUuid: fhirtypes.Uuid = Field( - None, - alias="valueUuid", - title="Value of extension", - description=( - "Value of extension - must be one of a constrained set of the data " - "types (see [Extensibility](extensibility.html) for a list)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Extension`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "url", - "valueBase64Binary", - "valueBoolean", - "valueCanonical", - "valueCode", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueId", - "valueInstant", - "valueInteger", - "valueMarkdown", - "valueOid", - "valuePositiveInt", - "valueString", - "valueTime", - "valueUnsignedInt", - "valueUri", - "valueUrl", - "valueUuid", - "valueAddress", - "valueAge", - "valueAnnotation", - "valueAttachment", - "valueCodeableConcept", - "valueCoding", - "valueContactPoint", - "valueCount", - "valueDistance", - "valueDuration", - "valueHumanName", - "valueIdentifier", - "valueMoney", - "valuePeriod", - "valueQuantity", - "valueRange", - "valueRatio", - "valueReference", - "valueSampledData", - "valueSignature", - "valueTiming", - "valueContactDetail", - "valueContributor", - "valueDataRequirement", - "valueExpression", - "valueParameterDefinition", - "valueRelatedArtifact", - "valueTriggerDefinition", - "valueUsageContext", - "valueDosage", - "valueMeta", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1136( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueAddress", - "valueAge", - "valueAnnotation", - "valueAttachment", - "valueBase64Binary", - "valueBoolean", - "valueCanonical", - "valueCode", - "valueCodeableConcept", - "valueCoding", - "valueContactDetail", - "valueContactPoint", - "valueContributor", - "valueCount", - "valueDataRequirement", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueDistance", - "valueDosage", - "valueDuration", - "valueExpression", - "valueHumanName", - "valueId", - "valueIdentifier", - "valueInstant", - "valueInteger", - "valueMarkdown", - "valueMeta", - "valueMoney", - "valueOid", - "valueParameterDefinition", - "valuePeriod", - "valuePositiveInt", - "valueQuantity", - "valueRange", - "valueRatio", - "valueReference", - "valueRelatedArtifact", - "valueSampledData", - "valueSignature", - "valueString", - "valueTime", - "valueTiming", - "valueTriggerDefinition", - "valueUnsignedInt", - "valueUri", - "valueUrl", - "valueUsageContext", - "valueUuid", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/familymemberhistory.py b/fhir/resources/familymemberhistory.py deleted file mode 100644 index f7e23111..00000000 --- a/fhir/resources/familymemberhistory.py +++ /dev/null @@ -1,770 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/FamilyMemberHistory -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class FamilyMemberHistory(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about patient's relatives, relevant for patient. - Significant health conditions for a person related to the patient relevant - in the context of care for the patient. - """ - - resource_type = Field("FamilyMemberHistory", const=True) - - ageAge: fhirtypes.AgeType = Field( - None, - alias="ageAge", - title="(approximate) age", - description=( - "The age of the relative at the time the family member history is " - "recorded." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e age[x] - one_of_many="age", - one_of_many_required=False, - ) - - ageRange: fhirtypes.RangeType = Field( - None, - alias="ageRange", - title="(approximate) age", - description=( - "The age of the relative at the time the family member history is " - "recorded." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e age[x] - one_of_many="age", - one_of_many_required=False, - ) - - ageString: fhirtypes.String = Field( - None, - alias="ageString", - title="(approximate) age", - description=( - "The age of the relative at the time the family member history is " - "recorded." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e age[x] - one_of_many="age", - one_of_many_required=False, - ) - ageString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_ageString", title="Extension field for ``ageString``." - ) - - bornDate: fhirtypes.Date = Field( - None, - alias="bornDate", - title="(approximate) date of birth", - description="The actual or approximate date of birth of the relative.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e born[x] - one_of_many="born", - one_of_many_required=False, - ) - bornDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_bornDate", title="Extension field for ``bornDate``." - ) - - bornPeriod: fhirtypes.PeriodType = Field( - None, - alias="bornPeriod", - title="(approximate) date of birth", - description="The actual or approximate date of birth of the relative.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e born[x] - one_of_many="born", - one_of_many_required=False, - ) - - bornString: fhirtypes.String = Field( - None, - alias="bornString", - title="(approximate) date of birth", - description="The actual or approximate date of birth of the relative.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e born[x] - one_of_many="born", - one_of_many_required=False, - ) - bornString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_bornString", title="Extension field for ``bornString``." - ) - - condition: typing.List[fhirtypes.FamilyMemberHistoryConditionType] = Field( - None, - alias="condition", - title="Condition that the related person had", - description=( - "The significant Conditions (or condition) that the family member had. " - "This is a repeating section to allow a system to represent more than " - "one condition per resource, though there is nothing stopping multiple " - "resources - one per condition." - ), - # if property is element of this resource. - element_property=True, - ) - - dataAbsentReason: fhirtypes.CodeableConceptType = Field( - None, - alias="dataAbsentReason", - title="subject-unknown | withheld | unable-to-obtain | deferred", - description="Describes why the family member's history is not available.", - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="When history was recorded or last updated", - description=( - "The date (and possibly time) when the family member history was " - "recorded or last updated." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - deceasedAge: fhirtypes.AgeType = Field( - None, - alias="deceasedAge", - title="Dead? How old/when?", - description=( - "Deceased flag or the actual or approximate age of the relative at the " - "time of death for the family member history record." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e deceased[x] - one_of_many="deceased", - one_of_many_required=False, - ) - - deceasedBoolean: bool = Field( - None, - alias="deceasedBoolean", - title="Dead? How old/when?", - description=( - "Deceased flag or the actual or approximate age of the relative at the " - "time of death for the family member history record." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e deceased[x] - one_of_many="deceased", - one_of_many_required=False, - ) - deceasedBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_deceasedBoolean", title="Extension field for ``deceasedBoolean``." - ) - - deceasedDate: fhirtypes.Date = Field( - None, - alias="deceasedDate", - title="Dead? How old/when?", - description=( - "Deceased flag or the actual or approximate age of the relative at the " - "time of death for the family member history record." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e deceased[x] - one_of_many="deceased", - one_of_many_required=False, - ) - deceasedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_deceasedDate", title="Extension field for ``deceasedDate``." - ) - - deceasedRange: fhirtypes.RangeType = Field( - None, - alias="deceasedRange", - title="Dead? How old/when?", - description=( - "Deceased flag or the actual or approximate age of the relative at the " - "time of death for the family member history record." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e deceased[x] - one_of_many="deceased", - one_of_many_required=False, - ) - - deceasedString: fhirtypes.String = Field( - None, - alias="deceasedString", - title="Dead? How old/when?", - description=( - "Deceased flag or the actual or approximate age of the relative at the " - "time of death for the family member history record." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e deceased[x] - one_of_many="deceased", - one_of_many_required=False, - ) - deceasedString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_deceasedString", title="Extension field for ``deceasedString``." - ) - - estimatedAge: bool = Field( - None, - alias="estimatedAge", - title="Age is estimated?", - description="If true, indicates that the age value specified is an estimated value.", - # if property is element of this resource. - element_property=True, - ) - estimatedAge__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_estimatedAge", title="Extension field for ``estimatedAge``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Id(s) for this record", - description=( - "Business identifiers assigned to this family member history by the " - "performer or other systems which remain constant as the resource is " - "updated and propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - instantiatesCanonical: typing.List[fhirtypes.Canonical] = Field( - None, - alias="instantiatesCanonical", - title="Instantiates FHIR protocol or definition", - description=( - "The URL pointing to a FHIR-defined protocol, guideline, orderset or " - "other definition that is adhered to in whole or in part by this " - "FamilyMemberHistory." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "PlanDefinition", - "Questionnaire", - "ActivityDefinition", - "Measure", - "OperationDefinition", - ], - ) - instantiatesCanonical__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_instantiatesCanonical", - title="Extension field for ``instantiatesCanonical``.", - ) - - instantiatesUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiatesUri", - title="Instantiates external protocol or definition", - description=( - "The URL pointing to an externally maintained protocol, guideline, " - "orderset or other definition that is adhered to in whole or in part by" - " this FamilyMemberHistory." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="The family member described", - description=( - 'This will either be a name or a description; e.g. "Aunt Susan", "my ' - 'cousin with the red hair".' - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="General note about related person", - description=( - "This property allows a non condition-specific note to the made about " - "the related person. Ideally, the note would be in the condition " - "property, but this is not always possible." - ), - # if property is element of this resource. - element_property=True, - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="Patient history is about", - description="The person who this history concerns.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why was family member history performed?", - description=( - "Describes why the family member history occurred in coded or textual " - "form." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why was family member history performed?", - description=( - "Indicates a Condition, Observation, AllergyIntolerance, or " - "QuestionnaireResponse that justifies this family member history event." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "AllergyIntolerance", - "QuestionnaireResponse", - "DiagnosticReport", - "DocumentReference", - ], - ) - - relationship: fhirtypes.CodeableConceptType = Field( - ..., - alias="relationship", - title="Relationship to the subject", - description=( - "The type of relationship this person has to the patient (father, " - "mother, brother etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - - sex: fhirtypes.CodeableConceptType = Field( - None, - alias="sex", - title="male | female | other | unknown", - description="The birth sex of the family member.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="partial | completed | entered-in-error | health-unknown", - description=( - "A code specifying the status of the record of the family history of a " - "specific family member." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["partial", "completed", "entered-in-error", "health-unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``FamilyMemberHistory`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "instantiatesCanonical", - "instantiatesUri", - "status", - "dataAbsentReason", - "patient", - "date", - "name", - "relationship", - "sex", - "bornPeriod", - "bornDate", - "bornString", - "ageAge", - "ageRange", - "ageString", - "estimatedAge", - "deceasedBoolean", - "deceasedAge", - "deceasedRange", - "deceasedDate", - "deceasedString", - "reasonCode", - "reasonReference", - "note", - "condition", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2155( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2155( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "age": ["ageAge", "ageRange", "ageString"], - "born": ["bornDate", "bornPeriod", "bornString"], - "deceased": [ - "deceasedAge", - "deceasedBoolean", - "deceasedDate", - "deceasedRange", - "deceasedString", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class FamilyMemberHistoryCondition(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Condition that the related person had. - The significant Conditions (or condition) that the family member had. This - is a repeating section to allow a system to represent more than one - condition per resource, though there is nothing stopping multiple resources - - one per condition. - """ - - resource_type = Field("FamilyMemberHistoryCondition", const=True) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Condition suffered by relation", - description=( - "The actual condition specified. Could be a coded condition (like MI or" - " Diabetes) or a less specific string like 'cancer' depending on how " - "much is known about the condition and the capabilities of the creating" - " system." - ), - # if property is element of this resource. - element_property=True, - ) - - contributedToDeath: bool = Field( - None, - alias="contributedToDeath", - title="Whether the condition contributed to the cause of death", - description=( - "This condition contributed to the cause of death of the related " - "person. If contributedToDeath is not populated, then it is unknown." - ), - # if property is element of this resource. - element_property=True, - ) - contributedToDeath__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_contributedToDeath", - title="Extension field for ``contributedToDeath``.", - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Extra information about condition", - description=( - "An area where general notes can be placed about this specific " - "condition." - ), - # if property is element of this resource. - element_property=True, - ) - - onsetAge: fhirtypes.AgeType = Field( - None, - alias="onsetAge", - title="When condition first manifested", - description=( - "Either the age of onset, range of approximate age or descriptive " - "string can be recorded. For conditions with multiple occurrences, " - "this describes the first known occurrence." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - - onsetPeriod: fhirtypes.PeriodType = Field( - None, - alias="onsetPeriod", - title="When condition first manifested", - description=( - "Either the age of onset, range of approximate age or descriptive " - "string can be recorded. For conditions with multiple occurrences, " - "this describes the first known occurrence." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - - onsetRange: fhirtypes.RangeType = Field( - None, - alias="onsetRange", - title="When condition first manifested", - description=( - "Either the age of onset, range of approximate age or descriptive " - "string can be recorded. For conditions with multiple occurrences, " - "this describes the first known occurrence." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - - onsetString: fhirtypes.String = Field( - None, - alias="onsetString", - title="When condition first manifested", - description=( - "Either the age of onset, range of approximate age or descriptive " - "string can be recorded. For conditions with multiple occurrences, " - "this describes the first known occurrence." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e onset[x] - one_of_many="onset", - one_of_many_required=False, - ) - onsetString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_onsetString", title="Extension field for ``onsetString``." - ) - - outcome: fhirtypes.CodeableConceptType = Field( - None, - alias="outcome", - title="deceased | permanent disability | etc.", - description=( - "Indicates what happened following the condition. If the condition " - "resulted in death, deceased date is captured on the relation." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``FamilyMemberHistoryCondition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "outcome", - "contributedToDeath", - "onsetAge", - "onsetRange", - "onsetPeriod", - "onsetString", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3079( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "onset": ["onsetAge", "onsetPeriod", "onsetRange", "onsetString"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/fhirprimitiveextension.py b/fhir/resources/fhirprimitiveextension.py deleted file mode 100644 index 8f052e80..00000000 --- a/fhir/resources/fhirprimitiveextension.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -"""see: https://www.hl7.org/fhir/extensibility.html -Extensibility feature for FHIR Primitive Data Types. -""" -__author__ = "Md Nazrul Islam" - -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError - -from fhir.resources.core import fhirabstractmodel - -from . import fhirtypes - - -class FHIRPrimitiveExtension(fhirabstractmodel.FHIRAbstractModel): - """""" - - resource_type = Field("FHIRPrimitiveExtension", const=True) - - id: fhirtypes.String = Field( - None, - alias="id", - title="Type `String`", - description="Unique id for inter-element referencing", - # if property is element of this resource. - element_property=False, - ) - - extension: typing.List[fhirtypes.ExtensionType] = Field( - None, - alias="extension", - title="List of `Extension` items (represented as `dict` in JSON)", - description="Additional content defined by implementations", - # if property is element of this resource. - element_property=True, - ) - - @root_validator(pre=True) - def validate_extension_or_fhir_comment_required( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """Conditional Required Validation""" - errors = list() - extension = values.get("extension", None) - fhir_comments = values.get("fhir_comments", None) - - if extension is None and fhir_comments is None: - errors.append(ErrorWrapper(MissingError(), loc="extension")) - raise ValidationError(errors, cls) # type: ignore - - return values - - @classmethod - def elements_sequence(cls): - """returning all elements names from ``FHIRPrimitiveExtension`` according specification, - with preserving original sequence order. - """ - return ["id", "extension"] diff --git a/fhir/resources/fhirresourcemodel.py b/fhir/resources/fhirresourcemodel.py deleted file mode 100644 index c53959e5..00000000 --- a/fhir/resources/fhirresourcemodel.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -"""Base class for all FHIR elements. """ -from typing import Optional, Union - -from pydantic import Field - -from fhir.resources.core.fhirabstractmodel import FHIRAbstractModel - -from .fhirtypes import Id, String - - -class FHIRResourceModel(FHIRAbstractModel): - """Abstract base model class for all FHIR elements.""" - - resource_type: str = Field("FHIRAbstractResource", const=True) - id: Optional[Union[Id, String]] = None - - def relative_base(self): - """ """ - return self.resource_type - - def relative_path(self): - if self.id is None: - return self.relative_base() - return "{0}/{1}".format(self.relative_base(), self.id) diff --git a/fhir/resources/fhirtypes.py b/fhir/resources/fhirtypes.py deleted file mode 100644 index 61c9ef6f..00000000 --- a/fhir/resources/fhirtypes.py +++ /dev/null @@ -1,4073 +0,0 @@ -# _*_ coding: utf-8 _*_ -import datetime -import decimal -import re -from email.utils import formataddr, parseaddr -from typing import TYPE_CHECKING, Any, Dict, Optional, Pattern, Union -from uuid import UUID - -from pydantic import AnyUrl -from pydantic.errors import ConfigError, DateError, DateTimeError, TimeError -from pydantic.main import load_str_bytes -from pydantic.networks import validate_email -from pydantic.types import ( - ConstrainedBytes, - ConstrainedDecimal, - ConstrainedInt, - ConstrainedStr, -) -from pydantic.validators import bool_validator, parse_date, parse_datetime, parse_time - -from fhir.resources.core.fhirabstractmodel import FHIRAbstractModel - -from .fhirtypesvalidators import run_validator_for_fhir_type - -if TYPE_CHECKING: - from pydantic.types import CallableGenerator - from pydantic.fields import ModelField - from pydantic import BaseConfig - -__author__ = "Md Nazrul Islam" - -FHIR_DATE_PARTS = re.compile(r"(?P\d{4})(-(?P\d{2}))?(-(?P\d{2}))?$") -FHIR_PRIMITIVES = [ - "boolean", - "string", - "base64Binary", - "code", - "id", - "decimal", - "integer", - "unsignedInt", - "positiveInt", - "uri", - "oid", - "uuid", - "canonical", - "url", - "markdown", - "xhtml", - "date", - "dateTime", - "instant", - "time", -] - - -class Primitive: - """FHIR Primitive Data Type Base Class""" - - __fhir_release__: str = "R4" - __visit_name__: Optional[str] = None - regex: Optional[Pattern[str]] = None - - @classmethod - def is_primitive(cls) -> bool: - """ """ - return True - - @classmethod - def fhir_type_name(cls) -> Optional[str]: - """ """ - return cls.__visit_name__ - - -if TYPE_CHECKING: - Boolean = bool -else: - - class Boolean(int, Primitive): - """true | false""" - - regex = re.compile("true|false") - __visit_name__ = "boolean" - - @classmethod - def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None: - field_schema.update(type="boolean") - - @classmethod - def __get_validators__(cls) -> "CallableGenerator": - yield bool_validator - - @classmethod - def to_string(cls, value): - """ """ - assert isinstance(value, bool) - return value is True and "true" or "false" - - -class String(ConstrainedStr, Primitive): - """A sequence of Unicode characters - Note that strings SHALL NOT exceed 1MB (1024*1024 characters) in size. - Strings SHOULD not contain Unicode character points below 32, except for - u0009 (horizontal tab), u0010 (carriage return) and u0013 (line feed). - Leading and Trailing whitespace is allowed, but SHOULD be removed when using - the XML format. Note: This means that a string that consists only of whitespace - could be trimmed to nothing, which would be treated as an invalid element value. - Therefore strings SHOULD always contain non-whitespace content""" - - regex = re.compile(r"[ \r\n\t\S]+") - allow_empty_str = False - __visit_name__ = "string" - - @classmethod - def configure_empty_str(cls, allow: bool = None): - """About empty string - 1. https://bit.ly/3woGnFG - 2. https://github.com/nazrulworld/fhir.resources/issues/65#issuecomment-856693256 - There are a lot of valid discussion about accept empty string as String value but - it is cleared for us that according to FHIR Specification, empty string is not valid! - However in real use cases, we see empty string is coming other (when the task is related - to query data from other system) - - It is in your hand now, if you would like to allow empty string! by default - empty string is not accepted. - """ - if isinstance(allow, bool): - cls.allow_empty_str = allow - - @classmethod - def validate(cls, value: Union[str]) -> Union[str]: - if cls.allow_empty_str is True and value in ("", ""): - return value - # do the default things - return ConstrainedStr.validate.__func__(cls, value) # type: ignore - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, bytes): - value = value.decode() - elif value is None: - value = "" - assert isinstance(value, str) - return value - - -class Base64Binary(ConstrainedBytes, Primitive): - """A stream of bytes, base64 encoded (RFC 4648 )""" - - regex = re.compile(r"^(\s*([0-9a-zA-Z+=]){4}\s*)+$") - __visit_name__ = "base64Binary" - - @classmethod - def to_string(cls, value): - """ """ - assert isinstance(value, bytes) - return value.decode() - - -class Code(ConstrainedStr, Primitive): - """Indicates that the value is taken from a set of controlled - strings defined elsewhere (see Using codes for further discussion). - Technically, a code is restricted to a string which has at least one - character and no leading or trailing whitespace, and where there is - no whitespace other than single spaces in the contents""" - - regex = re.compile(r"^[^\s]+(\s[^\s]+)*$") - __visit_name__ = "code" - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, bytes): - value = value.decode() - assert isinstance(value, str) - return value - - -class Id(ConstrainedStr, Primitive): - """Any combination of upper- or lower-case ASCII letters - ('A'..'Z', and 'a'..'z', numerals ('0'..'9'), '-' and '.', - with a length limit of 64 characters. - (This might be an integer, an un-prefixed OID, UUID or any other identifier - pattern that meets these constraints.) - - But it is possible to change the default behaviour by using configure_constraints() - method! - """ - - regex = re.compile(r"^[A-Za-z0-9\-.]+$") - min_length = 1 - max_length = 64 - __visit_name__ = "id" - - @classmethod - def configure_constraints( - cls, min_length: int = None, max_length: int = None, regex: Pattern = None - ): - """There are a lots of discussion about ``Resource.Id`` length of value. - 1. https://bit.ly/360HksL - 2. https://bit.ly/3o1fZgl - We see there is some agreement and disagreement, because of that we decide to make - it more flexible. Now it is possible configure three types of constraints. - """ - if min_length is not None: - if min_length < 1: - raise ConfigError("Minimum length must be more than 0.") - _max_check = max_length or cls.max_length - if min_length > _max_check: - raise ConfigError( - "Minimum length value cannot be greater than maximum value." - ) - cls.min_length = min_length - - if max_length is not None: - if max_length < 1: - raise ConfigError("Maximum length must be more than 0.") - _min_check = min_length or cls.min_length - if max_length < _min_check: - raise ConfigError( - "Maximum length value cannot be less than minimum value." - ) - cls.max_length = max_length - - if regex is not None: - cls.regex = regex - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, bytes): - value = value.decode() - assert isinstance(value, str) - return value - - -class Decimal(ConstrainedDecimal, Primitive): - """Rational numbers that have a decimal representation. - See below about the precision of the number""" - - regex = re.compile(r"^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$") - __visit_name__ = "decimal" - - @classmethod - def to_string(cls, value): - """ """ - assert isinstance(value, decimal.Decimal) - return str(float(value)) - - -class Integer(ConstrainedInt, Primitive): - """A signed integer in the range −2,147,483,648..2,147,483,647 (32-bit; - for larger values, use decimal)""" - - regex = re.compile(r"^[0]|[-+]?[1-9][0-9]*$") - __visit_name__ = "integer" - - @classmethod - def to_string(cls, value): - """ """ - assert isinstance(value, int) - return str(value) - - -class UnsignedInt(ConstrainedInt, Primitive): - """Any non-negative integer in the range 0..2,147,483,647""" - - regex = re.compile(r"^[0]|([1-9][0-9]*)$") - __visit_name__ = "unsignedInt" - ge = 0 - - @classmethod - def to_string(cls, value): - """ """ - assert isinstance(value, int) - return str(value) - - -class PositiveInt(ConstrainedInt, Primitive): - """Any positive integer in the range 1..2,147,483,647""" - - regex = re.compile(r"^\+?[1-9][0-9]*$") - __visit_name__ = "positiveInt" - gt = 0 - - @classmethod - def to_string(cls, value): - """ """ - assert isinstance(value, int) - return str(value) - - -class Uri(ConstrainedStr, Primitive): - """A Uniform Resource Identifier Reference (RFC 3986 ). - Note: URIs are case sensitive. - For UUID (urn:uuid:53fefa32-fcbb-4ff8-8a92-55ee120877b7) - use all lowercase xs:anyURI A JSON string - a URI - Regex: \\S* (This regex is very permissive, but URIs must be valid. - Implementers are welcome to use more specific regex statements - for a URI in specific contexts) - URIs can be absolute or relative, and may have an optional fragment identifier - This data type can be bound to a ValueSet""" - - __visit_name__ = "uri" - regex = re.compile(r"\S*") - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, bytes): - value = value.decode() - assert isinstance(value, str) - return value - - -class Oid(ConstrainedStr, Primitive): - """An OID represented as a URI (RFC 3001 ); e.g. urn:oid:1.2.3.4.5""" - - __visit_name__ = "oid" - regex = re.compile(r"^urn:oid:[0-2](\.(0|[1-9][0-9]*))+$") - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, bytes): - value = value.decode() - assert isinstance(value, str) - return value - - -class Uuid(UUID, Primitive): - """A UUID (aka GUID) represented as a URI (RFC 4122 ); - e.g. urn:uuid:c757873d-ec9a-4326-a141-556f43239520""" - - __visit_name__ = "uuid" - regex = None - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, UUID): - value = f"urn:uuid:{value}" - assert isinstance(value, str) - return value - - -class Canonical(Uri): - """A URI that refers to a resource by its canonical URL (resources with a url property). - The canonical type differs from a uri in that it has special meaning in this specification, - and in that it may have a version appended, separated by a vertical bar (|). - Note that the type canonical is not used for the actual canonical URLs that are - the target of these references, but for the URIs that refer to them, and may have - the version suffix in them. Like other URIs, elements of type canonical may also have - #fragment references""" - - __visit_name__ = "canonical" - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, bytes): - value = value.decode() - assert isinstance(value, str) - return value - - -class Url(AnyUrl, Primitive): - """A Uniform Resource Locator (RFC 1738 ). - Note URLs are accessed directly using the specified protocol. - Common URL protocols are http{s}:, ftp:, mailto: and mllp:, - though many others are defined""" - - path_regex = re.compile(r"^/(?P[^\s?/]+)(/[^\s?/]+)*") - __visit_name__ = "url" - - @classmethod - def validate( # type: ignore - cls, value: str, field: "ModelField", config: "BaseConfig" - ) -> Union["AnyUrl", str]: - """ """ - if value.startswith("mailto:"): - schema = value[0:7] - email = value[7:] - realname = parseaddr(email)[0] - name, email = validate_email(email) - if realname: - email = formataddr((name, email)) - return schema + email - elif value.startswith("mllp:") or value.startswith("llp:"): - # xxx: find validation - return value - elif value in FHIR_PRIMITIVES: - # Extensions may contain a valueUrl for a primitive FHIR type - return value - - # we are allowing relative path - matched = cls.path_regex.match(value) - if matched is not None: - # @ToDo: required resource type validation? - # fx: resource type = matched.groupdict().get("resourceType") - return value - - return AnyUrl.validate(value, field, config) - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, bytes): - value = value.decode() - assert isinstance(value, str) - return value - - -class Markdown(ConstrainedStr, Primitive): - """A FHIR string (see above) that may contain markdown syntax for optional processing - by a markdown presentation engine, in the GFM extension of CommonMark format (see below)""" - - __visit_name__ = "markdown" - regex = re.compile(r"\s*(\S|\s)*") - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, bytes): - value = value.decode() - assert isinstance(value, str) - return value - - -class Xhtml(ConstrainedStr, Primitive): - __visit_name__ = "xhtml" - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, bytes): - value = value.decode() - assert isinstance(value, str) - return value - - -class Date(datetime.date, Primitive): - """A date, or partial date (e.g. just year or year + month) - as used in human communication. The format is YYYY, YYYY-MM, or YYYY-MM-DD, - e.g. 2018, 1973-06, or 1905-08-23. - There SHALL be no time zone. Dates SHALL be valid dates""" - - regex = re.compile( - r"([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|" - r"[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]" - r"[0-9]|3[0-1]))?)?" - ) - __visit_name__ = "date" - - @classmethod - def __get_validators__(cls) -> "CallableGenerator": - - yield cls.validate - - @classmethod - def validate( - cls, value: Union[datetime.date, str, bytes, int, float] - ) -> Union[datetime.date, str]: - """ """ - if not isinstance(value, str): - # default handler - return parse_date(value) - - match = FHIR_DATE_PARTS.match(value) - - if not match: - if not cls.regex.match(value): - raise DateError() - elif not match.groupdict().get("day"): - if match.groupdict().get("month") and int(match.groupdict()["month"]) > 12: - raise DateError() - # we keep original - return value - return parse_date(value) - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, (datetime.date, datetime.time, datetime.datetime)): - value = value.isoformat() - assert isinstance(value, str) - return value - - -class DateTime(datetime.datetime, Primitive): - """A date, date-time or partial date (e.g. just year or year + month) as used - in human communication. The format is YYYY, YYYY-MM, YYYY-MM-DD or - YYYY-MM-DDThh:mm:ss+zz:zz, e.g. 2018, 1973-06, 1905-08-23, - 2015-02-07T13:28:17-05:00 or 2017-01-01T00:00:00.000Z. - If hours and minutes are specified, a time zone SHALL be populated. - Seconds must be provided due to schema type constraints but may be - zero-filled and may be ignored at receiver discretion. - Dates SHALL be valid dates. The time "24:00" is not allowed. - Leap Seconds are allowed - see below""" - - regex = re.compile( - r"([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|" - r"[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|" - r"3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|" - r"60)(\.[0-9]+)?(Z|([+\-])((0[0-9]|" - r"1[0-3]):[0-5][0-9]|14:00)))?)?)?" - ) - __visit_name__ = "dateTime" - - @classmethod - def __get_validators__(cls) -> "CallableGenerator": - - yield cls.validate - - @classmethod - def validate( - cls, value: Union[datetime.date, datetime.datetime, str, bytes, int, float] - ) -> Union[datetime.datetime, datetime.date, str]: - """ """ - if isinstance(value, datetime.date): - return value - - if not isinstance(value, str): - # default handler - return parse_datetime(value) - match = FHIR_DATE_PARTS.match(value) - if match: - if ( - match.groupdict().get("year") - and match.groupdict().get("month") - and match.groupdict().get("day") - ): - return parse_date(value) - elif match.groupdict().get("year") and match.groupdict().get("month"): - if int(match.groupdict()["month"]) > 12: - raise DateError() - # we don't want to loose actual information, so keep as string - return value - if not cls.regex.match(value): - raise DateTimeError() - - return parse_datetime(value) - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, (datetime.date, datetime.time, datetime.datetime)): - value = value.isoformat() - assert isinstance(value, str) - return value - - -class Instant(datetime.datetime, Primitive): - """An instant in time in the format YYYY-MM-DDThh:mm:ss.sss+zz:zz - (e.g. 2015-02-07T13:28:17.239+02:00 or 2017-01-01T00:00:00Z). - The time SHALL specified at least to the second and SHALL include a time zone. - Note: This is intended for when precisely observed times are required - (typically system logs etc.), and not human-reported times - for those, - use date or dateTime (which can be as precise as instant, - but is not required to be). instant is a more constrained dateTime - - Note: This type is for system times, not human times (see date and dateTime below).""" - - regex = re.compile( - r"([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|" - r"[1-9]000)-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|" - r"3[0-1])T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]" - r"|60)(\.[0-9]+)?(Z|([+\-])((0[0-9]|" - r"1[0-3]):[0-5][0-9]|14:00))" - ) - __visit_name__ = "instant" - - @classmethod - def __get_validators__(cls) -> "CallableGenerator": - - yield cls.validate - - @classmethod - def validate(cls, value): - """ """ - if isinstance(value, str): - if not cls.regex.match(value): - raise DateTimeError() - return parse_datetime(value) - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, (datetime.date, datetime.time, datetime.datetime)): - value = value.isoformat() - assert isinstance(value, str) - return value - - -class Time(datetime.time, Primitive): - """A time during the day, in the format hh:mm:ss. - There is no date specified. Seconds must be provided due - to schema type constraints but may be zero-filled and may - be ignored at receiver discretion. - The time "24:00" SHALL NOT be used. A time zone SHALL NOT be present. - Times can be converted to a Duration since midnight.""" - - regex = re.compile(r"([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\.[0-9]+)?") - __visit_name__ = "time" - - @classmethod - def __get_validators__(cls) -> "CallableGenerator": - - yield cls.validate - - @classmethod - def validate(cls, value): - """ """ - if isinstance(value, str): - if not cls.regex.match(value): - raise TimeError() - - return parse_time(value) - - @classmethod - def to_string(cls, value): - """ """ - if isinstance(value, (datetime.date, datetime.time, datetime.datetime)): - value = value.isoformat() - assert isinstance(value, str) - return value - - -def get_fhir_type_class(model_name): - try: - return globals()[model_name + "Type"] - except KeyError: - raise LookupError(f"'{__name__}.{model_name}Type' doesnt found.") - - -class AbstractType(dict): - """ """ - - __fhir_release__: str = "R4" - __resource_type__: str = ... # type: ignore - - @classmethod - def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None: - field_schema.update(type=cls.__resource_type__) - - @classmethod - def __get_validators__(cls) -> "CallableGenerator": - from . import fhirtypesvalidators - - yield getattr(fhirtypesvalidators, cls.__resource_type__.lower() + "_validator") - - @classmethod - def is_primitive(cls) -> bool: - """ """ - return False - - @classmethod - def fhir_type_name(cls) -> str: - """ """ - return cls.__resource_type__ - - -class FHIRPrimitiveExtensionType(AbstractType): - """ """ - - __resource_type__ = "FHIRPrimitiveExtension" - - -class AbstractBaseType(dict): - """ """ - - __fhir_release__: str = "R4" - __resource_type__: str = ... # type: ignore - - @classmethod - def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None: - field_schema.update(type=cls.__resource_type__) - - @classmethod - def __get_validators__(cls) -> "CallableGenerator": - yield cls.validate - - @classmethod - def validate(cls, v, values, config, field): - """ """ - if isinstance(v, (bytes, str)): - input_data = load_str_bytes(v) - resource_type = input_data.get("resourceType", None) - elif isinstance(v, FHIRAbstractModel): - resource_type = v.resource_type - else: - resource_type = v.get("resourceType", None) - - if resource_type is None or resource_type == cls.__resource_type__: - from . import fhirtypesvalidators - - v = getattr( - fhirtypesvalidators, cls.__resource_type__.lower() + "_validator" - )(v) - return v - - type_class = get_fhir_type_class(resource_type) - v = run_validator_for_fhir_type(type_class, v, values, config, field) - return v - - @classmethod - def is_primitive(cls) -> bool: - """ """ - return False - - @classmethod - def fhir_type_name(cls) -> str: - """ """ - return cls.__resource_type__ - - -class ElementType(AbstractBaseType): - """ """ - - __resource_type__ = "Element" - - -class ResourceType(AbstractBaseType): - """ """ - - __resource_type__ = "Resource" - - -class AccountType(AbstractType): - __resource_type__ = "Account" - - -class AccountCoverageType(AbstractType): - __resource_type__ = "AccountCoverage" - - -class AccountGuarantorType(AbstractType): - __resource_type__ = "AccountGuarantor" - - -class ActivityDefinitionType(AbstractType): - __resource_type__ = "ActivityDefinition" - - -class ActivityDefinitionDynamicValueType(AbstractType): - __resource_type__ = "ActivityDefinitionDynamicValue" - - -class ActivityDefinitionParticipantType(AbstractType): - __resource_type__ = "ActivityDefinitionParticipant" - - -class AddressType(AbstractType): - __resource_type__ = "Address" - - -class AdverseEventType(AbstractType): - __resource_type__ = "AdverseEvent" - - -class AdverseEventSuspectEntityType(AbstractType): - __resource_type__ = "AdverseEventSuspectEntity" - - -class AdverseEventSuspectEntityCausalityType(AbstractType): - __resource_type__ = "AdverseEventSuspectEntityCausality" - - -class AgeType(AbstractType): - __resource_type__ = "Age" - - -class AllergyIntoleranceType(AbstractType): - __resource_type__ = "AllergyIntolerance" - - -class AllergyIntoleranceReactionType(AbstractType): - __resource_type__ = "AllergyIntoleranceReaction" - - -class AnnotationType(AbstractType): - __resource_type__ = "Annotation" - - -class AppointmentType(AbstractType): - __resource_type__ = "Appointment" - - -class AppointmentParticipantType(AbstractType): - __resource_type__ = "AppointmentParticipant" - - -class AppointmentResponseType(AbstractType): - __resource_type__ = "AppointmentResponse" - - -class AttachmentType(AbstractType): - __resource_type__ = "Attachment" - - -class AuditEventType(AbstractType): - __resource_type__ = "AuditEvent" - - -class AuditEventAgentType(AbstractType): - __resource_type__ = "AuditEventAgent" - - -class AuditEventAgentNetworkType(AbstractType): - __resource_type__ = "AuditEventAgentNetwork" - - -class AuditEventEntityType(AbstractType): - __resource_type__ = "AuditEventEntity" - - -class AuditEventEntityDetailType(AbstractType): - __resource_type__ = "AuditEventEntityDetail" - - -class AuditEventSourceType(AbstractType): - __resource_type__ = "AuditEventSource" - - -class BackboneElementType(AbstractType): - __resource_type__ = "BackboneElement" - - -class BasicType(AbstractType): - __resource_type__ = "Basic" - - -class BinaryType(AbstractType): - __resource_type__ = "Binary" - - -class BiologicallyDerivedProductType(AbstractType): - __resource_type__ = "BiologicallyDerivedProduct" - - -class BiologicallyDerivedProductCollectionType(AbstractType): - __resource_type__ = "BiologicallyDerivedProductCollection" - - -class BiologicallyDerivedProductManipulationType(AbstractType): - __resource_type__ = "BiologicallyDerivedProductManipulation" - - -class BiologicallyDerivedProductProcessingType(AbstractType): - __resource_type__ = "BiologicallyDerivedProductProcessing" - - -class BiologicallyDerivedProductStorageType(AbstractType): - __resource_type__ = "BiologicallyDerivedProductStorage" - - -class BodyStructureType(AbstractType): - __resource_type__ = "BodyStructure" - - -class BundleType(AbstractType): - __resource_type__ = "Bundle" - - -class BundleEntryType(AbstractType): - __resource_type__ = "BundleEntry" - - -class BundleEntryRequestType(AbstractType): - __resource_type__ = "BundleEntryRequest" - - -class BundleEntryResponseType(AbstractType): - __resource_type__ = "BundleEntryResponse" - - -class BundleEntrySearchType(AbstractType): - __resource_type__ = "BundleEntrySearch" - - -class BundleLinkType(AbstractType): - __resource_type__ = "BundleLink" - - -class CapabilityStatementType(AbstractType): - __resource_type__ = "CapabilityStatement" - - -class CapabilityStatementDocumentType(AbstractType): - __resource_type__ = "CapabilityStatementDocument" - - -class CapabilityStatementImplementationType(AbstractType): - __resource_type__ = "CapabilityStatementImplementation" - - -class CapabilityStatementMessagingType(AbstractType): - __resource_type__ = "CapabilityStatementMessaging" - - -class CapabilityStatementMessagingEndpointType(AbstractType): - __resource_type__ = "CapabilityStatementMessagingEndpoint" - - -class CapabilityStatementMessagingSupportedMessageType(AbstractType): - __resource_type__ = "CapabilityStatementMessagingSupportedMessage" - - -class CapabilityStatementRestType(AbstractType): - __resource_type__ = "CapabilityStatementRest" - - -class CapabilityStatementRestInteractionType(AbstractType): - __resource_type__ = "CapabilityStatementRestInteraction" - - -class CapabilityStatementRestResourceType(AbstractType): - __resource_type__ = "CapabilityStatementRestResource" - - -class CapabilityStatementRestResourceInteractionType(AbstractType): - __resource_type__ = "CapabilityStatementRestResourceInteraction" - - -class CapabilityStatementRestResourceOperationType(AbstractType): - __resource_type__ = "CapabilityStatementRestResourceOperation" - - -class CapabilityStatementRestResourceSearchParamType(AbstractType): - __resource_type__ = "CapabilityStatementRestResourceSearchParam" - - -class CapabilityStatementRestSecurityType(AbstractType): - __resource_type__ = "CapabilityStatementRestSecurity" - - -class CapabilityStatementSoftwareType(AbstractType): - __resource_type__ = "CapabilityStatementSoftware" - - -class CarePlanType(AbstractType): - __resource_type__ = "CarePlan" - - -class CarePlanActivityType(AbstractType): - __resource_type__ = "CarePlanActivity" - - -class CarePlanActivityDetailType(AbstractType): - __resource_type__ = "CarePlanActivityDetail" - - -class CareTeamType(AbstractType): - __resource_type__ = "CareTeam" - - -class CareTeamParticipantType(AbstractType): - __resource_type__ = "CareTeamParticipant" - - -class CatalogEntryType(AbstractType): - __resource_type__ = "CatalogEntry" - - -class CatalogEntryRelatedEntryType(AbstractType): - __resource_type__ = "CatalogEntryRelatedEntry" - - -class ChargeItemType(AbstractType): - __resource_type__ = "ChargeItem" - - -class ChargeItemDefinitionType(AbstractType): - __resource_type__ = "ChargeItemDefinition" - - -class ChargeItemDefinitionApplicabilityType(AbstractType): - __resource_type__ = "ChargeItemDefinitionApplicability" - - -class ChargeItemDefinitionPropertyGroupType(AbstractType): - __resource_type__ = "ChargeItemDefinitionPropertyGroup" - - -class ChargeItemDefinitionPropertyGroupPriceComponentType(AbstractType): - __resource_type__ = "ChargeItemDefinitionPropertyGroupPriceComponent" - - -class ChargeItemPerformerType(AbstractType): - __resource_type__ = "ChargeItemPerformer" - - -class ClaimType(AbstractType): - __resource_type__ = "Claim" - - -class ClaimAccidentType(AbstractType): - __resource_type__ = "ClaimAccident" - - -class ClaimCareTeamType(AbstractType): - __resource_type__ = "ClaimCareTeam" - - -class ClaimDiagnosisType(AbstractType): - __resource_type__ = "ClaimDiagnosis" - - -class ClaimInsuranceType(AbstractType): - __resource_type__ = "ClaimInsurance" - - -class ClaimItemType(AbstractType): - __resource_type__ = "ClaimItem" - - -class ClaimItemDetailType(AbstractType): - __resource_type__ = "ClaimItemDetail" - - -class ClaimItemDetailSubDetailType(AbstractType): - __resource_type__ = "ClaimItemDetailSubDetail" - - -class ClaimPayeeType(AbstractType): - __resource_type__ = "ClaimPayee" - - -class ClaimProcedureType(AbstractType): - __resource_type__ = "ClaimProcedure" - - -class ClaimRelatedType(AbstractType): - __resource_type__ = "ClaimRelated" - - -class ClaimResponseType(AbstractType): - __resource_type__ = "ClaimResponse" - - -class ClaimResponseAddItemType(AbstractType): - __resource_type__ = "ClaimResponseAddItem" - - -class ClaimResponseAddItemDetailType(AbstractType): - __resource_type__ = "ClaimResponseAddItemDetail" - - -class ClaimResponseAddItemDetailSubDetailType(AbstractType): - __resource_type__ = "ClaimResponseAddItemDetailSubDetail" - - -class ClaimResponseErrorType(AbstractType): - __resource_type__ = "ClaimResponseError" - - -class ClaimResponseInsuranceType(AbstractType): - __resource_type__ = "ClaimResponseInsurance" - - -class ClaimResponseItemType(AbstractType): - __resource_type__ = "ClaimResponseItem" - - -class ClaimResponseItemAdjudicationType(AbstractType): - __resource_type__ = "ClaimResponseItemAdjudication" - - -class ClaimResponseItemDetailType(AbstractType): - __resource_type__ = "ClaimResponseItemDetail" - - -class ClaimResponseItemDetailSubDetailType(AbstractType): - __resource_type__ = "ClaimResponseItemDetailSubDetail" - - -class ClaimResponsePaymentType(AbstractType): - __resource_type__ = "ClaimResponsePayment" - - -class ClaimResponseProcessNoteType(AbstractType): - __resource_type__ = "ClaimResponseProcessNote" - - -class ClaimResponseTotalType(AbstractType): - __resource_type__ = "ClaimResponseTotal" - - -class ClaimSupportingInfoType(AbstractType): - __resource_type__ = "ClaimSupportingInfo" - - -class ClinicalImpressionType(AbstractType): - __resource_type__ = "ClinicalImpression" - - -class ClinicalImpressionFindingType(AbstractType): - __resource_type__ = "ClinicalImpressionFinding" - - -class ClinicalImpressionInvestigationType(AbstractType): - __resource_type__ = "ClinicalImpressionInvestigation" - - -class CodeSystemType(AbstractType): - __resource_type__ = "CodeSystem" - - -class CodeSystemConceptType(AbstractType): - __resource_type__ = "CodeSystemConcept" - - -class CodeSystemConceptDesignationType(AbstractType): - __resource_type__ = "CodeSystemConceptDesignation" - - -class CodeSystemConceptPropertyType(AbstractType): - __resource_type__ = "CodeSystemConceptProperty" - - -class CodeSystemFilterType(AbstractType): - __resource_type__ = "CodeSystemFilter" - - -class CodeSystemPropertyType(AbstractType): - __resource_type__ = "CodeSystemProperty" - - -class CodeableConceptType(AbstractType): - __resource_type__ = "CodeableConcept" - - -class CodingType(AbstractType): - __resource_type__ = "Coding" - - -class CommunicationType(AbstractType): - __resource_type__ = "Communication" - - -class CommunicationPayloadType(AbstractType): - __resource_type__ = "CommunicationPayload" - - -class CommunicationRequestType(AbstractType): - __resource_type__ = "CommunicationRequest" - - -class CommunicationRequestPayloadType(AbstractType): - __resource_type__ = "CommunicationRequestPayload" - - -class CompartmentDefinitionType(AbstractType): - __resource_type__ = "CompartmentDefinition" - - -class CompartmentDefinitionResourceType(AbstractType): - __resource_type__ = "CompartmentDefinitionResource" - - -class CompositionType(AbstractType): - __resource_type__ = "Composition" - - -class CompositionAttesterType(AbstractType): - __resource_type__ = "CompositionAttester" - - -class CompositionEventType(AbstractType): - __resource_type__ = "CompositionEvent" - - -class CompositionRelatesToType(AbstractType): - __resource_type__ = "CompositionRelatesTo" - - -class CompositionSectionType(AbstractType): - __resource_type__ = "CompositionSection" - - -class ConceptMapType(AbstractType): - __resource_type__ = "ConceptMap" - - -class ConceptMapGroupType(AbstractType): - __resource_type__ = "ConceptMapGroup" - - -class ConceptMapGroupElementType(AbstractType): - __resource_type__ = "ConceptMapGroupElement" - - -class ConceptMapGroupElementTargetType(AbstractType): - __resource_type__ = "ConceptMapGroupElementTarget" - - -class ConceptMapGroupElementTargetDependsOnType(AbstractType): - __resource_type__ = "ConceptMapGroupElementTargetDependsOn" - - -class ConceptMapGroupUnmappedType(AbstractType): - __resource_type__ = "ConceptMapGroupUnmapped" - - -class ConditionType(AbstractType): - __resource_type__ = "Condition" - - -class ConditionEvidenceType(AbstractType): - __resource_type__ = "ConditionEvidence" - - -class ConditionStageType(AbstractType): - __resource_type__ = "ConditionStage" - - -class ConsentType(AbstractType): - __resource_type__ = "Consent" - - -class ConsentPolicyType(AbstractType): - __resource_type__ = "ConsentPolicy" - - -class ConsentProvisionType(AbstractType): - __resource_type__ = "ConsentProvision" - - -class ConsentProvisionActorType(AbstractType): - __resource_type__ = "ConsentProvisionActor" - - -class ConsentProvisionDataType(AbstractType): - __resource_type__ = "ConsentProvisionData" - - -class ConsentVerificationType(AbstractType): - __resource_type__ = "ConsentVerification" - - -class ContactDetailType(AbstractType): - __resource_type__ = "ContactDetail" - - -class ContactPointType(AbstractType): - __resource_type__ = "ContactPoint" - - -class ContractType(AbstractType): - __resource_type__ = "Contract" - - -class ContractContentDefinitionType(AbstractType): - __resource_type__ = "ContractContentDefinition" - - -class ContractFriendlyType(AbstractType): - __resource_type__ = "ContractFriendly" - - -class ContractLegalType(AbstractType): - __resource_type__ = "ContractLegal" - - -class ContractRuleType(AbstractType): - __resource_type__ = "ContractRule" - - -class ContractSignerType(AbstractType): - __resource_type__ = "ContractSigner" - - -class ContractTermType(AbstractType): - __resource_type__ = "ContractTerm" - - -class ContractTermActionType(AbstractType): - __resource_type__ = "ContractTermAction" - - -class ContractTermActionSubjectType(AbstractType): - __resource_type__ = "ContractTermActionSubject" - - -class ContractTermAssetType(AbstractType): - __resource_type__ = "ContractTermAsset" - - -class ContractTermAssetContextType(AbstractType): - __resource_type__ = "ContractTermAssetContext" - - -class ContractTermAssetValuedItemType(AbstractType): - __resource_type__ = "ContractTermAssetValuedItem" - - -class ContractTermOfferType(AbstractType): - __resource_type__ = "ContractTermOffer" - - -class ContractTermOfferAnswerType(AbstractType): - __resource_type__ = "ContractTermOfferAnswer" - - -class ContractTermOfferPartyType(AbstractType): - __resource_type__ = "ContractTermOfferParty" - - -class ContractTermSecurityLabelType(AbstractType): - __resource_type__ = "ContractTermSecurityLabel" - - -class ContributorType(AbstractType): - __resource_type__ = "Contributor" - - -class CountType(AbstractType): - __resource_type__ = "Count" - - -class CoverageType(AbstractType): - __resource_type__ = "Coverage" - - -class CoverageClassType(AbstractType): - __resource_type__ = "CoverageClass" - - -class CoverageCostToBeneficiaryType(AbstractType): - __resource_type__ = "CoverageCostToBeneficiary" - - -class CoverageCostToBeneficiaryExceptionType(AbstractType): - __resource_type__ = "CoverageCostToBeneficiaryException" - - -class CoverageEligibilityRequestType(AbstractType): - __resource_type__ = "CoverageEligibilityRequest" - - -class CoverageEligibilityRequestInsuranceType(AbstractType): - __resource_type__ = "CoverageEligibilityRequestInsurance" - - -class CoverageEligibilityRequestItemType(AbstractType): - __resource_type__ = "CoverageEligibilityRequestItem" - - -class CoverageEligibilityRequestItemDiagnosisType(AbstractType): - __resource_type__ = "CoverageEligibilityRequestItemDiagnosis" - - -class CoverageEligibilityRequestSupportingInfoType(AbstractType): - __resource_type__ = "CoverageEligibilityRequestSupportingInfo" - - -class CoverageEligibilityResponseType(AbstractType): - __resource_type__ = "CoverageEligibilityResponse" - - -class CoverageEligibilityResponseErrorType(AbstractType): - __resource_type__ = "CoverageEligibilityResponseError" - - -class CoverageEligibilityResponseInsuranceType(AbstractType): - __resource_type__ = "CoverageEligibilityResponseInsurance" - - -class CoverageEligibilityResponseInsuranceItemType(AbstractType): - __resource_type__ = "CoverageEligibilityResponseInsuranceItem" - - -class CoverageEligibilityResponseInsuranceItemBenefitType(AbstractType): - __resource_type__ = "CoverageEligibilityResponseInsuranceItemBenefit" - - -class DataRequirementType(AbstractType): - __resource_type__ = "DataRequirement" - - -class DataRequirementCodeFilterType(AbstractType): - __resource_type__ = "DataRequirementCodeFilter" - - -class DataRequirementDateFilterType(AbstractType): - __resource_type__ = "DataRequirementDateFilter" - - -class DataRequirementSortType(AbstractType): - __resource_type__ = "DataRequirementSort" - - -class DetectedIssueType(AbstractType): - __resource_type__ = "DetectedIssue" - - -class DetectedIssueEvidenceType(AbstractType): - __resource_type__ = "DetectedIssueEvidence" - - -class DetectedIssueMitigationType(AbstractType): - __resource_type__ = "DetectedIssueMitigation" - - -class DeviceType(AbstractType): - __resource_type__ = "Device" - - -class DeviceDefinitionType(AbstractType): - __resource_type__ = "DeviceDefinition" - - -class DeviceDefinitionCapabilityType(AbstractType): - __resource_type__ = "DeviceDefinitionCapability" - - -class DeviceDefinitionDeviceNameType(AbstractType): - __resource_type__ = "DeviceDefinitionDeviceName" - - -class DeviceDefinitionMaterialType(AbstractType): - __resource_type__ = "DeviceDefinitionMaterial" - - -class DeviceDefinitionPropertyType(AbstractType): - __resource_type__ = "DeviceDefinitionProperty" - - -class DeviceDefinitionSpecializationType(AbstractType): - __resource_type__ = "DeviceDefinitionSpecialization" - - -class DeviceDefinitionUdiDeviceIdentifierType(AbstractType): - __resource_type__ = "DeviceDefinitionUdiDeviceIdentifier" - - -class DeviceDeviceNameType(AbstractType): - __resource_type__ = "DeviceDeviceName" - - -class DeviceMetricType(AbstractType): - __resource_type__ = "DeviceMetric" - - -class DeviceMetricCalibrationType(AbstractType): - __resource_type__ = "DeviceMetricCalibration" - - -class DevicePropertyType(AbstractType): - __resource_type__ = "DeviceProperty" - - -class DeviceRequestType(AbstractType): - __resource_type__ = "DeviceRequest" - - -class DeviceRequestParameterType(AbstractType): - __resource_type__ = "DeviceRequestParameter" - - -class DeviceSpecializationType(AbstractType): - __resource_type__ = "DeviceSpecialization" - - -class DeviceUdiCarrierType(AbstractType): - __resource_type__ = "DeviceUdiCarrier" - - -class DeviceUseStatementType(AbstractType): - __resource_type__ = "DeviceUseStatement" - - -class DeviceVersionType(AbstractType): - __resource_type__ = "DeviceVersion" - - -class DiagnosticReportType(AbstractType): - __resource_type__ = "DiagnosticReport" - - -class DiagnosticReportMediaType(AbstractType): - __resource_type__ = "DiagnosticReportMedia" - - -class DistanceType(AbstractType): - __resource_type__ = "Distance" - - -class DocumentManifestType(AbstractType): - __resource_type__ = "DocumentManifest" - - -class DocumentManifestRelatedType(AbstractType): - __resource_type__ = "DocumentManifestRelated" - - -class DocumentReferenceType(AbstractType): - __resource_type__ = "DocumentReference" - - -class DocumentReferenceContentType(AbstractType): - __resource_type__ = "DocumentReferenceContent" - - -class DocumentReferenceContextType(AbstractType): - __resource_type__ = "DocumentReferenceContext" - - -class DocumentReferenceRelatesToType(AbstractType): - __resource_type__ = "DocumentReferenceRelatesTo" - - -class DomainResourceType(AbstractType): - __resource_type__ = "DomainResource" - - -class DosageType(AbstractType): - __resource_type__ = "Dosage" - - -class DosageDoseAndRateType(AbstractType): - __resource_type__ = "DosageDoseAndRate" - - -class DurationType(AbstractType): - __resource_type__ = "Duration" - - -class EffectEvidenceSynthesisType(AbstractType): - __resource_type__ = "EffectEvidenceSynthesis" - - -class EffectEvidenceSynthesisCertaintyType(AbstractType): - __resource_type__ = "EffectEvidenceSynthesisCertainty" - - -class EffectEvidenceSynthesisCertaintyCertaintySubcomponentType(AbstractType): - __resource_type__ = "EffectEvidenceSynthesisCertaintyCertaintySubcomponent" - - -class EffectEvidenceSynthesisEffectEstimateType(AbstractType): - __resource_type__ = "EffectEvidenceSynthesisEffectEstimate" - - -class EffectEvidenceSynthesisEffectEstimatePrecisionEstimateType(AbstractType): - __resource_type__ = "EffectEvidenceSynthesisEffectEstimatePrecisionEstimate" - - -class EffectEvidenceSynthesisResultsByExposureType(AbstractType): - __resource_type__ = "EffectEvidenceSynthesisResultsByExposure" - - -class EffectEvidenceSynthesisSampleSizeType(AbstractType): - __resource_type__ = "EffectEvidenceSynthesisSampleSize" - - -class ElementDefinitionType(AbstractType): - __resource_type__ = "ElementDefinition" - - -class ElementDefinitionBaseType(AbstractType): - __resource_type__ = "ElementDefinitionBase" - - -class ElementDefinitionBindingType(AbstractType): - __resource_type__ = "ElementDefinitionBinding" - - -class ElementDefinitionConstraintType(AbstractType): - __resource_type__ = "ElementDefinitionConstraint" - - -class ElementDefinitionExampleType(AbstractType): - __resource_type__ = "ElementDefinitionExample" - - -class ElementDefinitionMappingType(AbstractType): - __resource_type__ = "ElementDefinitionMapping" - - -class ElementDefinitionSlicingType(AbstractType): - __resource_type__ = "ElementDefinitionSlicing" - - -class ElementDefinitionSlicingDiscriminatorType(AbstractType): - __resource_type__ = "ElementDefinitionSlicingDiscriminator" - - -class ElementDefinitionTypeType(AbstractType): - __resource_type__ = "ElementDefinitionType" - - -class EncounterType(AbstractType): - __resource_type__ = "Encounter" - - -class EncounterClassHistoryType(AbstractType): - __resource_type__ = "EncounterClassHistory" - - -class EncounterDiagnosisType(AbstractType): - __resource_type__ = "EncounterDiagnosis" - - -class EncounterHospitalizationType(AbstractType): - __resource_type__ = "EncounterHospitalization" - - -class EncounterLocationType(AbstractType): - __resource_type__ = "EncounterLocation" - - -class EncounterParticipantType(AbstractType): - __resource_type__ = "EncounterParticipant" - - -class EncounterStatusHistoryType(AbstractType): - __resource_type__ = "EncounterStatusHistory" - - -class EndpointType(AbstractType): - __resource_type__ = "Endpoint" - - -class EnrollmentRequestType(AbstractType): - __resource_type__ = "EnrollmentRequest" - - -class EnrollmentResponseType(AbstractType): - __resource_type__ = "EnrollmentResponse" - - -class EpisodeOfCareType(AbstractType): - __resource_type__ = "EpisodeOfCare" - - -class EpisodeOfCareDiagnosisType(AbstractType): - __resource_type__ = "EpisodeOfCareDiagnosis" - - -class EpisodeOfCareStatusHistoryType(AbstractType): - __resource_type__ = "EpisodeOfCareStatusHistory" - - -class EventDefinitionType(AbstractType): - __resource_type__ = "EventDefinition" - - -class EvidenceType(AbstractType): - __resource_type__ = "Evidence" - - -class EvidenceVariableType(AbstractType): - __resource_type__ = "EvidenceVariable" - - -class EvidenceVariableCharacteristicType(AbstractType): - __resource_type__ = "EvidenceVariableCharacteristic" - - -class ExampleScenarioType(AbstractType): - __resource_type__ = "ExampleScenario" - - -class ExampleScenarioActorType(AbstractType): - __resource_type__ = "ExampleScenarioActor" - - -class ExampleScenarioInstanceType(AbstractType): - __resource_type__ = "ExampleScenarioInstance" - - -class ExampleScenarioInstanceContainedInstanceType(AbstractType): - __resource_type__ = "ExampleScenarioInstanceContainedInstance" - - -class ExampleScenarioInstanceVersionType(AbstractType): - __resource_type__ = "ExampleScenarioInstanceVersion" - - -class ExampleScenarioProcessType(AbstractType): - __resource_type__ = "ExampleScenarioProcess" - - -class ExampleScenarioProcessStepType(AbstractType): - __resource_type__ = "ExampleScenarioProcessStep" - - -class ExampleScenarioProcessStepAlternativeType(AbstractType): - __resource_type__ = "ExampleScenarioProcessStepAlternative" - - -class ExampleScenarioProcessStepOperationType(AbstractType): - __resource_type__ = "ExampleScenarioProcessStepOperation" - - -class ExplanationOfBenefitType(AbstractType): - __resource_type__ = "ExplanationOfBenefit" - - -class ExplanationOfBenefitAccidentType(AbstractType): - __resource_type__ = "ExplanationOfBenefitAccident" - - -class ExplanationOfBenefitAddItemType(AbstractType): - __resource_type__ = "ExplanationOfBenefitAddItem" - - -class ExplanationOfBenefitAddItemDetailType(AbstractType): - __resource_type__ = "ExplanationOfBenefitAddItemDetail" - - -class ExplanationOfBenefitAddItemDetailSubDetailType(AbstractType): - __resource_type__ = "ExplanationOfBenefitAddItemDetailSubDetail" - - -class ExplanationOfBenefitBenefitBalanceType(AbstractType): - __resource_type__ = "ExplanationOfBenefitBenefitBalance" - - -class ExplanationOfBenefitBenefitBalanceFinancialType(AbstractType): - __resource_type__ = "ExplanationOfBenefitBenefitBalanceFinancial" - - -class ExplanationOfBenefitCareTeamType(AbstractType): - __resource_type__ = "ExplanationOfBenefitCareTeam" - - -class ExplanationOfBenefitDiagnosisType(AbstractType): - __resource_type__ = "ExplanationOfBenefitDiagnosis" - - -class ExplanationOfBenefitInsuranceType(AbstractType): - __resource_type__ = "ExplanationOfBenefitInsurance" - - -class ExplanationOfBenefitItemType(AbstractType): - __resource_type__ = "ExplanationOfBenefitItem" - - -class ExplanationOfBenefitItemAdjudicationType(AbstractType): - __resource_type__ = "ExplanationOfBenefitItemAdjudication" - - -class ExplanationOfBenefitItemDetailType(AbstractType): - __resource_type__ = "ExplanationOfBenefitItemDetail" - - -class ExplanationOfBenefitItemDetailSubDetailType(AbstractType): - __resource_type__ = "ExplanationOfBenefitItemDetailSubDetail" - - -class ExplanationOfBenefitPayeeType(AbstractType): - __resource_type__ = "ExplanationOfBenefitPayee" - - -class ExplanationOfBenefitPaymentType(AbstractType): - __resource_type__ = "ExplanationOfBenefitPayment" - - -class ExplanationOfBenefitProcedureType(AbstractType): - __resource_type__ = "ExplanationOfBenefitProcedure" - - -class ExplanationOfBenefitProcessNoteType(AbstractType): - __resource_type__ = "ExplanationOfBenefitProcessNote" - - -class ExplanationOfBenefitRelatedType(AbstractType): - __resource_type__ = "ExplanationOfBenefitRelated" - - -class ExplanationOfBenefitSupportingInfoType(AbstractType): - __resource_type__ = "ExplanationOfBenefitSupportingInfo" - - -class ExplanationOfBenefitTotalType(AbstractType): - __resource_type__ = "ExplanationOfBenefitTotal" - - -class ExpressionType(AbstractType): - __resource_type__ = "Expression" - - -class ExtensionType(AbstractType): - __resource_type__ = "Extension" - - -class FamilyMemberHistoryType(AbstractType): - __resource_type__ = "FamilyMemberHistory" - - -class FamilyMemberHistoryConditionType(AbstractType): - __resource_type__ = "FamilyMemberHistoryCondition" - - -class FlagType(AbstractType): - __resource_type__ = "Flag" - - -class GoalType(AbstractType): - __resource_type__ = "Goal" - - -class GoalTargetType(AbstractType): - __resource_type__ = "GoalTarget" - - -class GraphDefinitionType(AbstractType): - __resource_type__ = "GraphDefinition" - - -class GraphDefinitionLinkType(AbstractType): - __resource_type__ = "GraphDefinitionLink" - - -class GraphDefinitionLinkTargetType(AbstractType): - __resource_type__ = "GraphDefinitionLinkTarget" - - -class GraphDefinitionLinkTargetCompartmentType(AbstractType): - __resource_type__ = "GraphDefinitionLinkTargetCompartment" - - -class GroupType(AbstractType): - __resource_type__ = "Group" - - -class GroupCharacteristicType(AbstractType): - __resource_type__ = "GroupCharacteristic" - - -class GroupMemberType(AbstractType): - __resource_type__ = "GroupMember" - - -class GuidanceResponseType(AbstractType): - __resource_type__ = "GuidanceResponse" - - -class HealthcareServiceType(AbstractType): - __resource_type__ = "HealthcareService" - - -class HealthcareServiceAvailableTimeType(AbstractType): - __resource_type__ = "HealthcareServiceAvailableTime" - - -class HealthcareServiceEligibilityType(AbstractType): - __resource_type__ = "HealthcareServiceEligibility" - - -class HealthcareServiceNotAvailableType(AbstractType): - __resource_type__ = "HealthcareServiceNotAvailable" - - -class HumanNameType(AbstractType): - __resource_type__ = "HumanName" - - -class IdentifierType(AbstractType): - __resource_type__ = "Identifier" - - -class ImagingStudyType(AbstractType): - __resource_type__ = "ImagingStudy" - - -class ImagingStudySeriesType(AbstractType): - __resource_type__ = "ImagingStudySeries" - - -class ImagingStudySeriesInstanceType(AbstractType): - __resource_type__ = "ImagingStudySeriesInstance" - - -class ImagingStudySeriesPerformerType(AbstractType): - __resource_type__ = "ImagingStudySeriesPerformer" - - -class ImmunizationType(AbstractType): - __resource_type__ = "Immunization" - - -class ImmunizationEducationType(AbstractType): - __resource_type__ = "ImmunizationEducation" - - -class ImmunizationEvaluationType(AbstractType): - __resource_type__ = "ImmunizationEvaluation" - - -class ImmunizationPerformerType(AbstractType): - __resource_type__ = "ImmunizationPerformer" - - -class ImmunizationProtocolAppliedType(AbstractType): - __resource_type__ = "ImmunizationProtocolApplied" - - -class ImmunizationReactionType(AbstractType): - __resource_type__ = "ImmunizationReaction" - - -class ImmunizationRecommendationType(AbstractType): - __resource_type__ = "ImmunizationRecommendation" - - -class ImmunizationRecommendationRecommendationType(AbstractType): - __resource_type__ = "ImmunizationRecommendationRecommendation" - - -class ImmunizationRecommendationRecommendationDateCriterionType(AbstractType): - __resource_type__ = "ImmunizationRecommendationRecommendationDateCriterion" - - -class ImplementationGuideType(AbstractType): - __resource_type__ = "ImplementationGuide" - - -class ImplementationGuideDefinitionType(AbstractType): - __resource_type__ = "ImplementationGuideDefinition" - - -class ImplementationGuideDefinitionGroupingType(AbstractType): - __resource_type__ = "ImplementationGuideDefinitionGrouping" - - -class ImplementationGuideDefinitionPageType(AbstractType): - __resource_type__ = "ImplementationGuideDefinitionPage" - - -class ImplementationGuideDefinitionParameterType(AbstractType): - __resource_type__ = "ImplementationGuideDefinitionParameter" - - -class ImplementationGuideDefinitionResourceType(AbstractType): - __resource_type__ = "ImplementationGuideDefinitionResource" - - -class ImplementationGuideDefinitionTemplateType(AbstractType): - __resource_type__ = "ImplementationGuideDefinitionTemplate" - - -class ImplementationGuideDependsOnType(AbstractType): - __resource_type__ = "ImplementationGuideDependsOn" - - -class ImplementationGuideGlobalType(AbstractType): - __resource_type__ = "ImplementationGuideGlobal" - - -class ImplementationGuideManifestType(AbstractType): - __resource_type__ = "ImplementationGuideManifest" - - -class ImplementationGuideManifestPageType(AbstractType): - __resource_type__ = "ImplementationGuideManifestPage" - - -class ImplementationGuideManifestResourceType(AbstractType): - __resource_type__ = "ImplementationGuideManifestResource" - - -class InsurancePlanType(AbstractType): - __resource_type__ = "InsurancePlan" - - -class InsurancePlanContactType(AbstractType): - __resource_type__ = "InsurancePlanContact" - - -class InsurancePlanCoverageType(AbstractType): - __resource_type__ = "InsurancePlanCoverage" - - -class InsurancePlanCoverageBenefitType(AbstractType): - __resource_type__ = "InsurancePlanCoverageBenefit" - - -class InsurancePlanCoverageBenefitLimitType(AbstractType): - __resource_type__ = "InsurancePlanCoverageBenefitLimit" - - -class InsurancePlanPlanType(AbstractType): - __resource_type__ = "InsurancePlanPlan" - - -class InsurancePlanPlanGeneralCostType(AbstractType): - __resource_type__ = "InsurancePlanPlanGeneralCost" - - -class InsurancePlanPlanSpecificCostType(AbstractType): - __resource_type__ = "InsurancePlanPlanSpecificCost" - - -class InsurancePlanPlanSpecificCostBenefitType(AbstractType): - __resource_type__ = "InsurancePlanPlanSpecificCostBenefit" - - -class InsurancePlanPlanSpecificCostBenefitCostType(AbstractType): - __resource_type__ = "InsurancePlanPlanSpecificCostBenefitCost" - - -class InvoiceType(AbstractType): - __resource_type__ = "Invoice" - - -class InvoiceLineItemType(AbstractType): - __resource_type__ = "InvoiceLineItem" - - -class InvoiceLineItemPriceComponentType(AbstractType): - __resource_type__ = "InvoiceLineItemPriceComponent" - - -class InvoiceParticipantType(AbstractType): - __resource_type__ = "InvoiceParticipant" - - -class LibraryType(AbstractType): - __resource_type__ = "Library" - - -class LinkageType(AbstractType): - __resource_type__ = "Linkage" - - -class LinkageItemType(AbstractType): - __resource_type__ = "LinkageItem" - - -class ListType(AbstractType): - __resource_type__ = "List" - - -class ListEntryType(AbstractType): - __resource_type__ = "ListEntry" - - -class LocationType(AbstractType): - __resource_type__ = "Location" - - -class LocationHoursOfOperationType(AbstractType): - __resource_type__ = "LocationHoursOfOperation" - - -class LocationPositionType(AbstractType): - __resource_type__ = "LocationPosition" - - -class MarketingStatusType(AbstractType): - __resource_type__ = "MarketingStatus" - - -class MeasureType(AbstractType): - __resource_type__ = "Measure" - - -class MeasureGroupType(AbstractType): - __resource_type__ = "MeasureGroup" - - -class MeasureGroupPopulationType(AbstractType): - __resource_type__ = "MeasureGroupPopulation" - - -class MeasureGroupStratifierType(AbstractType): - __resource_type__ = "MeasureGroupStratifier" - - -class MeasureGroupStratifierComponentType(AbstractType): - __resource_type__ = "MeasureGroupStratifierComponent" - - -class MeasureReportType(AbstractType): - __resource_type__ = "MeasureReport" - - -class MeasureReportGroupType(AbstractType): - __resource_type__ = "MeasureReportGroup" - - -class MeasureReportGroupPopulationType(AbstractType): - __resource_type__ = "MeasureReportGroupPopulation" - - -class MeasureReportGroupStratifierType(AbstractType): - __resource_type__ = "MeasureReportGroupStratifier" - - -class MeasureReportGroupStratifierStratumType(AbstractType): - __resource_type__ = "MeasureReportGroupStratifierStratum" - - -class MeasureReportGroupStratifierStratumComponentType(AbstractType): - __resource_type__ = "MeasureReportGroupStratifierStratumComponent" - - -class MeasureReportGroupStratifierStratumPopulationType(AbstractType): - __resource_type__ = "MeasureReportGroupStratifierStratumPopulation" - - -class MeasureSupplementalDataType(AbstractType): - __resource_type__ = "MeasureSupplementalData" - - -class MediaType(AbstractType): - __resource_type__ = "Media" - - -class MedicationType(AbstractType): - __resource_type__ = "Medication" - - -class MedicationAdministrationType(AbstractType): - __resource_type__ = "MedicationAdministration" - - -class MedicationAdministrationDosageType(AbstractType): - __resource_type__ = "MedicationAdministrationDosage" - - -class MedicationAdministrationPerformerType(AbstractType): - __resource_type__ = "MedicationAdministrationPerformer" - - -class MedicationBatchType(AbstractType): - __resource_type__ = "MedicationBatch" - - -class MedicationDispenseType(AbstractType): - __resource_type__ = "MedicationDispense" - - -class MedicationDispensePerformerType(AbstractType): - __resource_type__ = "MedicationDispensePerformer" - - -class MedicationDispenseSubstitutionType(AbstractType): - __resource_type__ = "MedicationDispenseSubstitution" - - -class MedicationIngredientType(AbstractType): - __resource_type__ = "MedicationIngredient" - - -class MedicationKnowledgeType(AbstractType): - __resource_type__ = "MedicationKnowledge" - - -class MedicationKnowledgeAdministrationGuidelinesType(AbstractType): - __resource_type__ = "MedicationKnowledgeAdministrationGuidelines" - - -class MedicationKnowledgeAdministrationGuidelinesDosageType(AbstractType): - __resource_type__ = "MedicationKnowledgeAdministrationGuidelinesDosage" - - -class MedicationKnowledgeAdministrationGuidelinesPatientCharacteristicsType( - AbstractType -): - __resource_type__ = ( - "MedicationKnowledgeAdministrationGuidelinesPatientCharacteristics" - ) - - -class MedicationKnowledgeCostType(AbstractType): - __resource_type__ = "MedicationKnowledgeCost" - - -class MedicationKnowledgeDrugCharacteristicType(AbstractType): - __resource_type__ = "MedicationKnowledgeDrugCharacteristic" - - -class MedicationKnowledgeIngredientType(AbstractType): - __resource_type__ = "MedicationKnowledgeIngredient" - - -class MedicationKnowledgeKineticsType(AbstractType): - __resource_type__ = "MedicationKnowledgeKinetics" - - -class MedicationKnowledgeMedicineClassificationType(AbstractType): - __resource_type__ = "MedicationKnowledgeMedicineClassification" - - -class MedicationKnowledgeMonitoringProgramType(AbstractType): - __resource_type__ = "MedicationKnowledgeMonitoringProgram" - - -class MedicationKnowledgeMonographType(AbstractType): - __resource_type__ = "MedicationKnowledgeMonograph" - - -class MedicationKnowledgePackagingType(AbstractType): - __resource_type__ = "MedicationKnowledgePackaging" - - -class MedicationKnowledgeRegulatoryType(AbstractType): - __resource_type__ = "MedicationKnowledgeRegulatory" - - -class MedicationKnowledgeRegulatoryMaxDispenseType(AbstractType): - __resource_type__ = "MedicationKnowledgeRegulatoryMaxDispense" - - -class MedicationKnowledgeRegulatoryScheduleType(AbstractType): - __resource_type__ = "MedicationKnowledgeRegulatorySchedule" - - -class MedicationKnowledgeRegulatorySubstitutionType(AbstractType): - __resource_type__ = "MedicationKnowledgeRegulatorySubstitution" - - -class MedicationKnowledgeRelatedMedicationKnowledgeType(AbstractType): - __resource_type__ = "MedicationKnowledgeRelatedMedicationKnowledge" - - -class MedicationRequestType(AbstractType): - __resource_type__ = "MedicationRequest" - - -class MedicationRequestDispenseRequestType(AbstractType): - __resource_type__ = "MedicationRequestDispenseRequest" - - -class MedicationRequestDispenseRequestInitialFillType(AbstractType): - __resource_type__ = "MedicationRequestDispenseRequestInitialFill" - - -class MedicationRequestSubstitutionType(AbstractType): - __resource_type__ = "MedicationRequestSubstitution" - - -class MedicationStatementType(AbstractType): - __resource_type__ = "MedicationStatement" - - -class MedicinalProductType(AbstractType): - __resource_type__ = "MedicinalProduct" - - -class MedicinalProductAuthorizationType(AbstractType): - __resource_type__ = "MedicinalProductAuthorization" - - -class MedicinalProductAuthorizationJurisdictionalAuthorizationType(AbstractType): - __resource_type__ = "MedicinalProductAuthorizationJurisdictionalAuthorization" - - -class MedicinalProductAuthorizationProcedureType(AbstractType): - __resource_type__ = "MedicinalProductAuthorizationProcedure" - - -class MedicinalProductContraindicationType(AbstractType): - __resource_type__ = "MedicinalProductContraindication" - - -class MedicinalProductContraindicationOtherTherapyType(AbstractType): - __resource_type__ = "MedicinalProductContraindicationOtherTherapy" - - -class MedicinalProductIndicationType(AbstractType): - __resource_type__ = "MedicinalProductIndication" - - -class MedicinalProductIndicationOtherTherapyType(AbstractType): - __resource_type__ = "MedicinalProductIndicationOtherTherapy" - - -class MedicinalProductIngredientType(AbstractType): - __resource_type__ = "MedicinalProductIngredient" - - -class MedicinalProductIngredientSpecifiedSubstanceType(AbstractType): - __resource_type__ = "MedicinalProductIngredientSpecifiedSubstance" - - -class MedicinalProductIngredientSpecifiedSubstanceStrengthType(AbstractType): - __resource_type__ = "MedicinalProductIngredientSpecifiedSubstanceStrength" - - -class MedicinalProductIngredientSpecifiedSubstanceStrengthReferenceStrengthType( - AbstractType -): - __resource_type__ = ( - "MedicinalProductIngredientSpecifiedSubstanceStrengthReferenceStrength" - ) - - -class MedicinalProductIngredientSubstanceType(AbstractType): - __resource_type__ = "MedicinalProductIngredientSubstance" - - -class MedicinalProductInteractionType(AbstractType): - __resource_type__ = "MedicinalProductInteraction" - - -class MedicinalProductInteractionInteractantType(AbstractType): - __resource_type__ = "MedicinalProductInteractionInteractant" - - -class MedicinalProductManufacturedType(AbstractType): - __resource_type__ = "MedicinalProductManufactured" - - -class MedicinalProductManufacturingBusinessOperationType(AbstractType): - __resource_type__ = "MedicinalProductManufacturingBusinessOperation" - - -class MedicinalProductNameType(AbstractType): - __resource_type__ = "MedicinalProductName" - - -class MedicinalProductNameCountryLanguageType(AbstractType): - __resource_type__ = "MedicinalProductNameCountryLanguage" - - -class MedicinalProductNameNamePartType(AbstractType): - __resource_type__ = "MedicinalProductNameNamePart" - - -class MedicinalProductPackagedType(AbstractType): - __resource_type__ = "MedicinalProductPackaged" - - -class MedicinalProductPackagedBatchIdentifierType(AbstractType): - __resource_type__ = "MedicinalProductPackagedBatchIdentifier" - - -class MedicinalProductPackagedPackageItemType(AbstractType): - __resource_type__ = "MedicinalProductPackagedPackageItem" - - -class MedicinalProductPharmaceuticalType(AbstractType): - __resource_type__ = "MedicinalProductPharmaceutical" - - -class MedicinalProductPharmaceuticalCharacteristicsType(AbstractType): - __resource_type__ = "MedicinalProductPharmaceuticalCharacteristics" - - -class MedicinalProductPharmaceuticalRouteOfAdministrationType(AbstractType): - __resource_type__ = "MedicinalProductPharmaceuticalRouteOfAdministration" - - -class MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesType( - AbstractType -): - __resource_type__ = ( - "MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpecies" - ) - - -class MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesWithdrawalPeriodType( - AbstractType -): - __resource_type__ = "MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesWithdrawalPeriod" # noqa: B950 - - -class MedicinalProductSpecialDesignationType(AbstractType): - __resource_type__ = "MedicinalProductSpecialDesignation" - - -class MedicinalProductUndesirableEffectType(AbstractType): - __resource_type__ = "MedicinalProductUndesirableEffect" - - -class MessageDefinitionType(AbstractType): - __resource_type__ = "MessageDefinition" - - -class MessageDefinitionAllowedResponseType(AbstractType): - __resource_type__ = "MessageDefinitionAllowedResponse" - - -class MessageDefinitionFocusType(AbstractType): - __resource_type__ = "MessageDefinitionFocus" - - -class MessageHeaderType(AbstractType): - __resource_type__ = "MessageHeader" - - -class MessageHeaderDestinationType(AbstractType): - __resource_type__ = "MessageHeaderDestination" - - -class MessageHeaderResponseType(AbstractType): - __resource_type__ = "MessageHeaderResponse" - - -class MessageHeaderSourceType(AbstractType): - __resource_type__ = "MessageHeaderSource" - - -class MetaType(AbstractType): - __resource_type__ = "Meta" - - -class MetadataResourceType(AbstractType): - __resource_type__ = "MetadataResource" - - -class MolecularSequenceType(AbstractType): - __resource_type__ = "MolecularSequence" - - -class MolecularSequenceQualityType(AbstractType): - __resource_type__ = "MolecularSequenceQuality" - - -class MolecularSequenceQualityRocType(AbstractType): - __resource_type__ = "MolecularSequenceQualityRoc" - - -class MolecularSequenceReferenceSeqType(AbstractType): - __resource_type__ = "MolecularSequenceReferenceSeq" - - -class MolecularSequenceRepositoryType(AbstractType): - __resource_type__ = "MolecularSequenceRepository" - - -class MolecularSequenceStructureVariantType(AbstractType): - __resource_type__ = "MolecularSequenceStructureVariant" - - -class MolecularSequenceStructureVariantInnerType(AbstractType): - __resource_type__ = "MolecularSequenceStructureVariantInner" - - -class MolecularSequenceStructureVariantOuterType(AbstractType): - __resource_type__ = "MolecularSequenceStructureVariantOuter" - - -class MolecularSequenceVariantType(AbstractType): - __resource_type__ = "MolecularSequenceVariant" - - -class MoneyType(AbstractType): - __resource_type__ = "Money" - - -class NamingSystemType(AbstractType): - __resource_type__ = "NamingSystem" - - -class NamingSystemUniqueIdType(AbstractType): - __resource_type__ = "NamingSystemUniqueId" - - -class NarrativeType(AbstractType): - __resource_type__ = "Narrative" - - -class NutritionOrderType(AbstractType): - __resource_type__ = "NutritionOrder" - - -class NutritionOrderEnteralFormulaType(AbstractType): - __resource_type__ = "NutritionOrderEnteralFormula" - - -class NutritionOrderEnteralFormulaAdministrationType(AbstractType): - __resource_type__ = "NutritionOrderEnteralFormulaAdministration" - - -class NutritionOrderOralDietType(AbstractType): - __resource_type__ = "NutritionOrderOralDiet" - - -class NutritionOrderOralDietNutrientType(AbstractType): - __resource_type__ = "NutritionOrderOralDietNutrient" - - -class NutritionOrderOralDietTextureType(AbstractType): - __resource_type__ = "NutritionOrderOralDietTexture" - - -class NutritionOrderSupplementType(AbstractType): - __resource_type__ = "NutritionOrderSupplement" - - -class ObservationType(AbstractType): - __resource_type__ = "Observation" - - -class ObservationComponentType(AbstractType): - __resource_type__ = "ObservationComponent" - - -class ObservationDefinitionType(AbstractType): - __resource_type__ = "ObservationDefinition" - - -class ObservationDefinitionQualifiedIntervalType(AbstractType): - __resource_type__ = "ObservationDefinitionQualifiedInterval" - - -class ObservationDefinitionQuantitativeDetailsType(AbstractType): - __resource_type__ = "ObservationDefinitionQuantitativeDetails" - - -class ObservationReferenceRangeType(AbstractType): - __resource_type__ = "ObservationReferenceRange" - - -class OperationDefinitionType(AbstractType): - __resource_type__ = "OperationDefinition" - - -class OperationDefinitionOverloadType(AbstractType): - __resource_type__ = "OperationDefinitionOverload" - - -class OperationDefinitionParameterType(AbstractType): - __resource_type__ = "OperationDefinitionParameter" - - -class OperationDefinitionParameterBindingType(AbstractType): - __resource_type__ = "OperationDefinitionParameterBinding" - - -class OperationDefinitionParameterReferencedFromType(AbstractType): - __resource_type__ = "OperationDefinitionParameterReferencedFrom" - - -class OperationOutcomeType(AbstractType): - __resource_type__ = "OperationOutcome" - - -class OperationOutcomeIssueType(AbstractType): - __resource_type__ = "OperationOutcomeIssue" - - -class OrganizationType(AbstractType): - __resource_type__ = "Organization" - - -class OrganizationAffiliationType(AbstractType): - __resource_type__ = "OrganizationAffiliation" - - -class OrganizationContactType(AbstractType): - __resource_type__ = "OrganizationContact" - - -class ParameterDefinitionType(AbstractType): - __resource_type__ = "ParameterDefinition" - - -class ParametersType(AbstractType): - __resource_type__ = "Parameters" - - -class ParametersParameterType(AbstractType): - __resource_type__ = "ParametersParameter" - - -class PatientType(AbstractType): - __resource_type__ = "Patient" - - -class PatientCommunicationType(AbstractType): - __resource_type__ = "PatientCommunication" - - -class PatientContactType(AbstractType): - __resource_type__ = "PatientContact" - - -class PatientLinkType(AbstractType): - __resource_type__ = "PatientLink" - - -class PaymentNoticeType(AbstractType): - __resource_type__ = "PaymentNotice" - - -class PaymentReconciliationType(AbstractType): - __resource_type__ = "PaymentReconciliation" - - -class PaymentReconciliationDetailType(AbstractType): - __resource_type__ = "PaymentReconciliationDetail" - - -class PaymentReconciliationProcessNoteType(AbstractType): - __resource_type__ = "PaymentReconciliationProcessNote" - - -class PeriodType(AbstractType): - __resource_type__ = "Period" - - -class PersonType(AbstractType): - __resource_type__ = "Person" - - -class PersonLinkType(AbstractType): - __resource_type__ = "PersonLink" - - -class PlanDefinitionType(AbstractType): - __resource_type__ = "PlanDefinition" - - -class PlanDefinitionActionType(AbstractType): - __resource_type__ = "PlanDefinitionAction" - - -class PlanDefinitionActionConditionType(AbstractType): - __resource_type__ = "PlanDefinitionActionCondition" - - -class PlanDefinitionActionDynamicValueType(AbstractType): - __resource_type__ = "PlanDefinitionActionDynamicValue" - - -class PlanDefinitionActionParticipantType(AbstractType): - __resource_type__ = "PlanDefinitionActionParticipant" - - -class PlanDefinitionActionRelatedActionType(AbstractType): - __resource_type__ = "PlanDefinitionActionRelatedAction" - - -class PlanDefinitionGoalType(AbstractType): - __resource_type__ = "PlanDefinitionGoal" - - -class PlanDefinitionGoalTargetType(AbstractType): - __resource_type__ = "PlanDefinitionGoalTarget" - - -class PopulationType(AbstractType): - __resource_type__ = "Population" - - -class PractitionerType(AbstractType): - __resource_type__ = "Practitioner" - - -class PractitionerQualificationType(AbstractType): - __resource_type__ = "PractitionerQualification" - - -class PractitionerRoleType(AbstractType): - __resource_type__ = "PractitionerRole" - - -class PractitionerRoleAvailableTimeType(AbstractType): - __resource_type__ = "PractitionerRoleAvailableTime" - - -class PractitionerRoleNotAvailableType(AbstractType): - __resource_type__ = "PractitionerRoleNotAvailable" - - -class ProcedureType(AbstractType): - __resource_type__ = "Procedure" - - -class ProcedureFocalDeviceType(AbstractType): - __resource_type__ = "ProcedureFocalDevice" - - -class ProcedurePerformerType(AbstractType): - __resource_type__ = "ProcedurePerformer" - - -class ProdCharacteristicType(AbstractType): - __resource_type__ = "ProdCharacteristic" - - -class ProductShelfLifeType(AbstractType): - __resource_type__ = "ProductShelfLife" - - -class ProvenanceType(AbstractType): - __resource_type__ = "Provenance" - - -class ProvenanceAgentType(AbstractType): - __resource_type__ = "ProvenanceAgent" - - -class ProvenanceEntityType(AbstractType): - __resource_type__ = "ProvenanceEntity" - - -class QuantityType(AbstractType): - __resource_type__ = "Quantity" - - -class QuestionnaireType(AbstractType): - __resource_type__ = "Questionnaire" - - -class QuestionnaireItemType(AbstractType): - __resource_type__ = "QuestionnaireItem" - - -class QuestionnaireItemAnswerOptionType(AbstractType): - __resource_type__ = "QuestionnaireItemAnswerOption" - - -class QuestionnaireItemEnableWhenType(AbstractType): - __resource_type__ = "QuestionnaireItemEnableWhen" - - -class QuestionnaireItemInitialType(AbstractType): - __resource_type__ = "QuestionnaireItemInitial" - - -class QuestionnaireResponseType(AbstractType): - __resource_type__ = "QuestionnaireResponse" - - -class QuestionnaireResponseItemType(AbstractType): - __resource_type__ = "QuestionnaireResponseItem" - - -class QuestionnaireResponseItemAnswerType(AbstractType): - __resource_type__ = "QuestionnaireResponseItemAnswer" - - -class RangeType(AbstractType): - __resource_type__ = "Range" - - -class RatioType(AbstractType): - __resource_type__ = "Ratio" - - -class ReferenceType(AbstractType): - __resource_type__ = "Reference" - - -class RelatedArtifactType(AbstractType): - __resource_type__ = "RelatedArtifact" - - -class RelatedPersonType(AbstractType): - __resource_type__ = "RelatedPerson" - - -class RelatedPersonCommunicationType(AbstractType): - __resource_type__ = "RelatedPersonCommunication" - - -class RequestGroupType(AbstractType): - __resource_type__ = "RequestGroup" - - -class RequestGroupActionType(AbstractType): - __resource_type__ = "RequestGroupAction" - - -class RequestGroupActionConditionType(AbstractType): - __resource_type__ = "RequestGroupActionCondition" - - -class RequestGroupActionRelatedActionType(AbstractType): - __resource_type__ = "RequestGroupActionRelatedAction" - - -class ResearchDefinitionType(AbstractType): - __resource_type__ = "ResearchDefinition" - - -class ResearchElementDefinitionType(AbstractType): - __resource_type__ = "ResearchElementDefinition" - - -class ResearchElementDefinitionCharacteristicType(AbstractType): - __resource_type__ = "ResearchElementDefinitionCharacteristic" - - -class ResearchStudyType(AbstractType): - __resource_type__ = "ResearchStudy" - - -class ResearchStudyArmType(AbstractType): - __resource_type__ = "ResearchStudyArm" - - -class ResearchStudyObjectiveType(AbstractType): - __resource_type__ = "ResearchStudyObjective" - - -class ResearchSubjectType(AbstractType): - __resource_type__ = "ResearchSubject" - - -class RiskAssessmentType(AbstractType): - __resource_type__ = "RiskAssessment" - - -class RiskAssessmentPredictionType(AbstractType): - __resource_type__ = "RiskAssessmentPrediction" - - -class RiskEvidenceSynthesisType(AbstractType): - __resource_type__ = "RiskEvidenceSynthesis" - - -class RiskEvidenceSynthesisCertaintyType(AbstractType): - __resource_type__ = "RiskEvidenceSynthesisCertainty" - - -class RiskEvidenceSynthesisCertaintyCertaintySubcomponentType(AbstractType): - __resource_type__ = "RiskEvidenceSynthesisCertaintyCertaintySubcomponent" - - -class RiskEvidenceSynthesisRiskEstimateType(AbstractType): - __resource_type__ = "RiskEvidenceSynthesisRiskEstimate" - - -class RiskEvidenceSynthesisRiskEstimatePrecisionEstimateType(AbstractType): - __resource_type__ = "RiskEvidenceSynthesisRiskEstimatePrecisionEstimate" - - -class RiskEvidenceSynthesisSampleSizeType(AbstractType): - __resource_type__ = "RiskEvidenceSynthesisSampleSize" - - -class SampledDataType(AbstractType): - __resource_type__ = "SampledData" - - -class ScheduleType(AbstractType): - __resource_type__ = "Schedule" - - -class SearchParameterType(AbstractType): - __resource_type__ = "SearchParameter" - - -class SearchParameterComponentType(AbstractType): - __resource_type__ = "SearchParameterComponent" - - -class ServiceRequestType(AbstractType): - __resource_type__ = "ServiceRequest" - - -class SignatureType(AbstractType): - __resource_type__ = "Signature" - - -class SlotType(AbstractType): - __resource_type__ = "Slot" - - -class SpecimenType(AbstractType): - __resource_type__ = "Specimen" - - -class SpecimenCollectionType(AbstractType): - __resource_type__ = "SpecimenCollection" - - -class SpecimenContainerType(AbstractType): - __resource_type__ = "SpecimenContainer" - - -class SpecimenDefinitionType(AbstractType): - __resource_type__ = "SpecimenDefinition" - - -class SpecimenDefinitionTypeTestedType(AbstractType): - __resource_type__ = "SpecimenDefinitionTypeTested" - - -class SpecimenDefinitionTypeTestedContainerType(AbstractType): - __resource_type__ = "SpecimenDefinitionTypeTestedContainer" - - -class SpecimenDefinitionTypeTestedContainerAdditiveType(AbstractType): - __resource_type__ = "SpecimenDefinitionTypeTestedContainerAdditive" - - -class SpecimenDefinitionTypeTestedHandlingType(AbstractType): - __resource_type__ = "SpecimenDefinitionTypeTestedHandling" - - -class SpecimenProcessingType(AbstractType): - __resource_type__ = "SpecimenProcessing" - - -class StructureDefinitionType(AbstractType): - __resource_type__ = "StructureDefinition" - - -class StructureDefinitionContextType(AbstractType): - __resource_type__ = "StructureDefinitionContext" - - -class StructureDefinitionDifferentialType(AbstractType): - __resource_type__ = "StructureDefinitionDifferential" - - -class StructureDefinitionMappingType(AbstractType): - __resource_type__ = "StructureDefinitionMapping" - - -class StructureDefinitionSnapshotType(AbstractType): - __resource_type__ = "StructureDefinitionSnapshot" - - -class StructureMapType(AbstractType): - __resource_type__ = "StructureMap" - - -class StructureMapGroupType(AbstractType): - __resource_type__ = "StructureMapGroup" - - -class StructureMapGroupInputType(AbstractType): - __resource_type__ = "StructureMapGroupInput" - - -class StructureMapGroupRuleType(AbstractType): - __resource_type__ = "StructureMapGroupRule" - - -class StructureMapGroupRuleDependentType(AbstractType): - __resource_type__ = "StructureMapGroupRuleDependent" - - -class StructureMapGroupRuleSourceType(AbstractType): - __resource_type__ = "StructureMapGroupRuleSource" - - -class StructureMapGroupRuleTargetType(AbstractType): - __resource_type__ = "StructureMapGroupRuleTarget" - - -class StructureMapGroupRuleTargetParameterType(AbstractType): - __resource_type__ = "StructureMapGroupRuleTargetParameter" - - -class StructureMapStructureType(AbstractType): - __resource_type__ = "StructureMapStructure" - - -class SubscriptionType(AbstractType): - __resource_type__ = "Subscription" - - -class SubscriptionChannelType(AbstractType): - __resource_type__ = "SubscriptionChannel" - - -class SubstanceType(AbstractType): - __resource_type__ = "Substance" - - -class SubstanceAmountType(AbstractType): - __resource_type__ = "SubstanceAmount" - - -class SubstanceAmountReferenceRangeType(AbstractType): - __resource_type__ = "SubstanceAmountReferenceRange" - - -class SubstanceIngredientType(AbstractType): - __resource_type__ = "SubstanceIngredient" - - -class SubstanceInstanceType(AbstractType): - __resource_type__ = "SubstanceInstance" - - -class SubstanceNucleicAcidType(AbstractType): - __resource_type__ = "SubstanceNucleicAcid" - - -class SubstanceNucleicAcidSubunitType(AbstractType): - __resource_type__ = "SubstanceNucleicAcidSubunit" - - -class SubstanceNucleicAcidSubunitLinkageType(AbstractType): - __resource_type__ = "SubstanceNucleicAcidSubunitLinkage" - - -class SubstanceNucleicAcidSubunitSugarType(AbstractType): - __resource_type__ = "SubstanceNucleicAcidSubunitSugar" - - -class SubstancePolymerType(AbstractType): - __resource_type__ = "SubstancePolymer" - - -class SubstancePolymerMonomerSetType(AbstractType): - __resource_type__ = "SubstancePolymerMonomerSet" - - -class SubstancePolymerMonomerSetStartingMaterialType(AbstractType): - __resource_type__ = "SubstancePolymerMonomerSetStartingMaterial" - - -class SubstancePolymerRepeatType(AbstractType): - __resource_type__ = "SubstancePolymerRepeat" - - -class SubstancePolymerRepeatRepeatUnitType(AbstractType): - __resource_type__ = "SubstancePolymerRepeatRepeatUnit" - - -class SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationType(AbstractType): - __resource_type__ = "SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisation" - - -class SubstancePolymerRepeatRepeatUnitStructuralRepresentationType(AbstractType): - __resource_type__ = "SubstancePolymerRepeatRepeatUnitStructuralRepresentation" - - -class SubstanceProteinType(AbstractType): - __resource_type__ = "SubstanceProtein" - - -class SubstanceProteinSubunitType(AbstractType): - __resource_type__ = "SubstanceProteinSubunit" - - -class SubstanceReferenceInformationType(AbstractType): - __resource_type__ = "SubstanceReferenceInformation" - - -class SubstanceReferenceInformationClassificationType(AbstractType): - __resource_type__ = "SubstanceReferenceInformationClassification" - - -class SubstanceReferenceInformationGeneType(AbstractType): - __resource_type__ = "SubstanceReferenceInformationGene" - - -class SubstanceReferenceInformationGeneElementType(AbstractType): - __resource_type__ = "SubstanceReferenceInformationGeneElement" - - -class SubstanceReferenceInformationTargetType(AbstractType): - __resource_type__ = "SubstanceReferenceInformationTarget" - - -class SubstanceSourceMaterialType(AbstractType): - __resource_type__ = "SubstanceSourceMaterial" - - -class SubstanceSourceMaterialFractionDescriptionType(AbstractType): - __resource_type__ = "SubstanceSourceMaterialFractionDescription" - - -class SubstanceSourceMaterialOrganismType(AbstractType): - __resource_type__ = "SubstanceSourceMaterialOrganism" - - -class SubstanceSourceMaterialOrganismAuthorType(AbstractType): - __resource_type__ = "SubstanceSourceMaterialOrganismAuthor" - - -class SubstanceSourceMaterialOrganismHybridType(AbstractType): - __resource_type__ = "SubstanceSourceMaterialOrganismHybrid" - - -class SubstanceSourceMaterialOrganismOrganismGeneralType(AbstractType): - __resource_type__ = "SubstanceSourceMaterialOrganismOrganismGeneral" - - -class SubstanceSourceMaterialPartDescriptionType(AbstractType): - __resource_type__ = "SubstanceSourceMaterialPartDescription" - - -class SubstanceSpecificationType(AbstractType): - __resource_type__ = "SubstanceSpecification" - - -class SubstanceSpecificationCodeType(AbstractType): - __resource_type__ = "SubstanceSpecificationCode" - - -class SubstanceSpecificationMoietyType(AbstractType): - __resource_type__ = "SubstanceSpecificationMoiety" - - -class SubstanceSpecificationNameType(AbstractType): - __resource_type__ = "SubstanceSpecificationName" - - -class SubstanceSpecificationNameOfficialType(AbstractType): - __resource_type__ = "SubstanceSpecificationNameOfficial" - - -class SubstanceSpecificationPropertyType(AbstractType): - __resource_type__ = "SubstanceSpecificationProperty" - - -class SubstanceSpecificationRelationshipType(AbstractType): - __resource_type__ = "SubstanceSpecificationRelationship" - - -class SubstanceSpecificationStructureType(AbstractType): - __resource_type__ = "SubstanceSpecificationStructure" - - -class SubstanceSpecificationStructureIsotopeType(AbstractType): - __resource_type__ = "SubstanceSpecificationStructureIsotope" - - -class SubstanceSpecificationStructureIsotopeMolecularWeightType(AbstractType): - __resource_type__ = "SubstanceSpecificationStructureIsotopeMolecularWeight" - - -class SubstanceSpecificationStructureRepresentationType(AbstractType): - __resource_type__ = "SubstanceSpecificationStructureRepresentation" - - -class SupplyDeliveryType(AbstractType): - __resource_type__ = "SupplyDelivery" - - -class SupplyDeliverySuppliedItemType(AbstractType): - __resource_type__ = "SupplyDeliverySuppliedItem" - - -class SupplyRequestType(AbstractType): - __resource_type__ = "SupplyRequest" - - -class SupplyRequestParameterType(AbstractType): - __resource_type__ = "SupplyRequestParameter" - - -class TaskType(AbstractType): - __resource_type__ = "Task" - - -class TaskInputType(AbstractType): - __resource_type__ = "TaskInput" - - -class TaskOutputType(AbstractType): - __resource_type__ = "TaskOutput" - - -class TaskRestrictionType(AbstractType): - __resource_type__ = "TaskRestriction" - - -class TerminologyCapabilitiesType(AbstractType): - __resource_type__ = "TerminologyCapabilities" - - -class TerminologyCapabilitiesClosureType(AbstractType): - __resource_type__ = "TerminologyCapabilitiesClosure" - - -class TerminologyCapabilitiesCodeSystemType(AbstractType): - __resource_type__ = "TerminologyCapabilitiesCodeSystem" - - -class TerminologyCapabilitiesCodeSystemVersionType(AbstractType): - __resource_type__ = "TerminologyCapabilitiesCodeSystemVersion" - - -class TerminologyCapabilitiesCodeSystemVersionFilterType(AbstractType): - __resource_type__ = "TerminologyCapabilitiesCodeSystemVersionFilter" - - -class TerminologyCapabilitiesExpansionType(AbstractType): - __resource_type__ = "TerminologyCapabilitiesExpansion" - - -class TerminologyCapabilitiesExpansionParameterType(AbstractType): - __resource_type__ = "TerminologyCapabilitiesExpansionParameter" - - -class TerminologyCapabilitiesImplementationType(AbstractType): - __resource_type__ = "TerminologyCapabilitiesImplementation" - - -class TerminologyCapabilitiesSoftwareType(AbstractType): - __resource_type__ = "TerminologyCapabilitiesSoftware" - - -class TerminologyCapabilitiesTranslationType(AbstractType): - __resource_type__ = "TerminologyCapabilitiesTranslation" - - -class TerminologyCapabilitiesValidateCodeType(AbstractType): - __resource_type__ = "TerminologyCapabilitiesValidateCode" - - -class TestReportType(AbstractType): - __resource_type__ = "TestReport" - - -class TestReportParticipantType(AbstractType): - __resource_type__ = "TestReportParticipant" - - -class TestReportSetupType(AbstractType): - __resource_type__ = "TestReportSetup" - - -class TestReportSetupActionType(AbstractType): - __resource_type__ = "TestReportSetupAction" - - -class TestReportSetupActionAssertType(AbstractType): - __resource_type__ = "TestReportSetupActionAssert" - - -class TestReportSetupActionOperationType(AbstractType): - __resource_type__ = "TestReportSetupActionOperation" - - -class TestReportTeardownType(AbstractType): - __resource_type__ = "TestReportTeardown" - - -class TestReportTeardownActionType(AbstractType): - __resource_type__ = "TestReportTeardownAction" - - -class TestReportTestType(AbstractType): - __resource_type__ = "TestReportTest" - - -class TestReportTestActionType(AbstractType): - __resource_type__ = "TestReportTestAction" - - -class TestScriptType(AbstractType): - __resource_type__ = "TestScript" - - -class TestScriptDestinationType(AbstractType): - __resource_type__ = "TestScriptDestination" - - -class TestScriptFixtureType(AbstractType): - __resource_type__ = "TestScriptFixture" - - -class TestScriptMetadataType(AbstractType): - __resource_type__ = "TestScriptMetadata" - - -class TestScriptMetadataCapabilityType(AbstractType): - __resource_type__ = "TestScriptMetadataCapability" - - -class TestScriptMetadataLinkType(AbstractType): - __resource_type__ = "TestScriptMetadataLink" - - -class TestScriptOriginType(AbstractType): - __resource_type__ = "TestScriptOrigin" - - -class TestScriptSetupType(AbstractType): - __resource_type__ = "TestScriptSetup" - - -class TestScriptSetupActionType(AbstractType): - __resource_type__ = "TestScriptSetupAction" - - -class TestScriptSetupActionAssertType(AbstractType): - __resource_type__ = "TestScriptSetupActionAssert" - - -class TestScriptSetupActionOperationType(AbstractType): - __resource_type__ = "TestScriptSetupActionOperation" - - -class TestScriptSetupActionOperationRequestHeaderType(AbstractType): - __resource_type__ = "TestScriptSetupActionOperationRequestHeader" - - -class TestScriptTeardownType(AbstractType): - __resource_type__ = "TestScriptTeardown" - - -class TestScriptTeardownActionType(AbstractType): - __resource_type__ = "TestScriptTeardownAction" - - -class TestScriptTestType(AbstractType): - __resource_type__ = "TestScriptTest" - - -class TestScriptTestActionType(AbstractType): - __resource_type__ = "TestScriptTestAction" - - -class TestScriptVariableType(AbstractType): - __resource_type__ = "TestScriptVariable" - - -class TimingType(AbstractType): - __resource_type__ = "Timing" - - -class TimingRepeatType(AbstractType): - __resource_type__ = "TimingRepeat" - - -class TriggerDefinitionType(AbstractType): - __resource_type__ = "TriggerDefinition" - - -class UsageContextType(AbstractType): - __resource_type__ = "UsageContext" - - -class ValueSetType(AbstractType): - __resource_type__ = "ValueSet" - - -class ValueSetComposeType(AbstractType): - __resource_type__ = "ValueSetCompose" - - -class ValueSetComposeIncludeType(AbstractType): - __resource_type__ = "ValueSetComposeInclude" - - -class ValueSetComposeIncludeConceptType(AbstractType): - __resource_type__ = "ValueSetComposeIncludeConcept" - - -class ValueSetComposeIncludeConceptDesignationType(AbstractType): - __resource_type__ = "ValueSetComposeIncludeConceptDesignation" - - -class ValueSetComposeIncludeFilterType(AbstractType): - __resource_type__ = "ValueSetComposeIncludeFilter" - - -class ValueSetExpansionType(AbstractType): - __resource_type__ = "ValueSetExpansion" - - -class ValueSetExpansionContainsType(AbstractType): - __resource_type__ = "ValueSetExpansionContains" - - -class ValueSetExpansionParameterType(AbstractType): - __resource_type__ = "ValueSetExpansionParameter" - - -class VerificationResultType(AbstractType): - __resource_type__ = "VerificationResult" - - -class VerificationResultAttestationType(AbstractType): - __resource_type__ = "VerificationResultAttestation" - - -class VerificationResultPrimarySourceType(AbstractType): - __resource_type__ = "VerificationResultPrimarySource" - - -class VerificationResultValidatorType(AbstractType): - __resource_type__ = "VerificationResultValidator" - - -class VisionPrescriptionType(AbstractType): - __resource_type__ = "VisionPrescription" - - -class VisionPrescriptionLensSpecificationType(AbstractType): - __resource_type__ = "VisionPrescriptionLensSpecification" - - -class VisionPrescriptionLensSpecificationPrismType(AbstractType): - __resource_type__ = "VisionPrescriptionLensSpecificationPrism" - - -__all__ = [ - "Boolean", - "String", - "Base64Binary", - "Code", - "Id", - "Decimal", - "Integer", - "UnsignedInt", - "PositiveInt", - "Uri", - "Oid", - "Uuid", - "Canonical", - "Url", - "Markdown", - "Xhtml", - "Date", - "DateTime", - "Instant", - "Time", - "FHIRPrimitiveExtensionType", - "ElementType", - "ResourceType", - "AccountType", - "AccountCoverageType", - "AccountGuarantorType", - "ActivityDefinitionType", - "ActivityDefinitionDynamicValueType", - "ActivityDefinitionParticipantType", - "AddressType", - "AdverseEventType", - "AdverseEventSuspectEntityType", - "AdverseEventSuspectEntityCausalityType", - "AgeType", - "AllergyIntoleranceType", - "AllergyIntoleranceReactionType", - "AnnotationType", - "AppointmentType", - "AppointmentParticipantType", - "AppointmentResponseType", - "AttachmentType", - "AuditEventType", - "AuditEventAgentType", - "AuditEventAgentNetworkType", - "AuditEventEntityType", - "AuditEventEntityDetailType", - "AuditEventSourceType", - "BackboneElementType", - "BasicType", - "BinaryType", - "BiologicallyDerivedProductType", - "BiologicallyDerivedProductCollectionType", - "BiologicallyDerivedProductManipulationType", - "BiologicallyDerivedProductProcessingType", - "BiologicallyDerivedProductStorageType", - "BodyStructureType", - "BundleType", - "BundleEntryType", - "BundleEntryRequestType", - "BundleEntryResponseType", - "BundleEntrySearchType", - "BundleLinkType", - "CapabilityStatementType", - "CapabilityStatementDocumentType", - "CapabilityStatementImplementationType", - "CapabilityStatementMessagingType", - "CapabilityStatementMessagingEndpointType", - "CapabilityStatementMessagingSupportedMessageType", - "CapabilityStatementRestType", - "CapabilityStatementRestInteractionType", - "CapabilityStatementRestResourceType", - "CapabilityStatementRestResourceInteractionType", - "CapabilityStatementRestResourceOperationType", - "CapabilityStatementRestResourceSearchParamType", - "CapabilityStatementRestSecurityType", - "CapabilityStatementSoftwareType", - "CarePlanType", - "CarePlanActivityType", - "CarePlanActivityDetailType", - "CareTeamType", - "CareTeamParticipantType", - "CatalogEntryType", - "CatalogEntryRelatedEntryType", - "ChargeItemType", - "ChargeItemDefinitionType", - "ChargeItemDefinitionApplicabilityType", - "ChargeItemDefinitionPropertyGroupType", - "ChargeItemDefinitionPropertyGroupPriceComponentType", - "ChargeItemPerformerType", - "ClaimType", - "ClaimAccidentType", - "ClaimCareTeamType", - "ClaimDiagnosisType", - "ClaimInsuranceType", - "ClaimItemType", - "ClaimItemDetailType", - "ClaimItemDetailSubDetailType", - "ClaimPayeeType", - "ClaimProcedureType", - "ClaimRelatedType", - "ClaimResponseType", - "ClaimResponseAddItemType", - "ClaimResponseAddItemDetailType", - "ClaimResponseAddItemDetailSubDetailType", - "ClaimResponseErrorType", - "ClaimResponseInsuranceType", - "ClaimResponseItemType", - "ClaimResponseItemAdjudicationType", - "ClaimResponseItemDetailType", - "ClaimResponseItemDetailSubDetailType", - "ClaimResponsePaymentType", - "ClaimResponseProcessNoteType", - "ClaimResponseTotalType", - "ClaimSupportingInfoType", - "ClinicalImpressionType", - "ClinicalImpressionFindingType", - "ClinicalImpressionInvestigationType", - "CodeSystemType", - "CodeSystemConceptType", - "CodeSystemConceptDesignationType", - "CodeSystemConceptPropertyType", - "CodeSystemFilterType", - "CodeSystemPropertyType", - "CodeableConceptType", - "CodingType", - "CommunicationType", - "CommunicationPayloadType", - "CommunicationRequestType", - "CommunicationRequestPayloadType", - "CompartmentDefinitionType", - "CompartmentDefinitionResourceType", - "CompositionType", - "CompositionAttesterType", - "CompositionEventType", - "CompositionRelatesToType", - "CompositionSectionType", - "ConceptMapType", - "ConceptMapGroupType", - "ConceptMapGroupElementType", - "ConceptMapGroupElementTargetType", - "ConceptMapGroupElementTargetDependsOnType", - "ConceptMapGroupUnmappedType", - "ConditionType", - "ConditionEvidenceType", - "ConditionStageType", - "ConsentType", - "ConsentPolicyType", - "ConsentProvisionType", - "ConsentProvisionActorType", - "ConsentProvisionDataType", - "ConsentVerificationType", - "ContactDetailType", - "ContactPointType", - "ContractType", - "ContractContentDefinitionType", - "ContractFriendlyType", - "ContractLegalType", - "ContractRuleType", - "ContractSignerType", - "ContractTermType", - "ContractTermActionType", - "ContractTermActionSubjectType", - "ContractTermAssetType", - "ContractTermAssetContextType", - "ContractTermAssetValuedItemType", - "ContractTermOfferType", - "ContractTermOfferAnswerType", - "ContractTermOfferPartyType", - "ContractTermSecurityLabelType", - "ContributorType", - "CountType", - "CoverageType", - "CoverageClassType", - "CoverageCostToBeneficiaryType", - "CoverageCostToBeneficiaryExceptionType", - "CoverageEligibilityRequestType", - "CoverageEligibilityRequestInsuranceType", - "CoverageEligibilityRequestItemType", - "CoverageEligibilityRequestItemDiagnosisType", - "CoverageEligibilityRequestSupportingInfoType", - "CoverageEligibilityResponseType", - "CoverageEligibilityResponseErrorType", - "CoverageEligibilityResponseInsuranceType", - "CoverageEligibilityResponseInsuranceItemType", - "CoverageEligibilityResponseInsuranceItemBenefitType", - "DataRequirementType", - "DataRequirementCodeFilterType", - "DataRequirementDateFilterType", - "DataRequirementSortType", - "DetectedIssueType", - "DetectedIssueEvidenceType", - "DetectedIssueMitigationType", - "DeviceType", - "DeviceDefinitionType", - "DeviceDefinitionCapabilityType", - "DeviceDefinitionDeviceNameType", - "DeviceDefinitionMaterialType", - "DeviceDefinitionPropertyType", - "DeviceDefinitionSpecializationType", - "DeviceDefinitionUdiDeviceIdentifierType", - "DeviceDeviceNameType", - "DeviceMetricType", - "DeviceMetricCalibrationType", - "DevicePropertyType", - "DeviceRequestType", - "DeviceRequestParameterType", - "DeviceSpecializationType", - "DeviceUdiCarrierType", - "DeviceUseStatementType", - "DeviceVersionType", - "DiagnosticReportType", - "DiagnosticReportMediaType", - "DistanceType", - "DocumentManifestType", - "DocumentManifestRelatedType", - "DocumentReferenceType", - "DocumentReferenceContentType", - "DocumentReferenceContextType", - "DocumentReferenceRelatesToType", - "DomainResourceType", - "DosageType", - "DosageDoseAndRateType", - "DurationType", - "EffectEvidenceSynthesisType", - "EffectEvidenceSynthesisCertaintyType", - "EffectEvidenceSynthesisCertaintyCertaintySubcomponentType", - "EffectEvidenceSynthesisEffectEstimateType", - "EffectEvidenceSynthesisEffectEstimatePrecisionEstimateType", - "EffectEvidenceSynthesisResultsByExposureType", - "EffectEvidenceSynthesisSampleSizeType", - "ElementDefinitionType", - "ElementDefinitionBaseType", - "ElementDefinitionBindingType", - "ElementDefinitionConstraintType", - "ElementDefinitionExampleType", - "ElementDefinitionMappingType", - "ElementDefinitionSlicingType", - "ElementDefinitionSlicingDiscriminatorType", - "ElementDefinitionTypeType", - "EncounterType", - "EncounterClassHistoryType", - "EncounterDiagnosisType", - "EncounterHospitalizationType", - "EncounterLocationType", - "EncounterParticipantType", - "EncounterStatusHistoryType", - "EndpointType", - "EnrollmentRequestType", - "EnrollmentResponseType", - "EpisodeOfCareType", - "EpisodeOfCareDiagnosisType", - "EpisodeOfCareStatusHistoryType", - "EventDefinitionType", - "EvidenceType", - "EvidenceVariableType", - "EvidenceVariableCharacteristicType", - "ExampleScenarioType", - "ExampleScenarioActorType", - "ExampleScenarioInstanceType", - "ExampleScenarioInstanceContainedInstanceType", - "ExampleScenarioInstanceVersionType", - "ExampleScenarioProcessType", - "ExampleScenarioProcessStepType", - "ExampleScenarioProcessStepAlternativeType", - "ExampleScenarioProcessStepOperationType", - "ExplanationOfBenefitType", - "ExplanationOfBenefitAccidentType", - "ExplanationOfBenefitAddItemType", - "ExplanationOfBenefitAddItemDetailType", - "ExplanationOfBenefitAddItemDetailSubDetailType", - "ExplanationOfBenefitBenefitBalanceType", - "ExplanationOfBenefitBenefitBalanceFinancialType", - "ExplanationOfBenefitCareTeamType", - "ExplanationOfBenefitDiagnosisType", - "ExplanationOfBenefitInsuranceType", - "ExplanationOfBenefitItemType", - "ExplanationOfBenefitItemAdjudicationType", - "ExplanationOfBenefitItemDetailType", - "ExplanationOfBenefitItemDetailSubDetailType", - "ExplanationOfBenefitPayeeType", - "ExplanationOfBenefitPaymentType", - "ExplanationOfBenefitProcedureType", - "ExplanationOfBenefitProcessNoteType", - "ExplanationOfBenefitRelatedType", - "ExplanationOfBenefitSupportingInfoType", - "ExplanationOfBenefitTotalType", - "ExpressionType", - "ExtensionType", - "FamilyMemberHistoryType", - "FamilyMemberHistoryConditionType", - "FlagType", - "GoalType", - "GoalTargetType", - "GraphDefinitionType", - "GraphDefinitionLinkType", - "GraphDefinitionLinkTargetType", - "GraphDefinitionLinkTargetCompartmentType", - "GroupType", - "GroupCharacteristicType", - "GroupMemberType", - "GuidanceResponseType", - "HealthcareServiceType", - "HealthcareServiceAvailableTimeType", - "HealthcareServiceEligibilityType", - "HealthcareServiceNotAvailableType", - "HumanNameType", - "IdentifierType", - "ImagingStudyType", - "ImagingStudySeriesType", - "ImagingStudySeriesInstanceType", - "ImagingStudySeriesPerformerType", - "ImmunizationType", - "ImmunizationEducationType", - "ImmunizationEvaluationType", - "ImmunizationPerformerType", - "ImmunizationProtocolAppliedType", - "ImmunizationReactionType", - "ImmunizationRecommendationType", - "ImmunizationRecommendationRecommendationType", - "ImmunizationRecommendationRecommendationDateCriterionType", - "ImplementationGuideType", - "ImplementationGuideDefinitionType", - "ImplementationGuideDefinitionGroupingType", - "ImplementationGuideDefinitionPageType", - "ImplementationGuideDefinitionParameterType", - "ImplementationGuideDefinitionResourceType", - "ImplementationGuideDefinitionTemplateType", - "ImplementationGuideDependsOnType", - "ImplementationGuideGlobalType", - "ImplementationGuideManifestType", - "ImplementationGuideManifestPageType", - "ImplementationGuideManifestResourceType", - "InsurancePlanType", - "InsurancePlanContactType", - "InsurancePlanCoverageType", - "InsurancePlanCoverageBenefitType", - "InsurancePlanCoverageBenefitLimitType", - "InsurancePlanPlanType", - "InsurancePlanPlanGeneralCostType", - "InsurancePlanPlanSpecificCostType", - "InsurancePlanPlanSpecificCostBenefitType", - "InsurancePlanPlanSpecificCostBenefitCostType", - "InvoiceType", - "InvoiceLineItemType", - "InvoiceLineItemPriceComponentType", - "InvoiceParticipantType", - "LibraryType", - "LinkageType", - "LinkageItemType", - "ListType", - "ListEntryType", - "LocationType", - "LocationHoursOfOperationType", - "LocationPositionType", - "MarketingStatusType", - "MeasureType", - "MeasureGroupType", - "MeasureGroupPopulationType", - "MeasureGroupStratifierType", - "MeasureGroupStratifierComponentType", - "MeasureReportType", - "MeasureReportGroupType", - "MeasureReportGroupPopulationType", - "MeasureReportGroupStratifierType", - "MeasureReportGroupStratifierStratumType", - "MeasureReportGroupStratifierStratumComponentType", - "MeasureReportGroupStratifierStratumPopulationType", - "MeasureSupplementalDataType", - "MediaType", - "MedicationType", - "MedicationAdministrationType", - "MedicationAdministrationDosageType", - "MedicationAdministrationPerformerType", - "MedicationBatchType", - "MedicationDispenseType", - "MedicationDispensePerformerType", - "MedicationDispenseSubstitutionType", - "MedicationIngredientType", - "MedicationKnowledgeType", - "MedicationKnowledgeAdministrationGuidelinesType", - "MedicationKnowledgeAdministrationGuidelinesDosageType", - "MedicationKnowledgeAdministrationGuidelinesPatientCharacteristicsType", - "MedicationKnowledgeCostType", - "MedicationKnowledgeDrugCharacteristicType", - "MedicationKnowledgeIngredientType", - "MedicationKnowledgeKineticsType", - "MedicationKnowledgeMedicineClassificationType", - "MedicationKnowledgeMonitoringProgramType", - "MedicationKnowledgeMonographType", - "MedicationKnowledgePackagingType", - "MedicationKnowledgeRegulatoryType", - "MedicationKnowledgeRegulatoryMaxDispenseType", - "MedicationKnowledgeRegulatoryScheduleType", - "MedicationKnowledgeRegulatorySubstitutionType", - "MedicationKnowledgeRelatedMedicationKnowledgeType", - "MedicationRequestType", - "MedicationRequestDispenseRequestType", - "MedicationRequestDispenseRequestInitialFillType", - "MedicationRequestSubstitutionType", - "MedicationStatementType", - "MedicinalProductType", - "MedicinalProductAuthorizationType", - "MedicinalProductAuthorizationJurisdictionalAuthorizationType", - "MedicinalProductAuthorizationProcedureType", - "MedicinalProductContraindicationType", - "MedicinalProductContraindicationOtherTherapyType", - "MedicinalProductIndicationType", - "MedicinalProductIndicationOtherTherapyType", - "MedicinalProductIngredientType", - "MedicinalProductIngredientSpecifiedSubstanceType", - "MedicinalProductIngredientSpecifiedSubstanceStrengthType", - "MedicinalProductIngredientSpecifiedSubstanceStrengthReferenceStrengthType", - "MedicinalProductIngredientSubstanceType", - "MedicinalProductInteractionType", - "MedicinalProductInteractionInteractantType", - "MedicinalProductManufacturedType", - "MedicinalProductManufacturingBusinessOperationType", - "MedicinalProductNameType", - "MedicinalProductNameCountryLanguageType", - "MedicinalProductNameNamePartType", - "MedicinalProductPackagedType", - "MedicinalProductPackagedBatchIdentifierType", - "MedicinalProductPackagedPackageItemType", - "MedicinalProductPharmaceuticalType", - "MedicinalProductPharmaceuticalCharacteristicsType", - "MedicinalProductPharmaceuticalRouteOfAdministrationType", - "MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesType", - "MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesWithdrawalPeriodType", - "MedicinalProductSpecialDesignationType", - "MedicinalProductUndesirableEffectType", - "MessageDefinitionType", - "MessageDefinitionAllowedResponseType", - "MessageDefinitionFocusType", - "MessageHeaderType", - "MessageHeaderDestinationType", - "MessageHeaderResponseType", - "MessageHeaderSourceType", - "MetaType", - "MetadataResourceType", - "MolecularSequenceType", - "MolecularSequenceQualityType", - "MolecularSequenceQualityRocType", - "MolecularSequenceReferenceSeqType", - "MolecularSequenceRepositoryType", - "MolecularSequenceStructureVariantType", - "MolecularSequenceStructureVariantInnerType", - "MolecularSequenceStructureVariantOuterType", - "MolecularSequenceVariantType", - "MoneyType", - "NamingSystemType", - "NamingSystemUniqueIdType", - "NarrativeType", - "NutritionOrderType", - "NutritionOrderEnteralFormulaType", - "NutritionOrderEnteralFormulaAdministrationType", - "NutritionOrderOralDietType", - "NutritionOrderOralDietNutrientType", - "NutritionOrderOralDietTextureType", - "NutritionOrderSupplementType", - "ObservationType", - "ObservationComponentType", - "ObservationDefinitionType", - "ObservationDefinitionQualifiedIntervalType", - "ObservationDefinitionQuantitativeDetailsType", - "ObservationReferenceRangeType", - "OperationDefinitionType", - "OperationDefinitionOverloadType", - "OperationDefinitionParameterType", - "OperationDefinitionParameterBindingType", - "OperationDefinitionParameterReferencedFromType", - "OperationOutcomeType", - "OperationOutcomeIssueType", - "OrganizationType", - "OrganizationAffiliationType", - "OrganizationContactType", - "ParameterDefinitionType", - "ParametersType", - "ParametersParameterType", - "PatientType", - "PatientCommunicationType", - "PatientContactType", - "PatientLinkType", - "PaymentNoticeType", - "PaymentReconciliationType", - "PaymentReconciliationDetailType", - "PaymentReconciliationProcessNoteType", - "PeriodType", - "PersonType", - "PersonLinkType", - "PlanDefinitionType", - "PlanDefinitionActionType", - "PlanDefinitionActionConditionType", - "PlanDefinitionActionDynamicValueType", - "PlanDefinitionActionParticipantType", - "PlanDefinitionActionRelatedActionType", - "PlanDefinitionGoalType", - "PlanDefinitionGoalTargetType", - "PopulationType", - "PractitionerType", - "PractitionerQualificationType", - "PractitionerRoleType", - "PractitionerRoleAvailableTimeType", - "PractitionerRoleNotAvailableType", - "ProcedureType", - "ProcedureFocalDeviceType", - "ProcedurePerformerType", - "ProdCharacteristicType", - "ProductShelfLifeType", - "ProvenanceType", - "ProvenanceAgentType", - "ProvenanceEntityType", - "QuantityType", - "QuestionnaireType", - "QuestionnaireItemType", - "QuestionnaireItemAnswerOptionType", - "QuestionnaireItemEnableWhenType", - "QuestionnaireItemInitialType", - "QuestionnaireResponseType", - "QuestionnaireResponseItemType", - "QuestionnaireResponseItemAnswerType", - "RangeType", - "RatioType", - "ReferenceType", - "RelatedArtifactType", - "RelatedPersonType", - "RelatedPersonCommunicationType", - "RequestGroupType", - "RequestGroupActionType", - "RequestGroupActionConditionType", - "RequestGroupActionRelatedActionType", - "ResearchDefinitionType", - "ResearchElementDefinitionType", - "ResearchElementDefinitionCharacteristicType", - "ResearchStudyType", - "ResearchStudyArmType", - "ResearchStudyObjectiveType", - "ResearchSubjectType", - "RiskAssessmentType", - "RiskAssessmentPredictionType", - "RiskEvidenceSynthesisType", - "RiskEvidenceSynthesisCertaintyType", - "RiskEvidenceSynthesisCertaintyCertaintySubcomponentType", - "RiskEvidenceSynthesisRiskEstimateType", - "RiskEvidenceSynthesisRiskEstimatePrecisionEstimateType", - "RiskEvidenceSynthesisSampleSizeType", - "SampledDataType", - "ScheduleType", - "SearchParameterType", - "SearchParameterComponentType", - "ServiceRequestType", - "SignatureType", - "SlotType", - "SpecimenType", - "SpecimenCollectionType", - "SpecimenContainerType", - "SpecimenDefinitionType", - "SpecimenDefinitionTypeTestedType", - "SpecimenDefinitionTypeTestedContainerType", - "SpecimenDefinitionTypeTestedContainerAdditiveType", - "SpecimenDefinitionTypeTestedHandlingType", - "SpecimenProcessingType", - "StructureDefinitionType", - "StructureDefinitionContextType", - "StructureDefinitionDifferentialType", - "StructureDefinitionMappingType", - "StructureDefinitionSnapshotType", - "StructureMapType", - "StructureMapGroupType", - "StructureMapGroupInputType", - "StructureMapGroupRuleType", - "StructureMapGroupRuleDependentType", - "StructureMapGroupRuleSourceType", - "StructureMapGroupRuleTargetType", - "StructureMapGroupRuleTargetParameterType", - "StructureMapStructureType", - "SubscriptionType", - "SubscriptionChannelType", - "SubstanceType", - "SubstanceAmountType", - "SubstanceAmountReferenceRangeType", - "SubstanceIngredientType", - "SubstanceInstanceType", - "SubstanceNucleicAcidType", - "SubstanceNucleicAcidSubunitType", - "SubstanceNucleicAcidSubunitLinkageType", - "SubstanceNucleicAcidSubunitSugarType", - "SubstancePolymerType", - "SubstancePolymerMonomerSetType", - "SubstancePolymerMonomerSetStartingMaterialType", - "SubstancePolymerRepeatType", - "SubstancePolymerRepeatRepeatUnitType", - "SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationType", - "SubstancePolymerRepeatRepeatUnitStructuralRepresentationType", - "SubstanceProteinType", - "SubstanceProteinSubunitType", - "SubstanceReferenceInformationType", - "SubstanceReferenceInformationClassificationType", - "SubstanceReferenceInformationGeneType", - "SubstanceReferenceInformationGeneElementType", - "SubstanceReferenceInformationTargetType", - "SubstanceSourceMaterialType", - "SubstanceSourceMaterialFractionDescriptionType", - "SubstanceSourceMaterialOrganismType", - "SubstanceSourceMaterialOrganismAuthorType", - "SubstanceSourceMaterialOrganismHybridType", - "SubstanceSourceMaterialOrganismOrganismGeneralType", - "SubstanceSourceMaterialPartDescriptionType", - "SubstanceSpecificationType", - "SubstanceSpecificationCodeType", - "SubstanceSpecificationMoietyType", - "SubstanceSpecificationNameType", - "SubstanceSpecificationNameOfficialType", - "SubstanceSpecificationPropertyType", - "SubstanceSpecificationRelationshipType", - "SubstanceSpecificationStructureType", - "SubstanceSpecificationStructureIsotopeType", - "SubstanceSpecificationStructureIsotopeMolecularWeightType", - "SubstanceSpecificationStructureRepresentationType", - "SupplyDeliveryType", - "SupplyDeliverySuppliedItemType", - "SupplyRequestType", - "SupplyRequestParameterType", - "TaskType", - "TaskInputType", - "TaskOutputType", - "TaskRestrictionType", - "TerminologyCapabilitiesType", - "TerminologyCapabilitiesClosureType", - "TerminologyCapabilitiesCodeSystemType", - "TerminologyCapabilitiesCodeSystemVersionType", - "TerminologyCapabilitiesCodeSystemVersionFilterType", - "TerminologyCapabilitiesExpansionType", - "TerminologyCapabilitiesExpansionParameterType", - "TerminologyCapabilitiesImplementationType", - "TerminologyCapabilitiesSoftwareType", - "TerminologyCapabilitiesTranslationType", - "TerminologyCapabilitiesValidateCodeType", - "TestReportType", - "TestReportParticipantType", - "TestReportSetupType", - "TestReportSetupActionType", - "TestReportSetupActionAssertType", - "TestReportSetupActionOperationType", - "TestReportTeardownType", - "TestReportTeardownActionType", - "TestReportTestType", - "TestReportTestActionType", - "TestScriptType", - "TestScriptDestinationType", - "TestScriptFixtureType", - "TestScriptMetadataType", - "TestScriptMetadataCapabilityType", - "TestScriptMetadataLinkType", - "TestScriptOriginType", - "TestScriptSetupType", - "TestScriptSetupActionType", - "TestScriptSetupActionAssertType", - "TestScriptSetupActionOperationType", - "TestScriptSetupActionOperationRequestHeaderType", - "TestScriptTeardownType", - "TestScriptTeardownActionType", - "TestScriptTestType", - "TestScriptTestActionType", - "TestScriptVariableType", - "TimingType", - "TimingRepeatType", - "TriggerDefinitionType", - "UsageContextType", - "ValueSetType", - "ValueSetComposeType", - "ValueSetComposeIncludeType", - "ValueSetComposeIncludeConceptType", - "ValueSetComposeIncludeConceptDesignationType", - "ValueSetComposeIncludeFilterType", - "ValueSetExpansionType", - "ValueSetExpansionContainsType", - "ValueSetExpansionParameterType", - "VerificationResultType", - "VerificationResultAttestationType", - "VerificationResultPrimarySourceType", - "VerificationResultValidatorType", - "VisionPrescriptionType", - "VisionPrescriptionLensSpecificationType", - "VisionPrescriptionLensSpecificationPrismType", -] diff --git a/fhir/resources/fhirtypesvalidators.py b/fhir/resources/fhirtypesvalidators.py deleted file mode 100644 index 495a97e0..00000000 --- a/fhir/resources/fhirtypesvalidators.py +++ /dev/null @@ -1,5559 +0,0 @@ -# _*_ coding: utf-8 _*_ -"""Validators for ``pydantic`` Custom DataType""" -import importlib -import typing -from pathlib import Path -from typing import Union - -from pydantic.class_validators import make_generic_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.types import StrBytes -from pydantic.utils import ROOT_KEY - -from fhir.resources.core.fhirabstractmodel import FHIRAbstractModel - -if typing.TYPE_CHECKING: - from pydantic import BaseModel - -__author__ = "Md Nazrul Islam" - -MODEL_CLASSES = { - "FHIRPrimitiveExtension": (None, ".fhirprimitiveextension"), - "Account": (None, ".account"), - "AccountCoverage": (None, ".account"), - "AccountGuarantor": (None, ".account"), - "ActivityDefinition": (None, ".activitydefinition"), - "ActivityDefinitionDynamicValue": (None, ".activitydefinition"), - "ActivityDefinitionParticipant": (None, ".activitydefinition"), - "Address": (None, ".address"), - "AdverseEvent": (None, ".adverseevent"), - "AdverseEventSuspectEntity": (None, ".adverseevent"), - "AdverseEventSuspectEntityCausality": (None, ".adverseevent"), - "Age": (None, ".age"), - "AllergyIntolerance": (None, ".allergyintolerance"), - "AllergyIntoleranceReaction": (None, ".allergyintolerance"), - "Annotation": (None, ".annotation"), - "Appointment": (None, ".appointment"), - "AppointmentParticipant": (None, ".appointment"), - "AppointmentResponse": (None, ".appointmentresponse"), - "Attachment": (None, ".attachment"), - "AuditEvent": (None, ".auditevent"), - "AuditEventAgent": (None, ".auditevent"), - "AuditEventAgentNetwork": (None, ".auditevent"), - "AuditEventEntity": (None, ".auditevent"), - "AuditEventEntityDetail": (None, ".auditevent"), - "AuditEventSource": (None, ".auditevent"), - "BackboneElement": (None, ".backboneelement"), - "Basic": (None, ".basic"), - "Binary": (None, ".binary"), - "BiologicallyDerivedProduct": (None, ".biologicallyderivedproduct"), - "BiologicallyDerivedProductCollection": (None, ".biologicallyderivedproduct"), - "BiologicallyDerivedProductManipulation": (None, ".biologicallyderivedproduct"), - "BiologicallyDerivedProductProcessing": (None, ".biologicallyderivedproduct"), - "BiologicallyDerivedProductStorage": (None, ".biologicallyderivedproduct"), - "BodyStructure": (None, ".bodystructure"), - "Bundle": (None, ".bundle"), - "BundleEntry": (None, ".bundle"), - "BundleEntryRequest": (None, ".bundle"), - "BundleEntryResponse": (None, ".bundle"), - "BundleEntrySearch": (None, ".bundle"), - "BundleLink": (None, ".bundle"), - "CapabilityStatement": (None, ".capabilitystatement"), - "CapabilityStatementDocument": (None, ".capabilitystatement"), - "CapabilityStatementImplementation": (None, ".capabilitystatement"), - "CapabilityStatementMessaging": (None, ".capabilitystatement"), - "CapabilityStatementMessagingEndpoint": (None, ".capabilitystatement"), - "CapabilityStatementMessagingSupportedMessage": (None, ".capabilitystatement"), - "CapabilityStatementRest": (None, ".capabilitystatement"), - "CapabilityStatementRestInteraction": (None, ".capabilitystatement"), - "CapabilityStatementRestResource": (None, ".capabilitystatement"), - "CapabilityStatementRestResourceInteraction": (None, ".capabilitystatement"), - "CapabilityStatementRestResourceOperation": (None, ".capabilitystatement"), - "CapabilityStatementRestResourceSearchParam": (None, ".capabilitystatement"), - "CapabilityStatementRestSecurity": (None, ".capabilitystatement"), - "CapabilityStatementSoftware": (None, ".capabilitystatement"), - "CarePlan": (None, ".careplan"), - "CarePlanActivity": (None, ".careplan"), - "CarePlanActivityDetail": (None, ".careplan"), - "CareTeam": (None, ".careteam"), - "CareTeamParticipant": (None, ".careteam"), - "CatalogEntry": (None, ".catalogentry"), - "CatalogEntryRelatedEntry": (None, ".catalogentry"), - "ChargeItem": (None, ".chargeitem"), - "ChargeItemDefinition": (None, ".chargeitemdefinition"), - "ChargeItemDefinitionApplicability": (None, ".chargeitemdefinition"), - "ChargeItemDefinitionPropertyGroup": (None, ".chargeitemdefinition"), - "ChargeItemDefinitionPropertyGroupPriceComponent": (None, ".chargeitemdefinition"), - "ChargeItemPerformer": (None, ".chargeitem"), - "Claim": (None, ".claim"), - "ClaimAccident": (None, ".claim"), - "ClaimCareTeam": (None, ".claim"), - "ClaimDiagnosis": (None, ".claim"), - "ClaimInsurance": (None, ".claim"), - "ClaimItem": (None, ".claim"), - "ClaimItemDetail": (None, ".claim"), - "ClaimItemDetailSubDetail": (None, ".claim"), - "ClaimPayee": (None, ".claim"), - "ClaimProcedure": (None, ".claim"), - "ClaimRelated": (None, ".claim"), - "ClaimResponse": (None, ".claimresponse"), - "ClaimResponseAddItem": (None, ".claimresponse"), - "ClaimResponseAddItemDetail": (None, ".claimresponse"), - "ClaimResponseAddItemDetailSubDetail": (None, ".claimresponse"), - "ClaimResponseError": (None, ".claimresponse"), - "ClaimResponseInsurance": (None, ".claimresponse"), - "ClaimResponseItem": (None, ".claimresponse"), - "ClaimResponseItemAdjudication": (None, ".claimresponse"), - "ClaimResponseItemDetail": (None, ".claimresponse"), - "ClaimResponseItemDetailSubDetail": (None, ".claimresponse"), - "ClaimResponsePayment": (None, ".claimresponse"), - "ClaimResponseProcessNote": (None, ".claimresponse"), - "ClaimResponseTotal": (None, ".claimresponse"), - "ClaimSupportingInfo": (None, ".claim"), - "ClinicalImpression": (None, ".clinicalimpression"), - "ClinicalImpressionFinding": (None, ".clinicalimpression"), - "ClinicalImpressionInvestigation": (None, ".clinicalimpression"), - "CodeSystem": (None, ".codesystem"), - "CodeSystemConcept": (None, ".codesystem"), - "CodeSystemConceptDesignation": (None, ".codesystem"), - "CodeSystemConceptProperty": (None, ".codesystem"), - "CodeSystemFilter": (None, ".codesystem"), - "CodeSystemProperty": (None, ".codesystem"), - "CodeableConcept": (None, ".codeableconcept"), - "Coding": (None, ".coding"), - "Communication": (None, ".communication"), - "CommunicationPayload": (None, ".communication"), - "CommunicationRequest": (None, ".communicationrequest"), - "CommunicationRequestPayload": (None, ".communicationrequest"), - "CompartmentDefinition": (None, ".compartmentdefinition"), - "CompartmentDefinitionResource": (None, ".compartmentdefinition"), - "Composition": (None, ".composition"), - "CompositionAttester": (None, ".composition"), - "CompositionEvent": (None, ".composition"), - "CompositionRelatesTo": (None, ".composition"), - "CompositionSection": (None, ".composition"), - "ConceptMap": (None, ".conceptmap"), - "ConceptMapGroup": (None, ".conceptmap"), - "ConceptMapGroupElement": (None, ".conceptmap"), - "ConceptMapGroupElementTarget": (None, ".conceptmap"), - "ConceptMapGroupElementTargetDependsOn": (None, ".conceptmap"), - "ConceptMapGroupUnmapped": (None, ".conceptmap"), - "Condition": (None, ".condition"), - "ConditionEvidence": (None, ".condition"), - "ConditionStage": (None, ".condition"), - "Consent": (None, ".consent"), - "ConsentPolicy": (None, ".consent"), - "ConsentProvision": (None, ".consent"), - "ConsentProvisionActor": (None, ".consent"), - "ConsentProvisionData": (None, ".consent"), - "ConsentVerification": (None, ".consent"), - "ContactDetail": (None, ".contactdetail"), - "ContactPoint": (None, ".contactpoint"), - "Contract": (None, ".contract"), - "ContractContentDefinition": (None, ".contract"), - "ContractFriendly": (None, ".contract"), - "ContractLegal": (None, ".contract"), - "ContractRule": (None, ".contract"), - "ContractSigner": (None, ".contract"), - "ContractTerm": (None, ".contract"), - "ContractTermAction": (None, ".contract"), - "ContractTermActionSubject": (None, ".contract"), - "ContractTermAsset": (None, ".contract"), - "ContractTermAssetContext": (None, ".contract"), - "ContractTermAssetValuedItem": (None, ".contract"), - "ContractTermOffer": (None, ".contract"), - "ContractTermOfferAnswer": (None, ".contract"), - "ContractTermOfferParty": (None, ".contract"), - "ContractTermSecurityLabel": (None, ".contract"), - "Contributor": (None, ".contributor"), - "Count": (None, ".count"), - "Coverage": (None, ".coverage"), - "CoverageClass": (None, ".coverage"), - "CoverageCostToBeneficiary": (None, ".coverage"), - "CoverageCostToBeneficiaryException": (None, ".coverage"), - "CoverageEligibilityRequest": (None, ".coverageeligibilityrequest"), - "CoverageEligibilityRequestInsurance": (None, ".coverageeligibilityrequest"), - "CoverageEligibilityRequestItem": (None, ".coverageeligibilityrequest"), - "CoverageEligibilityRequestItemDiagnosis": (None, ".coverageeligibilityrequest"), - "CoverageEligibilityRequestSupportingInfo": (None, ".coverageeligibilityrequest"), - "CoverageEligibilityResponse": (None, ".coverageeligibilityresponse"), - "CoverageEligibilityResponseError": (None, ".coverageeligibilityresponse"), - "CoverageEligibilityResponseInsurance": (None, ".coverageeligibilityresponse"), - "CoverageEligibilityResponseInsuranceItem": (None, ".coverageeligibilityresponse"), - "CoverageEligibilityResponseInsuranceItemBenefit": ( - None, - ".coverageeligibilityresponse", - ), - "DataRequirement": (None, ".datarequirement"), - "DataRequirementCodeFilter": (None, ".datarequirement"), - "DataRequirementDateFilter": (None, ".datarequirement"), - "DataRequirementSort": (None, ".datarequirement"), - "DetectedIssue": (None, ".detectedissue"), - "DetectedIssueEvidence": (None, ".detectedissue"), - "DetectedIssueMitigation": (None, ".detectedissue"), - "Device": (None, ".device"), - "DeviceDefinition": (None, ".devicedefinition"), - "DeviceDefinitionCapability": (None, ".devicedefinition"), - "DeviceDefinitionDeviceName": (None, ".devicedefinition"), - "DeviceDefinitionMaterial": (None, ".devicedefinition"), - "DeviceDefinitionProperty": (None, ".devicedefinition"), - "DeviceDefinitionSpecialization": (None, ".devicedefinition"), - "DeviceDefinitionUdiDeviceIdentifier": (None, ".devicedefinition"), - "DeviceDeviceName": (None, ".device"), - "DeviceMetric": (None, ".devicemetric"), - "DeviceMetricCalibration": (None, ".devicemetric"), - "DeviceProperty": (None, ".device"), - "DeviceRequest": (None, ".devicerequest"), - "DeviceRequestParameter": (None, ".devicerequest"), - "DeviceSpecialization": (None, ".device"), - "DeviceUdiCarrier": (None, ".device"), - "DeviceUseStatement": (None, ".deviceusestatement"), - "DeviceVersion": (None, ".device"), - "DiagnosticReport": (None, ".diagnosticreport"), - "DiagnosticReportMedia": (None, ".diagnosticreport"), - "Distance": (None, ".distance"), - "DocumentManifest": (None, ".documentmanifest"), - "DocumentManifestRelated": (None, ".documentmanifest"), - "DocumentReference": (None, ".documentreference"), - "DocumentReferenceContent": (None, ".documentreference"), - "DocumentReferenceContext": (None, ".documentreference"), - "DocumentReferenceRelatesTo": (None, ".documentreference"), - "DomainResource": (None, ".domainresource"), - "Dosage": (None, ".dosage"), - "DosageDoseAndRate": (None, ".dosage"), - "Duration": (None, ".duration"), - "EffectEvidenceSynthesis": (None, ".effectevidencesynthesis"), - "EffectEvidenceSynthesisCertainty": (None, ".effectevidencesynthesis"), - "EffectEvidenceSynthesisCertaintyCertaintySubcomponent": ( - None, - ".effectevidencesynthesis", - ), - "EffectEvidenceSynthesisEffectEstimate": (None, ".effectevidencesynthesis"), - "EffectEvidenceSynthesisEffectEstimatePrecisionEstimate": ( - None, - ".effectevidencesynthesis", - ), - "EffectEvidenceSynthesisResultsByExposure": (None, ".effectevidencesynthesis"), - "EffectEvidenceSynthesisSampleSize": (None, ".effectevidencesynthesis"), - "Element": (None, ".element"), - "ElementDefinition": (None, ".elementdefinition"), - "ElementDefinitionBase": (None, ".elementdefinition"), - "ElementDefinitionBinding": (None, ".elementdefinition"), - "ElementDefinitionConstraint": (None, ".elementdefinition"), - "ElementDefinitionExample": (None, ".elementdefinition"), - "ElementDefinitionMapping": (None, ".elementdefinition"), - "ElementDefinitionSlicing": (None, ".elementdefinition"), - "ElementDefinitionSlicingDiscriminator": (None, ".elementdefinition"), - "ElementDefinitionType": (None, ".elementdefinition"), - "Encounter": (None, ".encounter"), - "EncounterClassHistory": (None, ".encounter"), - "EncounterDiagnosis": (None, ".encounter"), - "EncounterHospitalization": (None, ".encounter"), - "EncounterLocation": (None, ".encounter"), - "EncounterParticipant": (None, ".encounter"), - "EncounterStatusHistory": (None, ".encounter"), - "Endpoint": (None, ".endpoint"), - "EnrollmentRequest": (None, ".enrollmentrequest"), - "EnrollmentResponse": (None, ".enrollmentresponse"), - "EpisodeOfCare": (None, ".episodeofcare"), - "EpisodeOfCareDiagnosis": (None, ".episodeofcare"), - "EpisodeOfCareStatusHistory": (None, ".episodeofcare"), - "EventDefinition": (None, ".eventdefinition"), - "Evidence": (None, ".evidence"), - "EvidenceVariable": (None, ".evidencevariable"), - "EvidenceVariableCharacteristic": (None, ".evidencevariable"), - "ExampleScenario": (None, ".examplescenario"), - "ExampleScenarioActor": (None, ".examplescenario"), - "ExampleScenarioInstance": (None, ".examplescenario"), - "ExampleScenarioInstanceContainedInstance": (None, ".examplescenario"), - "ExampleScenarioInstanceVersion": (None, ".examplescenario"), - "ExampleScenarioProcess": (None, ".examplescenario"), - "ExampleScenarioProcessStep": (None, ".examplescenario"), - "ExampleScenarioProcessStepAlternative": (None, ".examplescenario"), - "ExampleScenarioProcessStepOperation": (None, ".examplescenario"), - "ExplanationOfBenefit": (None, ".explanationofbenefit"), - "ExplanationOfBenefitAccident": (None, ".explanationofbenefit"), - "ExplanationOfBenefitAddItem": (None, ".explanationofbenefit"), - "ExplanationOfBenefitAddItemDetail": (None, ".explanationofbenefit"), - "ExplanationOfBenefitAddItemDetailSubDetail": (None, ".explanationofbenefit"), - "ExplanationOfBenefitBenefitBalance": (None, ".explanationofbenefit"), - "ExplanationOfBenefitBenefitBalanceFinancial": (None, ".explanationofbenefit"), - "ExplanationOfBenefitCareTeam": (None, ".explanationofbenefit"), - "ExplanationOfBenefitDiagnosis": (None, ".explanationofbenefit"), - "ExplanationOfBenefitInsurance": (None, ".explanationofbenefit"), - "ExplanationOfBenefitItem": (None, ".explanationofbenefit"), - "ExplanationOfBenefitItemAdjudication": (None, ".explanationofbenefit"), - "ExplanationOfBenefitItemDetail": (None, ".explanationofbenefit"), - "ExplanationOfBenefitItemDetailSubDetail": (None, ".explanationofbenefit"), - "ExplanationOfBenefitPayee": (None, ".explanationofbenefit"), - "ExplanationOfBenefitPayment": (None, ".explanationofbenefit"), - "ExplanationOfBenefitProcedure": (None, ".explanationofbenefit"), - "ExplanationOfBenefitProcessNote": (None, ".explanationofbenefit"), - "ExplanationOfBenefitRelated": (None, ".explanationofbenefit"), - "ExplanationOfBenefitSupportingInfo": (None, ".explanationofbenefit"), - "ExplanationOfBenefitTotal": (None, ".explanationofbenefit"), - "Expression": (None, ".expression"), - "Extension": (None, ".extension"), - "FamilyMemberHistory": (None, ".familymemberhistory"), - "FamilyMemberHistoryCondition": (None, ".familymemberhistory"), - "Flag": (None, ".flag"), - "Goal": (None, ".goal"), - "GoalTarget": (None, ".goal"), - "GraphDefinition": (None, ".graphdefinition"), - "GraphDefinitionLink": (None, ".graphdefinition"), - "GraphDefinitionLinkTarget": (None, ".graphdefinition"), - "GraphDefinitionLinkTargetCompartment": (None, ".graphdefinition"), - "Group": (None, ".group"), - "GroupCharacteristic": (None, ".group"), - "GroupMember": (None, ".group"), - "GuidanceResponse": (None, ".guidanceresponse"), - "HealthcareService": (None, ".healthcareservice"), - "HealthcareServiceAvailableTime": (None, ".healthcareservice"), - "HealthcareServiceEligibility": (None, ".healthcareservice"), - "HealthcareServiceNotAvailable": (None, ".healthcareservice"), - "HumanName": (None, ".humanname"), - "Identifier": (None, ".identifier"), - "ImagingStudy": (None, ".imagingstudy"), - "ImagingStudySeries": (None, ".imagingstudy"), - "ImagingStudySeriesInstance": (None, ".imagingstudy"), - "ImagingStudySeriesPerformer": (None, ".imagingstudy"), - "Immunization": (None, ".immunization"), - "ImmunizationEducation": (None, ".immunization"), - "ImmunizationEvaluation": (None, ".immunizationevaluation"), - "ImmunizationPerformer": (None, ".immunization"), - "ImmunizationProtocolApplied": (None, ".immunization"), - "ImmunizationReaction": (None, ".immunization"), - "ImmunizationRecommendation": (None, ".immunizationrecommendation"), - "ImmunizationRecommendationRecommendation": (None, ".immunizationrecommendation"), - "ImmunizationRecommendationRecommendationDateCriterion": ( - None, - ".immunizationrecommendation", - ), - "ImplementationGuide": (None, ".implementationguide"), - "ImplementationGuideDefinition": (None, ".implementationguide"), - "ImplementationGuideDefinitionGrouping": (None, ".implementationguide"), - "ImplementationGuideDefinitionPage": (None, ".implementationguide"), - "ImplementationGuideDefinitionParameter": (None, ".implementationguide"), - "ImplementationGuideDefinitionResource": (None, ".implementationguide"), - "ImplementationGuideDefinitionTemplate": (None, ".implementationguide"), - "ImplementationGuideDependsOn": (None, ".implementationguide"), - "ImplementationGuideGlobal": (None, ".implementationguide"), - "ImplementationGuideManifest": (None, ".implementationguide"), - "ImplementationGuideManifestPage": (None, ".implementationguide"), - "ImplementationGuideManifestResource": (None, ".implementationguide"), - "InsurancePlan": (None, ".insuranceplan"), - "InsurancePlanContact": (None, ".insuranceplan"), - "InsurancePlanCoverage": (None, ".insuranceplan"), - "InsurancePlanCoverageBenefit": (None, ".insuranceplan"), - "InsurancePlanCoverageBenefitLimit": (None, ".insuranceplan"), - "InsurancePlanPlan": (None, ".insuranceplan"), - "InsurancePlanPlanGeneralCost": (None, ".insuranceplan"), - "InsurancePlanPlanSpecificCost": (None, ".insuranceplan"), - "InsurancePlanPlanSpecificCostBenefit": (None, ".insuranceplan"), - "InsurancePlanPlanSpecificCostBenefitCost": (None, ".insuranceplan"), - "Invoice": (None, ".invoice"), - "InvoiceLineItem": (None, ".invoice"), - "InvoiceLineItemPriceComponent": (None, ".invoice"), - "InvoiceParticipant": (None, ".invoice"), - "Library": (None, ".library"), - "Linkage": (None, ".linkage"), - "LinkageItem": (None, ".linkage"), - "List": (None, ".list"), - "ListEntry": (None, ".list"), - "Location": (None, ".location"), - "LocationHoursOfOperation": (None, ".location"), - "LocationPosition": (None, ".location"), - "MarketingStatus": (None, ".marketingstatus"), - "Measure": (None, ".measure"), - "MeasureGroup": (None, ".measure"), - "MeasureGroupPopulation": (None, ".measure"), - "MeasureGroupStratifier": (None, ".measure"), - "MeasureGroupStratifierComponent": (None, ".measure"), - "MeasureReport": (None, ".measurereport"), - "MeasureReportGroup": (None, ".measurereport"), - "MeasureReportGroupPopulation": (None, ".measurereport"), - "MeasureReportGroupStratifier": (None, ".measurereport"), - "MeasureReportGroupStratifierStratum": (None, ".measurereport"), - "MeasureReportGroupStratifierStratumComponent": (None, ".measurereport"), - "MeasureReportGroupStratifierStratumPopulation": (None, ".measurereport"), - "MeasureSupplementalData": (None, ".measure"), - "Media": (None, ".media"), - "Medication": (None, ".medication"), - "MedicationAdministration": (None, ".medicationadministration"), - "MedicationAdministrationDosage": (None, ".medicationadministration"), - "MedicationAdministrationPerformer": (None, ".medicationadministration"), - "MedicationBatch": (None, ".medication"), - "MedicationDispense": (None, ".medicationdispense"), - "MedicationDispensePerformer": (None, ".medicationdispense"), - "MedicationDispenseSubstitution": (None, ".medicationdispense"), - "MedicationIngredient": (None, ".medication"), - "MedicationKnowledge": (None, ".medicationknowledge"), - "MedicationKnowledgeAdministrationGuidelines": (None, ".medicationknowledge"), - "MedicationKnowledgeAdministrationGuidelinesDosage": (None, ".medicationknowledge"), - "MedicationKnowledgeAdministrationGuidelinesPatientCharacteristics": ( - None, - ".medicationknowledge", - ), - "MedicationKnowledgeCost": (None, ".medicationknowledge"), - "MedicationKnowledgeDrugCharacteristic": (None, ".medicationknowledge"), - "MedicationKnowledgeIngredient": (None, ".medicationknowledge"), - "MedicationKnowledgeKinetics": (None, ".medicationknowledge"), - "MedicationKnowledgeMedicineClassification": (None, ".medicationknowledge"), - "MedicationKnowledgeMonitoringProgram": (None, ".medicationknowledge"), - "MedicationKnowledgeMonograph": (None, ".medicationknowledge"), - "MedicationKnowledgePackaging": (None, ".medicationknowledge"), - "MedicationKnowledgeRegulatory": (None, ".medicationknowledge"), - "MedicationKnowledgeRegulatoryMaxDispense": (None, ".medicationknowledge"), - "MedicationKnowledgeRegulatorySchedule": (None, ".medicationknowledge"), - "MedicationKnowledgeRegulatorySubstitution": (None, ".medicationknowledge"), - "MedicationKnowledgeRelatedMedicationKnowledge": (None, ".medicationknowledge"), - "MedicationRequest": (None, ".medicationrequest"), - "MedicationRequestDispenseRequest": (None, ".medicationrequest"), - "MedicationRequestDispenseRequestInitialFill": (None, ".medicationrequest"), - "MedicationRequestSubstitution": (None, ".medicationrequest"), - "MedicationStatement": (None, ".medicationstatement"), - "MedicinalProduct": (None, ".medicinalproduct"), - "MedicinalProductAuthorization": (None, ".medicinalproductauthorization"), - "MedicinalProductAuthorizationJurisdictionalAuthorization": ( - None, - ".medicinalproductauthorization", - ), - "MedicinalProductAuthorizationProcedure": (None, ".medicinalproductauthorization"), - "MedicinalProductContraindication": (None, ".medicinalproductcontraindication"), - "MedicinalProductContraindicationOtherTherapy": ( - None, - ".medicinalproductcontraindication", - ), - "MedicinalProductIndication": (None, ".medicinalproductindication"), - "MedicinalProductIndicationOtherTherapy": (None, ".medicinalproductindication"), - "MedicinalProductIngredient": (None, ".medicinalproductingredient"), - "MedicinalProductIngredientSpecifiedSubstance": ( - None, - ".medicinalproductingredient", - ), - "MedicinalProductIngredientSpecifiedSubstanceStrength": ( - None, - ".medicinalproductingredient", - ), - "MedicinalProductIngredientSpecifiedSubstanceStrengthReferenceStrength": ( - None, - ".medicinalproductingredient", - ), - "MedicinalProductIngredientSubstance": (None, ".medicinalproductingredient"), - "MedicinalProductInteraction": (None, ".medicinalproductinteraction"), - "MedicinalProductInteractionInteractant": (None, ".medicinalproductinteraction"), - "MedicinalProductManufactured": (None, ".medicinalproductmanufactured"), - "MedicinalProductManufacturingBusinessOperation": (None, ".medicinalproduct"), - "MedicinalProductName": (None, ".medicinalproduct"), - "MedicinalProductNameCountryLanguage": (None, ".medicinalproduct"), - "MedicinalProductNameNamePart": (None, ".medicinalproduct"), - "MedicinalProductPackaged": (None, ".medicinalproductpackaged"), - "MedicinalProductPackagedBatchIdentifier": (None, ".medicinalproductpackaged"), - "MedicinalProductPackagedPackageItem": (None, ".medicinalproductpackaged"), - "MedicinalProductPharmaceutical": (None, ".medicinalproductpharmaceutical"), - "MedicinalProductPharmaceuticalCharacteristics": ( - None, - ".medicinalproductpharmaceutical", - ), - "MedicinalProductPharmaceuticalRouteOfAdministration": ( - None, - ".medicinalproductpharmaceutical", - ), - "MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpecies": ( - None, - ".medicinalproductpharmaceutical", - ), - "MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesWithdrawalPeriod": ( - None, - ".medicinalproductpharmaceutical", - ), - "MedicinalProductSpecialDesignation": (None, ".medicinalproduct"), - "MedicinalProductUndesirableEffect": (None, ".medicinalproductundesirableeffect"), - "MessageDefinition": (None, ".messagedefinition"), - "MessageDefinitionAllowedResponse": (None, ".messagedefinition"), - "MessageDefinitionFocus": (None, ".messagedefinition"), - "MessageHeader": (None, ".messageheader"), - "MessageHeaderDestination": (None, ".messageheader"), - "MessageHeaderResponse": (None, ".messageheader"), - "MessageHeaderSource": (None, ".messageheader"), - "Meta": (None, ".meta"), - "MetadataResource": (None, ".metadataresource"), - "MolecularSequence": (None, ".molecularsequence"), - "MolecularSequenceQuality": (None, ".molecularsequence"), - "MolecularSequenceQualityRoc": (None, ".molecularsequence"), - "MolecularSequenceReferenceSeq": (None, ".molecularsequence"), - "MolecularSequenceRepository": (None, ".molecularsequence"), - "MolecularSequenceStructureVariant": (None, ".molecularsequence"), - "MolecularSequenceStructureVariantInner": (None, ".molecularsequence"), - "MolecularSequenceStructureVariantOuter": (None, ".molecularsequence"), - "MolecularSequenceVariant": (None, ".molecularsequence"), - "Money": (None, ".money"), - "NamingSystem": (None, ".namingsystem"), - "NamingSystemUniqueId": (None, ".namingsystem"), - "Narrative": (None, ".narrative"), - "NutritionOrder": (None, ".nutritionorder"), - "NutritionOrderEnteralFormula": (None, ".nutritionorder"), - "NutritionOrderEnteralFormulaAdministration": (None, ".nutritionorder"), - "NutritionOrderOralDiet": (None, ".nutritionorder"), - "NutritionOrderOralDietNutrient": (None, ".nutritionorder"), - "NutritionOrderOralDietTexture": (None, ".nutritionorder"), - "NutritionOrderSupplement": (None, ".nutritionorder"), - "Observation": (None, ".observation"), - "ObservationComponent": (None, ".observation"), - "ObservationDefinition": (None, ".observationdefinition"), - "ObservationDefinitionQualifiedInterval": (None, ".observationdefinition"), - "ObservationDefinitionQuantitativeDetails": (None, ".observationdefinition"), - "ObservationReferenceRange": (None, ".observation"), - "OperationDefinition": (None, ".operationdefinition"), - "OperationDefinitionOverload": (None, ".operationdefinition"), - "OperationDefinitionParameter": (None, ".operationdefinition"), - "OperationDefinitionParameterBinding": (None, ".operationdefinition"), - "OperationDefinitionParameterReferencedFrom": (None, ".operationdefinition"), - "OperationOutcome": (None, ".operationoutcome"), - "OperationOutcomeIssue": (None, ".operationoutcome"), - "Organization": (None, ".organization"), - "OrganizationAffiliation": (None, ".organizationaffiliation"), - "OrganizationContact": (None, ".organization"), - "ParameterDefinition": (None, ".parameterdefinition"), - "Parameters": (None, ".parameters"), - "ParametersParameter": (None, ".parameters"), - "Patient": (None, ".patient"), - "PatientCommunication": (None, ".patient"), - "PatientContact": (None, ".patient"), - "PatientLink": (None, ".patient"), - "PaymentNotice": (None, ".paymentnotice"), - "PaymentReconciliation": (None, ".paymentreconciliation"), - "PaymentReconciliationDetail": (None, ".paymentreconciliation"), - "PaymentReconciliationProcessNote": (None, ".paymentreconciliation"), - "Period": (None, ".period"), - "Person": (None, ".person"), - "PersonLink": (None, ".person"), - "PlanDefinition": (None, ".plandefinition"), - "PlanDefinitionAction": (None, ".plandefinition"), - "PlanDefinitionActionCondition": (None, ".plandefinition"), - "PlanDefinitionActionDynamicValue": (None, ".plandefinition"), - "PlanDefinitionActionParticipant": (None, ".plandefinition"), - "PlanDefinitionActionRelatedAction": (None, ".plandefinition"), - "PlanDefinitionGoal": (None, ".plandefinition"), - "PlanDefinitionGoalTarget": (None, ".plandefinition"), - "Population": (None, ".population"), - "Practitioner": (None, ".practitioner"), - "PractitionerQualification": (None, ".practitioner"), - "PractitionerRole": (None, ".practitionerrole"), - "PractitionerRoleAvailableTime": (None, ".practitionerrole"), - "PractitionerRoleNotAvailable": (None, ".practitionerrole"), - "Procedure": (None, ".procedure"), - "ProcedureFocalDevice": (None, ".procedure"), - "ProcedurePerformer": (None, ".procedure"), - "ProdCharacteristic": (None, ".prodcharacteristic"), - "ProductShelfLife": (None, ".productshelflife"), - "Provenance": (None, ".provenance"), - "ProvenanceAgent": (None, ".provenance"), - "ProvenanceEntity": (None, ".provenance"), - "Quantity": (None, ".quantity"), - "Questionnaire": (None, ".questionnaire"), - "QuestionnaireItem": (None, ".questionnaire"), - "QuestionnaireItemAnswerOption": (None, ".questionnaire"), - "QuestionnaireItemEnableWhen": (None, ".questionnaire"), - "QuestionnaireItemInitial": (None, ".questionnaire"), - "QuestionnaireResponse": (None, ".questionnaireresponse"), - "QuestionnaireResponseItem": (None, ".questionnaireresponse"), - "QuestionnaireResponseItemAnswer": (None, ".questionnaireresponse"), - "Range": (None, ".range"), - "Ratio": (None, ".ratio"), - "Reference": (None, ".reference"), - "RelatedArtifact": (None, ".relatedartifact"), - "RelatedPerson": (None, ".relatedperson"), - "RelatedPersonCommunication": (None, ".relatedperson"), - "RequestGroup": (None, ".requestgroup"), - "RequestGroupAction": (None, ".requestgroup"), - "RequestGroupActionCondition": (None, ".requestgroup"), - "RequestGroupActionRelatedAction": (None, ".requestgroup"), - "ResearchDefinition": (None, ".researchdefinition"), - "ResearchElementDefinition": (None, ".researchelementdefinition"), - "ResearchElementDefinitionCharacteristic": (None, ".researchelementdefinition"), - "ResearchStudy": (None, ".researchstudy"), - "ResearchStudyArm": (None, ".researchstudy"), - "ResearchStudyObjective": (None, ".researchstudy"), - "ResearchSubject": (None, ".researchsubject"), - "Resource": (None, ".resource"), - "RiskAssessment": (None, ".riskassessment"), - "RiskAssessmentPrediction": (None, ".riskassessment"), - "RiskEvidenceSynthesis": (None, ".riskevidencesynthesis"), - "RiskEvidenceSynthesisCertainty": (None, ".riskevidencesynthesis"), - "RiskEvidenceSynthesisCertaintyCertaintySubcomponent": ( - None, - ".riskevidencesynthesis", - ), - "RiskEvidenceSynthesisRiskEstimate": (None, ".riskevidencesynthesis"), - "RiskEvidenceSynthesisRiskEstimatePrecisionEstimate": ( - None, - ".riskevidencesynthesis", - ), - "RiskEvidenceSynthesisSampleSize": (None, ".riskevidencesynthesis"), - "SampledData": (None, ".sampleddata"), - "Schedule": (None, ".schedule"), - "SearchParameter": (None, ".searchparameter"), - "SearchParameterComponent": (None, ".searchparameter"), - "ServiceRequest": (None, ".servicerequest"), - "Signature": (None, ".signature"), - "Slot": (None, ".slot"), - "Specimen": (None, ".specimen"), - "SpecimenCollection": (None, ".specimen"), - "SpecimenContainer": (None, ".specimen"), - "SpecimenDefinition": (None, ".specimendefinition"), - "SpecimenDefinitionTypeTested": (None, ".specimendefinition"), - "SpecimenDefinitionTypeTestedContainer": (None, ".specimendefinition"), - "SpecimenDefinitionTypeTestedContainerAdditive": (None, ".specimendefinition"), - "SpecimenDefinitionTypeTestedHandling": (None, ".specimendefinition"), - "SpecimenProcessing": (None, ".specimen"), - "StructureDefinition": (None, ".structuredefinition"), - "StructureDefinitionContext": (None, ".structuredefinition"), - "StructureDefinitionDifferential": (None, ".structuredefinition"), - "StructureDefinitionMapping": (None, ".structuredefinition"), - "StructureDefinitionSnapshot": (None, ".structuredefinition"), - "StructureMap": (None, ".structuremap"), - "StructureMapGroup": (None, ".structuremap"), - "StructureMapGroupInput": (None, ".structuremap"), - "StructureMapGroupRule": (None, ".structuremap"), - "StructureMapGroupRuleDependent": (None, ".structuremap"), - "StructureMapGroupRuleSource": (None, ".structuremap"), - "StructureMapGroupRuleTarget": (None, ".structuremap"), - "StructureMapGroupRuleTargetParameter": (None, ".structuremap"), - "StructureMapStructure": (None, ".structuremap"), - "Subscription": (None, ".subscription"), - "SubscriptionChannel": (None, ".subscription"), - "Substance": (None, ".substance"), - "SubstanceAmount": (None, ".substanceamount"), - "SubstanceAmountReferenceRange": (None, ".substanceamount"), - "SubstanceIngredient": (None, ".substance"), - "SubstanceInstance": (None, ".substance"), - "SubstanceNucleicAcid": (None, ".substancenucleicacid"), - "SubstanceNucleicAcidSubunit": (None, ".substancenucleicacid"), - "SubstanceNucleicAcidSubunitLinkage": (None, ".substancenucleicacid"), - "SubstanceNucleicAcidSubunitSugar": (None, ".substancenucleicacid"), - "SubstancePolymer": (None, ".substancepolymer"), - "SubstancePolymerMonomerSet": (None, ".substancepolymer"), - "SubstancePolymerMonomerSetStartingMaterial": (None, ".substancepolymer"), - "SubstancePolymerRepeat": (None, ".substancepolymer"), - "SubstancePolymerRepeatRepeatUnit": (None, ".substancepolymer"), - "SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisation": ( - None, - ".substancepolymer", - ), - "SubstancePolymerRepeatRepeatUnitStructuralRepresentation": ( - None, - ".substancepolymer", - ), - "SubstanceProtein": (None, ".substanceprotein"), - "SubstanceProteinSubunit": (None, ".substanceprotein"), - "SubstanceReferenceInformation": (None, ".substancereferenceinformation"), - "SubstanceReferenceInformationClassification": ( - None, - ".substancereferenceinformation", - ), - "SubstanceReferenceInformationGene": (None, ".substancereferenceinformation"), - "SubstanceReferenceInformationGeneElement": ( - None, - ".substancereferenceinformation", - ), - "SubstanceReferenceInformationTarget": (None, ".substancereferenceinformation"), - "SubstanceSourceMaterial": (None, ".substancesourcematerial"), - "SubstanceSourceMaterialFractionDescription": (None, ".substancesourcematerial"), - "SubstanceSourceMaterialOrganism": (None, ".substancesourcematerial"), - "SubstanceSourceMaterialOrganismAuthor": (None, ".substancesourcematerial"), - "SubstanceSourceMaterialOrganismHybrid": (None, ".substancesourcematerial"), - "SubstanceSourceMaterialOrganismOrganismGeneral": ( - None, - ".substancesourcematerial", - ), - "SubstanceSourceMaterialPartDescription": (None, ".substancesourcematerial"), - "SubstanceSpecification": (None, ".substancespecification"), - "SubstanceSpecificationCode": (None, ".substancespecification"), - "SubstanceSpecificationMoiety": (None, ".substancespecification"), - "SubstanceSpecificationName": (None, ".substancespecification"), - "SubstanceSpecificationNameOfficial": (None, ".substancespecification"), - "SubstanceSpecificationProperty": (None, ".substancespecification"), - "SubstanceSpecificationRelationship": (None, ".substancespecification"), - "SubstanceSpecificationStructure": (None, ".substancespecification"), - "SubstanceSpecificationStructureIsotope": (None, ".substancespecification"), - "SubstanceSpecificationStructureIsotopeMolecularWeight": ( - None, - ".substancespecification", - ), - "SubstanceSpecificationStructureRepresentation": (None, ".substancespecification"), - "SupplyDelivery": (None, ".supplydelivery"), - "SupplyDeliverySuppliedItem": (None, ".supplydelivery"), - "SupplyRequest": (None, ".supplyrequest"), - "SupplyRequestParameter": (None, ".supplyrequest"), - "Task": (None, ".task"), - "TaskInput": (None, ".task"), - "TaskOutput": (None, ".task"), - "TaskRestriction": (None, ".task"), - "TerminologyCapabilities": (None, ".terminologycapabilities"), - "TerminologyCapabilitiesClosure": (None, ".terminologycapabilities"), - "TerminologyCapabilitiesCodeSystem": (None, ".terminologycapabilities"), - "TerminologyCapabilitiesCodeSystemVersion": (None, ".terminologycapabilities"), - "TerminologyCapabilitiesCodeSystemVersionFilter": ( - None, - ".terminologycapabilities", - ), - "TerminologyCapabilitiesExpansion": (None, ".terminologycapabilities"), - "TerminologyCapabilitiesExpansionParameter": (None, ".terminologycapabilities"), - "TerminologyCapabilitiesImplementation": (None, ".terminologycapabilities"), - "TerminologyCapabilitiesSoftware": (None, ".terminologycapabilities"), - "TerminologyCapabilitiesTranslation": (None, ".terminologycapabilities"), - "TerminologyCapabilitiesValidateCode": (None, ".terminologycapabilities"), - "TestReport": (None, ".testreport"), - "TestReportParticipant": (None, ".testreport"), - "TestReportSetup": (None, ".testreport"), - "TestReportSetupAction": (None, ".testreport"), - "TestReportSetupActionAssert": (None, ".testreport"), - "TestReportSetupActionOperation": (None, ".testreport"), - "TestReportTeardown": (None, ".testreport"), - "TestReportTeardownAction": (None, ".testreport"), - "TestReportTest": (None, ".testreport"), - "TestReportTestAction": (None, ".testreport"), - "TestScript": (None, ".testscript"), - "TestScriptDestination": (None, ".testscript"), - "TestScriptFixture": (None, ".testscript"), - "TestScriptMetadata": (None, ".testscript"), - "TestScriptMetadataCapability": (None, ".testscript"), - "TestScriptMetadataLink": (None, ".testscript"), - "TestScriptOrigin": (None, ".testscript"), - "TestScriptSetup": (None, ".testscript"), - "TestScriptSetupAction": (None, ".testscript"), - "TestScriptSetupActionAssert": (None, ".testscript"), - "TestScriptSetupActionOperation": (None, ".testscript"), - "TestScriptSetupActionOperationRequestHeader": (None, ".testscript"), - "TestScriptTeardown": (None, ".testscript"), - "TestScriptTeardownAction": (None, ".testscript"), - "TestScriptTest": (None, ".testscript"), - "TestScriptTestAction": (None, ".testscript"), - "TestScriptVariable": (None, ".testscript"), - "Timing": (None, ".timing"), - "TimingRepeat": (None, ".timing"), - "TriggerDefinition": (None, ".triggerdefinition"), - "UsageContext": (None, ".usagecontext"), - "ValueSet": (None, ".valueset"), - "ValueSetCompose": (None, ".valueset"), - "ValueSetComposeInclude": (None, ".valueset"), - "ValueSetComposeIncludeConcept": (None, ".valueset"), - "ValueSetComposeIncludeConceptDesignation": (None, ".valueset"), - "ValueSetComposeIncludeFilter": (None, ".valueset"), - "ValueSetExpansion": (None, ".valueset"), - "ValueSetExpansionContains": (None, ".valueset"), - "ValueSetExpansionParameter": (None, ".valueset"), - "VerificationResult": (None, ".verificationresult"), - "VerificationResultAttestation": (None, ".verificationresult"), - "VerificationResultPrimarySource": (None, ".verificationresult"), - "VerificationResultValidator": (None, ".verificationresult"), - "VisionPrescription": (None, ".visionprescription"), - "VisionPrescriptionLensSpecification": (None, ".visionprescription"), - "VisionPrescriptionLensSpecificationPrism": (None, ".visionprescription"), -} - - -def get_fhir_model_class(model_name: str) -> typing.Type[FHIRAbstractModel]: - """""" - global MODEL_CLASSES - klass, module_name = MODEL_CLASSES[model_name] - if klass is not None: - return klass - module = importlib.import_module(module_name, package=__package__) - klass = getattr(module, model_name) - MODEL_CLASSES[model_name] = (klass, module_name) - return klass - - -def run_validator_for_fhir_type(model_type_cls, v, values, config, field): - """ """ - cls = get_fhir_model_class(model_type_cls.__resource_type__) - for validator in model_type_cls.__get_validators__(): - func = make_generic_validator(validator) - v = func(cls, v, values, config, field) - return v - - -def fhir_model_validator( - model_name: str, v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - """ """ - if typing.TYPE_CHECKING: - model_class: typing.Union[ - typing.Type[BaseModel], typing.Type[FHIRAbstractModel] - ] - model_class = get_fhir_model_class(model_name) - - if isinstance(v, (str, bytes)): - try: - v = model_class.parse_raw(v) - except ValidationError as exc: - if typing.TYPE_CHECKING: - model_class = typing.cast(typing.Type[BaseModel], model_class) - errors = exc.errors() - if ( - len(errors) == 1 - and errors[0]["type"] == "value_error.jsondecode" - and errors[0]["loc"][0] == ROOT_KEY - ): - raise ValidationError( - [ - ErrorWrapper( - ValueError( - "Invalid json str value has been provided for " - f"class {model_class}" - ), - loc=ROOT_KEY, - ) - ], - model_class, - ) - - raise - - elif isinstance(v, Path): - _p = v - try: - v = model_class.parse_file(_p) - except (ValueError, TypeError) as exc: - if exc.__class__.__name__ in ("JSONDecodeError", "UnicodeDecodeError"): - raise ValidationError( - [ - ErrorWrapper( - ValueError( - f"Provided file '{_p}' for class '{model_class.__name__}' " - "as value, contains invalid json data. errors from " - f"decoder-> ''{str(exc)}''" - ), - loc=ROOT_KEY, - ) - ], - model_class, - ) - - raise - - except FileNotFoundError: - raise ValidationError( - [ - ErrorWrapper( - ValueError( - f"Provided file '{_p}' for class {model_class} " - "as value, doesn't exists." - ), - loc=ROOT_KEY, - ) - ], - model_class, - ) - - elif isinstance(v, dict): - v = model_class.parse_obj(v) - - if not isinstance(v, model_class): - raise ValidationError( - [ - ErrorWrapper( - ValueError( - "Value is expected from the instance of " - f"{model_class}, but got type {type(v)}" - ), - loc=ROOT_KEY, - ) - ], - model_class, - ) - if model_name != v.resource_type: - raise ValidationError( - [ - ErrorWrapper( - ValueError( - f"Expected resource_type is '{model_name}', " - f"but value has resource_type '{v.resource_type}'" - ), - loc=ROOT_KEY, - ) - ], - model_class, - ) - return v - - -def fhirprimitiveextension_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("FHIRPrimitiveExtension", v) - - -def account_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Account", v) - - -def accountcoverage_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AccountCoverage", v) - - -def accountguarantor_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AccountGuarantor", v) - - -def activitydefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ActivityDefinition", v) - - -def activitydefinitiondynamicvalue_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ActivityDefinitionDynamicValue", v) - - -def activitydefinitionparticipant_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ActivityDefinitionParticipant", v) - - -def address_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Address", v) - - -def adverseevent_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AdverseEvent", v) - - -def adverseeventsuspectentity_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("AdverseEventSuspectEntity", v) - - -def adverseeventsuspectentitycausality_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("AdverseEventSuspectEntityCausality", v) - - -def age_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Age", v) - - -def allergyintolerance_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AllergyIntolerance", v) - - -def allergyintolerancereaction_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("AllergyIntoleranceReaction", v) - - -def annotation_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Annotation", v) - - -def appointment_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Appointment", v) - - -def appointmentparticipant_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AppointmentParticipant", v) - - -def appointmentresponse_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AppointmentResponse", v) - - -def attachment_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Attachment", v) - - -def auditevent_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AuditEvent", v) - - -def auditeventagent_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AuditEventAgent", v) - - -def auditeventagentnetwork_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AuditEventAgentNetwork", v) - - -def auditevententity_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AuditEventEntity", v) - - -def auditevententitydetail_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AuditEventEntityDetail", v) - - -def auditeventsource_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("AuditEventSource", v) - - -def backboneelement_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("BackboneElement", v) - - -def basic_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Basic", v) - - -def binary_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Binary", v) - - -def biologicallyderivedproduct_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("BiologicallyDerivedProduct", v) - - -def biologicallyderivedproductcollection_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("BiologicallyDerivedProductCollection", v) - - -def biologicallyderivedproductmanipulation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("BiologicallyDerivedProductManipulation", v) - - -def biologicallyderivedproductprocessing_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("BiologicallyDerivedProductProcessing", v) - - -def biologicallyderivedproductstorage_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("BiologicallyDerivedProductStorage", v) - - -def bodystructure_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("BodyStructure", v) - - -def bundle_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Bundle", v) - - -def bundleentry_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("BundleEntry", v) - - -def bundleentryrequest_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("BundleEntryRequest", v) - - -def bundleentryresponse_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("BundleEntryResponse", v) - - -def bundleentrysearch_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("BundleEntrySearch", v) - - -def bundlelink_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("BundleLink", v) - - -def capabilitystatement_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CapabilityStatement", v) - - -def capabilitystatementdocument_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementDocument", v) - - -def capabilitystatementimplementation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementImplementation", v) - - -def capabilitystatementmessaging_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementMessaging", v) - - -def capabilitystatementmessagingendpoint_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementMessagingEndpoint", v) - - -def capabilitystatementmessagingsupportedmessage_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementMessagingSupportedMessage", v) - - -def capabilitystatementrest_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementRest", v) - - -def capabilitystatementrestinteraction_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementRestInteraction", v) - - -def capabilitystatementrestresource_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementRestResource", v) - - -def capabilitystatementrestresourceinteraction_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementRestResourceInteraction", v) - - -def capabilitystatementrestresourceoperation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementRestResourceOperation", v) - - -def capabilitystatementrestresourcesearchparam_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementRestResourceSearchParam", v) - - -def capabilitystatementrestsecurity_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementRestSecurity", v) - - -def capabilitystatementsoftware_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CapabilityStatementSoftware", v) - - -def careplan_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CarePlan", v) - - -def careplanactivity_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CarePlanActivity", v) - - -def careplanactivitydetail_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CarePlanActivityDetail", v) - - -def careteam_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CareTeam", v) - - -def careteamparticipant_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CareTeamParticipant", v) - - -def catalogentry_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CatalogEntry", v) - - -def catalogentryrelatedentry_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CatalogEntryRelatedEntry", v) - - -def chargeitem_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ChargeItem", v) - - -def chargeitemdefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ChargeItemDefinition", v) - - -def chargeitemdefinitionapplicability_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ChargeItemDefinitionApplicability", v) - - -def chargeitemdefinitionpropertygroup_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ChargeItemDefinitionPropertyGroup", v) - - -def chargeitemdefinitionpropertygrouppricecomponent_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ChargeItemDefinitionPropertyGroupPriceComponent", v) - - -def chargeitemperformer_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ChargeItemPerformer", v) - - -def claim_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Claim", v) - - -def claimaccident_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimAccident", v) - - -def claimcareteam_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimCareTeam", v) - - -def claimdiagnosis_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimDiagnosis", v) - - -def claiminsurance_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimInsurance", v) - - -def claimitem_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimItem", v) - - -def claimitemdetail_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimItemDetail", v) - - -def claimitemdetailsubdetail_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ClaimItemDetailSubDetail", v) - - -def claimpayee_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimPayee", v) - - -def claimprocedure_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimProcedure", v) - - -def claimrelated_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimRelated", v) - - -def claimresponse_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimResponse", v) - - -def claimresponseadditem_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimResponseAddItem", v) - - -def claimresponseadditemdetail_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ClaimResponseAddItemDetail", v) - - -def claimresponseadditemdetailsubdetail_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ClaimResponseAddItemDetailSubDetail", v) - - -def claimresponseerror_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimResponseError", v) - - -def claimresponseinsurance_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimResponseInsurance", v) - - -def claimresponseitem_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimResponseItem", v) - - -def claimresponseitemadjudication_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ClaimResponseItemAdjudication", v) - - -def claimresponseitemdetail_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ClaimResponseItemDetail", v) - - -def claimresponseitemdetailsubdetail_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ClaimResponseItemDetailSubDetail", v) - - -def claimresponsepayment_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimResponsePayment", v) - - -def claimresponseprocessnote_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ClaimResponseProcessNote", v) - - -def claimresponsetotal_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimResponseTotal", v) - - -def claimsupportinginfo_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClaimSupportingInfo", v) - - -def clinicalimpression_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ClinicalImpression", v) - - -def clinicalimpressionfinding_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ClinicalImpressionFinding", v) - - -def clinicalimpressioninvestigation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ClinicalImpressionInvestigation", v) - - -def codesystem_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CodeSystem", v) - - -def codesystemconcept_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CodeSystemConcept", v) - - -def codesystemconceptdesignation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CodeSystemConceptDesignation", v) - - -def codesystemconceptproperty_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CodeSystemConceptProperty", v) - - -def codesystemfilter_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CodeSystemFilter", v) - - -def codesystemproperty_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CodeSystemProperty", v) - - -def codeableconcept_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CodeableConcept", v) - - -def coding_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Coding", v) - - -def communication_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Communication", v) - - -def communicationpayload_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CommunicationPayload", v) - - -def communicationrequest_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CommunicationRequest", v) - - -def communicationrequestpayload_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CommunicationRequestPayload", v) - - -def compartmentdefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CompartmentDefinition", v) - - -def compartmentdefinitionresource_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CompartmentDefinitionResource", v) - - -def composition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Composition", v) - - -def compositionattester_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CompositionAttester", v) - - -def compositionevent_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CompositionEvent", v) - - -def compositionrelatesto_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CompositionRelatesTo", v) - - -def compositionsection_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CompositionSection", v) - - -def conceptmap_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ConceptMap", v) - - -def conceptmapgroup_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ConceptMapGroup", v) - - -def conceptmapgroupelement_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ConceptMapGroupElement", v) - - -def conceptmapgroupelementtarget_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ConceptMapGroupElementTarget", v) - - -def conceptmapgroupelementtargetdependson_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ConceptMapGroupElementTargetDependsOn", v) - - -def conceptmapgroupunmapped_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ConceptMapGroupUnmapped", v) - - -def condition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Condition", v) - - -def conditionevidence_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ConditionEvidence", v) - - -def conditionstage_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ConditionStage", v) - - -def consent_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Consent", v) - - -def consentpolicy_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ConsentPolicy", v) - - -def consentprovision_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ConsentProvision", v) - - -def consentprovisionactor_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ConsentProvisionActor", v) - - -def consentprovisiondata_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ConsentProvisionData", v) - - -def consentverification_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ConsentVerification", v) - - -def contactdetail_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ContactDetail", v) - - -def contactpoint_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ContactPoint", v) - - -def contract_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Contract", v) - - -def contractcontentdefinition_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ContractContentDefinition", v) - - -def contractfriendly_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ContractFriendly", v) - - -def contractlegal_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ContractLegal", v) - - -def contractrule_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ContractRule", v) - - -def contractsigner_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ContractSigner", v) - - -def contractterm_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ContractTerm", v) - - -def contracttermaction_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ContractTermAction", v) - - -def contracttermactionsubject_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ContractTermActionSubject", v) - - -def contracttermasset_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ContractTermAsset", v) - - -def contracttermassetcontext_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ContractTermAssetContext", v) - - -def contracttermassetvalueditem_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ContractTermAssetValuedItem", v) - - -def contracttermoffer_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ContractTermOffer", v) - - -def contracttermofferanswer_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ContractTermOfferAnswer", v) - - -def contracttermofferparty_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ContractTermOfferParty", v) - - -def contracttermsecuritylabel_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ContractTermSecurityLabel", v) - - -def contributor_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Contributor", v) - - -def count_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Count", v) - - -def coverage_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Coverage", v) - - -def coverageclass_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("CoverageClass", v) - - -def coveragecosttobeneficiary_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageCostToBeneficiary", v) - - -def coveragecosttobeneficiaryexception_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageCostToBeneficiaryException", v) - - -def coverageeligibilityrequest_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageEligibilityRequest", v) - - -def coverageeligibilityrequestinsurance_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageEligibilityRequestInsurance", v) - - -def coverageeligibilityrequestitem_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageEligibilityRequestItem", v) - - -def coverageeligibilityrequestitemdiagnosis_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageEligibilityRequestItemDiagnosis", v) - - -def coverageeligibilityrequestsupportinginfo_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageEligibilityRequestSupportingInfo", v) - - -def coverageeligibilityresponse_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageEligibilityResponse", v) - - -def coverageeligibilityresponseerror_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageEligibilityResponseError", v) - - -def coverageeligibilityresponseinsurance_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageEligibilityResponseInsurance", v) - - -def coverageeligibilityresponseinsuranceitem_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageEligibilityResponseInsuranceItem", v) - - -def coverageeligibilityresponseinsuranceitembenefit_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("CoverageEligibilityResponseInsuranceItemBenefit", v) - - -def datarequirement_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DataRequirement", v) - - -def datarequirementcodefilter_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DataRequirementCodeFilter", v) - - -def datarequirementdatefilter_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DataRequirementDateFilter", v) - - -def datarequirementsort_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DataRequirementSort", v) - - -def detectedissue_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DetectedIssue", v) - - -def detectedissueevidence_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DetectedIssueEvidence", v) - - -def detectedissuemitigation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DetectedIssueMitigation", v) - - -def device_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Device", v) - - -def devicedefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DeviceDefinition", v) - - -def devicedefinitioncapability_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DeviceDefinitionCapability", v) - - -def devicedefinitiondevicename_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DeviceDefinitionDeviceName", v) - - -def devicedefinitionmaterial_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DeviceDefinitionMaterial", v) - - -def devicedefinitionproperty_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DeviceDefinitionProperty", v) - - -def devicedefinitionspecialization_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DeviceDefinitionSpecialization", v) - - -def devicedefinitionudideviceidentifier_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DeviceDefinitionUdiDeviceIdentifier", v) - - -def devicedevicename_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DeviceDeviceName", v) - - -def devicemetric_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DeviceMetric", v) - - -def devicemetriccalibration_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DeviceMetricCalibration", v) - - -def deviceproperty_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DeviceProperty", v) - - -def devicerequest_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DeviceRequest", v) - - -def devicerequestparameter_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DeviceRequestParameter", v) - - -def devicespecialization_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DeviceSpecialization", v) - - -def deviceudicarrier_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DeviceUdiCarrier", v) - - -def deviceusestatement_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DeviceUseStatement", v) - - -def deviceversion_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DeviceVersion", v) - - -def diagnosticreport_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DiagnosticReport", v) - - -def diagnosticreportmedia_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DiagnosticReportMedia", v) - - -def distance_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Distance", v) - - -def documentmanifest_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DocumentManifest", v) - - -def documentmanifestrelated_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DocumentManifestRelated", v) - - -def documentreference_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DocumentReference", v) - - -def documentreferencecontent_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DocumentReferenceContent", v) - - -def documentreferencecontext_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DocumentReferenceContext", v) - - -def documentreferencerelatesto_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("DocumentReferenceRelatesTo", v) - - -def domainresource_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DomainResource", v) - - -def dosage_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Dosage", v) - - -def dosagedoseandrate_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("DosageDoseAndRate", v) - - -def duration_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Duration", v) - - -def effectevidencesynthesis_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("EffectEvidenceSynthesis", v) - - -def effectevidencesynthesiscertainty_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("EffectEvidenceSynthesisCertainty", v) - - -def effectevidencesynthesiscertaintycertaintysubcomponent_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "EffectEvidenceSynthesisCertaintyCertaintySubcomponent", v - ) - - -def effectevidencesynthesiseffectestimate_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("EffectEvidenceSynthesisEffectEstimate", v) - - -def effectevidencesynthesiseffectestimateprecisionestimate_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "EffectEvidenceSynthesisEffectEstimatePrecisionEstimate", v - ) - - -def effectevidencesynthesisresultsbyexposure_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("EffectEvidenceSynthesisResultsByExposure", v) - - -def effectevidencesynthesissamplesize_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("EffectEvidenceSynthesisSampleSize", v) - - -def element_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Element", v) - - -def elementdefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ElementDefinition", v) - - -def elementdefinitionbase_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ElementDefinitionBase", v) - - -def elementdefinitionbinding_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ElementDefinitionBinding", v) - - -def elementdefinitionconstraint_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ElementDefinitionConstraint", v) - - -def elementdefinitionexample_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ElementDefinitionExample", v) - - -def elementdefinitionmapping_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ElementDefinitionMapping", v) - - -def elementdefinitionslicing_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ElementDefinitionSlicing", v) - - -def elementdefinitionslicingdiscriminator_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ElementDefinitionSlicingDiscriminator", v) - - -def elementdefinitiontype_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ElementDefinitionType", v) - - -def encounter_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Encounter", v) - - -def encounterclasshistory_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("EncounterClassHistory", v) - - -def encounterdiagnosis_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("EncounterDiagnosis", v) - - -def encounterhospitalization_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("EncounterHospitalization", v) - - -def encounterlocation_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("EncounterLocation", v) - - -def encounterparticipant_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("EncounterParticipant", v) - - -def encounterstatushistory_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("EncounterStatusHistory", v) - - -def endpoint_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Endpoint", v) - - -def enrollmentrequest_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("EnrollmentRequest", v) - - -def enrollmentresponse_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("EnrollmentResponse", v) - - -def episodeofcare_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("EpisodeOfCare", v) - - -def episodeofcarediagnosis_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("EpisodeOfCareDiagnosis", v) - - -def episodeofcarestatushistory_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("EpisodeOfCareStatusHistory", v) - - -def eventdefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("EventDefinition", v) - - -def evidence_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Evidence", v) - - -def evidencevariable_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("EvidenceVariable", v) - - -def evidencevariablecharacteristic_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("EvidenceVariableCharacteristic", v) - - -def examplescenario_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ExampleScenario", v) - - -def examplescenarioactor_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ExampleScenarioActor", v) - - -def examplescenarioinstance_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExampleScenarioInstance", v) - - -def examplescenarioinstancecontainedinstance_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExampleScenarioInstanceContainedInstance", v) - - -def examplescenarioinstanceversion_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExampleScenarioInstanceVersion", v) - - -def examplescenarioprocess_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ExampleScenarioProcess", v) - - -def examplescenarioprocessstep_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExampleScenarioProcessStep", v) - - -def examplescenarioprocessstepalternative_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExampleScenarioProcessStepAlternative", v) - - -def examplescenarioprocessstepoperation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExampleScenarioProcessStepOperation", v) - - -def explanationofbenefit_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ExplanationOfBenefit", v) - - -def explanationofbenefitaccident_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitAccident", v) - - -def explanationofbenefitadditem_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitAddItem", v) - - -def explanationofbenefitadditemdetail_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitAddItemDetail", v) - - -def explanationofbenefitadditemdetailsubdetail_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitAddItemDetailSubDetail", v) - - -def explanationofbenefitbenefitbalance_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitBenefitBalance", v) - - -def explanationofbenefitbenefitbalancefinancial_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitBenefitBalanceFinancial", v) - - -def explanationofbenefitcareteam_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitCareTeam", v) - - -def explanationofbenefitdiagnosis_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitDiagnosis", v) - - -def explanationofbenefitinsurance_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitInsurance", v) - - -def explanationofbenefititem_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitItem", v) - - -def explanationofbenefititemadjudication_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitItemAdjudication", v) - - -def explanationofbenefititemdetail_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitItemDetail", v) - - -def explanationofbenefititemdetailsubdetail_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitItemDetailSubDetail", v) - - -def explanationofbenefitpayee_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitPayee", v) - - -def explanationofbenefitpayment_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitPayment", v) - - -def explanationofbenefitprocedure_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitProcedure", v) - - -def explanationofbenefitprocessnote_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitProcessNote", v) - - -def explanationofbenefitrelated_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitRelated", v) - - -def explanationofbenefitsupportinginfo_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitSupportingInfo", v) - - -def explanationofbenefittotal_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ExplanationOfBenefitTotal", v) - - -def expression_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Expression", v) - - -def extension_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Extension", v) - - -def familymemberhistory_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("FamilyMemberHistory", v) - - -def familymemberhistorycondition_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("FamilyMemberHistoryCondition", v) - - -def flag_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Flag", v) - - -def goal_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Goal", v) - - -def goaltarget_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("GoalTarget", v) - - -def graphdefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("GraphDefinition", v) - - -def graphdefinitionlink_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("GraphDefinitionLink", v) - - -def graphdefinitionlinktarget_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("GraphDefinitionLinkTarget", v) - - -def graphdefinitionlinktargetcompartment_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("GraphDefinitionLinkTargetCompartment", v) - - -def group_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Group", v) - - -def groupcharacteristic_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("GroupCharacteristic", v) - - -def groupmember_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("GroupMember", v) - - -def guidanceresponse_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("GuidanceResponse", v) - - -def healthcareservice_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("HealthcareService", v) - - -def healthcareserviceavailabletime_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("HealthcareServiceAvailableTime", v) - - -def healthcareserviceeligibility_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("HealthcareServiceEligibility", v) - - -def healthcareservicenotavailable_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("HealthcareServiceNotAvailable", v) - - -def humanname_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("HumanName", v) - - -def identifier_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Identifier", v) - - -def imagingstudy_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ImagingStudy", v) - - -def imagingstudyseries_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ImagingStudySeries", v) - - -def imagingstudyseriesinstance_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImagingStudySeriesInstance", v) - - -def imagingstudyseriesperformer_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImagingStudySeriesPerformer", v) - - -def immunization_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Immunization", v) - - -def immunizationeducation_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ImmunizationEducation", v) - - -def immunizationevaluation_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ImmunizationEvaluation", v) - - -def immunizationperformer_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ImmunizationPerformer", v) - - -def immunizationprotocolapplied_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImmunizationProtocolApplied", v) - - -def immunizationreaction_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ImmunizationReaction", v) - - -def immunizationrecommendation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImmunizationRecommendation", v) - - -def immunizationrecommendationrecommendation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImmunizationRecommendationRecommendation", v) - - -def immunizationrecommendationrecommendationdatecriterion_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "ImmunizationRecommendationRecommendationDateCriterion", v - ) - - -def implementationguide_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ImplementationGuide", v) - - -def implementationguidedefinition_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImplementationGuideDefinition", v) - - -def implementationguidedefinitiongrouping_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImplementationGuideDefinitionGrouping", v) - - -def implementationguidedefinitionpage_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImplementationGuideDefinitionPage", v) - - -def implementationguidedefinitionparameter_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImplementationGuideDefinitionParameter", v) - - -def implementationguidedefinitionresource_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImplementationGuideDefinitionResource", v) - - -def implementationguidedefinitiontemplate_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImplementationGuideDefinitionTemplate", v) - - -def implementationguidedependson_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImplementationGuideDependsOn", v) - - -def implementationguideglobal_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImplementationGuideGlobal", v) - - -def implementationguidemanifest_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImplementationGuideManifest", v) - - -def implementationguidemanifestpage_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImplementationGuideManifestPage", v) - - -def implementationguidemanifestresource_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ImplementationGuideManifestResource", v) - - -def insuranceplan_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("InsurancePlan", v) - - -def insuranceplancontact_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("InsurancePlanContact", v) - - -def insuranceplancoverage_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("InsurancePlanCoverage", v) - - -def insuranceplancoveragebenefit_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("InsurancePlanCoverageBenefit", v) - - -def insuranceplancoveragebenefitlimit_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("InsurancePlanCoverageBenefitLimit", v) - - -def insuranceplanplan_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("InsurancePlanPlan", v) - - -def insuranceplanplangeneralcost_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("InsurancePlanPlanGeneralCost", v) - - -def insuranceplanplanspecificcost_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("InsurancePlanPlanSpecificCost", v) - - -def insuranceplanplanspecificcostbenefit_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("InsurancePlanPlanSpecificCostBenefit", v) - - -def insuranceplanplanspecificcostbenefitcost_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("InsurancePlanPlanSpecificCostBenefitCost", v) - - -def invoice_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Invoice", v) - - -def invoicelineitem_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("InvoiceLineItem", v) - - -def invoicelineitempricecomponent_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("InvoiceLineItemPriceComponent", v) - - -def invoiceparticipant_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("InvoiceParticipant", v) - - -def library_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Library", v) - - -def linkage_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Linkage", v) - - -def linkageitem_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("LinkageItem", v) - - -def list_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("List", v) - - -def listentry_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ListEntry", v) - - -def location_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Location", v) - - -def locationhoursofoperation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("LocationHoursOfOperation", v) - - -def locationposition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("LocationPosition", v) - - -def marketingstatus_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MarketingStatus", v) - - -def measure_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Measure", v) - - -def measuregroup_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MeasureGroup", v) - - -def measuregrouppopulation_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MeasureGroupPopulation", v) - - -def measuregroupstratifier_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MeasureGroupStratifier", v) - - -def measuregroupstratifiercomponent_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MeasureGroupStratifierComponent", v) - - -def measurereport_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MeasureReport", v) - - -def measurereportgroup_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MeasureReportGroup", v) - - -def measurereportgrouppopulation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MeasureReportGroupPopulation", v) - - -def measurereportgroupstratifier_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MeasureReportGroupStratifier", v) - - -def measurereportgroupstratifierstratum_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MeasureReportGroupStratifierStratum", v) - - -def measurereportgroupstratifierstratumcomponent_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MeasureReportGroupStratifierStratumComponent", v) - - -def measurereportgroupstratifierstratumpopulation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MeasureReportGroupStratifierStratumPopulation", v) - - -def measuresupplementaldata_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MeasureSupplementalData", v) - - -def media_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Media", v) - - -def medication_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Medication", v) - - -def medicationadministration_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationAdministration", v) - - -def medicationadministrationdosage_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationAdministrationDosage", v) - - -def medicationadministrationperformer_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationAdministrationPerformer", v) - - -def medicationbatch_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MedicationBatch", v) - - -def medicationdispense_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MedicationDispense", v) - - -def medicationdispenseperformer_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationDispensePerformer", v) - - -def medicationdispensesubstitution_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationDispenseSubstitution", v) - - -def medicationingredient_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MedicationIngredient", v) - - -def medicationknowledge_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MedicationKnowledge", v) - - -def medicationknowledgeadministrationguidelines_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeAdministrationGuidelines", v) - - -def medicationknowledgeadministrationguidelinesdosage_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeAdministrationGuidelinesDosage", v) - - -def medicationknowledgeadministrationguidelinespatientcharacteristics_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "MedicationKnowledgeAdministrationGuidelinesPatientCharacteristics", v - ) - - -def medicationknowledgecost_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeCost", v) - - -def medicationknowledgedrugcharacteristic_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeDrugCharacteristic", v) - - -def medicationknowledgeingredient_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeIngredient", v) - - -def medicationknowledgekinetics_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeKinetics", v) - - -def medicationknowledgemedicineclassification_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeMedicineClassification", v) - - -def medicationknowledgemonitoringprogram_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeMonitoringProgram", v) - - -def medicationknowledgemonograph_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeMonograph", v) - - -def medicationknowledgepackaging_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgePackaging", v) - - -def medicationknowledgeregulatory_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeRegulatory", v) - - -def medicationknowledgeregulatorymaxdispense_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeRegulatoryMaxDispense", v) - - -def medicationknowledgeregulatoryschedule_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeRegulatorySchedule", v) - - -def medicationknowledgeregulatorysubstitution_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeRegulatorySubstitution", v) - - -def medicationknowledgerelatedmedicationknowledge_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationKnowledgeRelatedMedicationKnowledge", v) - - -def medicationrequest_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MedicationRequest", v) - - -def medicationrequestdispenserequest_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationRequestDispenseRequest", v) - - -def medicationrequestdispenserequestinitialfill_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationRequestDispenseRequestInitialFill", v) - - -def medicationrequestsubstitution_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicationRequestSubstitution", v) - - -def medicationstatement_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MedicationStatement", v) - - -def medicinalproduct_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MedicinalProduct", v) - - -def medicinalproductauthorization_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductAuthorization", v) - - -def medicinalproductauthorizationjurisdictionalauthorization_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "MedicinalProductAuthorizationJurisdictionalAuthorization", v - ) - - -def medicinalproductauthorizationprocedure_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductAuthorizationProcedure", v) - - -def medicinalproductcontraindication_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductContraindication", v) - - -def medicinalproductcontraindicationothertherapy_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductContraindicationOtherTherapy", v) - - -def medicinalproductindication_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductIndication", v) - - -def medicinalproductindicationothertherapy_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductIndicationOtherTherapy", v) - - -def medicinalproductingredient_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductIngredient", v) - - -def medicinalproductingredientspecifiedsubstance_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductIngredientSpecifiedSubstance", v) - - -def medicinalproductingredientspecifiedsubstancestrength_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "MedicinalProductIngredientSpecifiedSubstanceStrength", v - ) - - -def medicinalproductingredientspecifiedsubstancestrengthreferencestrength_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "MedicinalProductIngredientSpecifiedSubstanceStrengthReferenceStrength", v - ) - - -def medicinalproductingredientsubstance_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductIngredientSubstance", v) - - -def medicinalproductinteraction_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductInteraction", v) - - -def medicinalproductinteractioninteractant_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductInteractionInteractant", v) - - -def medicinalproductmanufactured_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductManufactured", v) - - -def medicinalproductmanufacturingbusinessoperation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductManufacturingBusinessOperation", v) - - -def medicinalproductname_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MedicinalProductName", v) - - -def medicinalproductnamecountrylanguage_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductNameCountryLanguage", v) - - -def medicinalproductnamenamepart_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductNameNamePart", v) - - -def medicinalproductpackaged_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductPackaged", v) - - -def medicinalproductpackagedbatchidentifier_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductPackagedBatchIdentifier", v) - - -def medicinalproductpackagedpackageitem_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductPackagedPackageItem", v) - - -def medicinalproductpharmaceutical_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductPharmaceutical", v) - - -def medicinalproductpharmaceuticalcharacteristics_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductPharmaceuticalCharacteristics", v) - - -def medicinalproductpharmaceuticalrouteofadministration_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "MedicinalProductPharmaceuticalRouteOfAdministration", v - ) - - -def medicinalproductpharmaceuticalrouteofadministrationtargetspecies_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpecies", v - ) - - -def medicinalproductpharmaceuticalrouteofadministrationtargetspecieswithdrawalperiod_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesWithdrawalPeriod", - v, - ) - - -def medicinalproductspecialdesignation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductSpecialDesignation", v) - - -def medicinalproductundesirableeffect_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MedicinalProductUndesirableEffect", v) - - -def messagedefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MessageDefinition", v) - - -def messagedefinitionallowedresponse_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MessageDefinitionAllowedResponse", v) - - -def messagedefinitionfocus_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MessageDefinitionFocus", v) - - -def messageheader_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MessageHeader", v) - - -def messageheaderdestination_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MessageHeaderDestination", v) - - -def messageheaderresponse_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MessageHeaderResponse", v) - - -def messageheadersource_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MessageHeaderSource", v) - - -def meta_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Meta", v) - - -def metadataresource_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MetadataResource", v) - - -def molecularsequence_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("MolecularSequence", v) - - -def molecularsequencequality_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MolecularSequenceQuality", v) - - -def molecularsequencequalityroc_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MolecularSequenceQualityRoc", v) - - -def molecularsequencereferenceseq_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MolecularSequenceReferenceSeq", v) - - -def molecularsequencerepository_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MolecularSequenceRepository", v) - - -def molecularsequencestructurevariant_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MolecularSequenceStructureVariant", v) - - -def molecularsequencestructurevariantinner_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MolecularSequenceStructureVariantInner", v) - - -def molecularsequencestructurevariantouter_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MolecularSequenceStructureVariantOuter", v) - - -def molecularsequencevariant_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("MolecularSequenceVariant", v) - - -def money_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Money", v) - - -def namingsystem_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("NamingSystem", v) - - -def namingsystemuniqueid_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("NamingSystemUniqueId", v) - - -def narrative_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Narrative", v) - - -def nutritionorder_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("NutritionOrder", v) - - -def nutritionorderenteralformula_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("NutritionOrderEnteralFormula", v) - - -def nutritionorderenteralformulaadministration_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("NutritionOrderEnteralFormulaAdministration", v) - - -def nutritionorderoraldiet_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("NutritionOrderOralDiet", v) - - -def nutritionorderoraldietnutrient_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("NutritionOrderOralDietNutrient", v) - - -def nutritionorderoraldiettexture_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("NutritionOrderOralDietTexture", v) - - -def nutritionordersupplement_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("NutritionOrderSupplement", v) - - -def observation_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Observation", v) - - -def observationcomponent_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ObservationComponent", v) - - -def observationdefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ObservationDefinition", v) - - -def observationdefinitionqualifiedinterval_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ObservationDefinitionQualifiedInterval", v) - - -def observationdefinitionquantitativedetails_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ObservationDefinitionQuantitativeDetails", v) - - -def observationreferencerange_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ObservationReferenceRange", v) - - -def operationdefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("OperationDefinition", v) - - -def operationdefinitionoverload_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("OperationDefinitionOverload", v) - - -def operationdefinitionparameter_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("OperationDefinitionParameter", v) - - -def operationdefinitionparameterbinding_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("OperationDefinitionParameterBinding", v) - - -def operationdefinitionparameterreferencedfrom_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("OperationDefinitionParameterReferencedFrom", v) - - -def operationoutcome_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("OperationOutcome", v) - - -def operationoutcomeissue_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("OperationOutcomeIssue", v) - - -def organization_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Organization", v) - - -def organizationaffiliation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("OrganizationAffiliation", v) - - -def organizationcontact_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("OrganizationContact", v) - - -def parameterdefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ParameterDefinition", v) - - -def parameters_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Parameters", v) - - -def parametersparameter_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ParametersParameter", v) - - -def patient_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Patient", v) - - -def patientcommunication_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("PatientCommunication", v) - - -def patientcontact_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("PatientContact", v) - - -def patientlink_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("PatientLink", v) - - -def paymentnotice_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("PaymentNotice", v) - - -def paymentreconciliation_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("PaymentReconciliation", v) - - -def paymentreconciliationdetail_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("PaymentReconciliationDetail", v) - - -def paymentreconciliationprocessnote_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("PaymentReconciliationProcessNote", v) - - -def period_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Period", v) - - -def person_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Person", v) - - -def personlink_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("PersonLink", v) - - -def plandefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("PlanDefinition", v) - - -def plandefinitionaction_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("PlanDefinitionAction", v) - - -def plandefinitionactioncondition_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("PlanDefinitionActionCondition", v) - - -def plandefinitionactiondynamicvalue_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("PlanDefinitionActionDynamicValue", v) - - -def plandefinitionactionparticipant_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("PlanDefinitionActionParticipant", v) - - -def plandefinitionactionrelatedaction_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("PlanDefinitionActionRelatedAction", v) - - -def plandefinitiongoal_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("PlanDefinitionGoal", v) - - -def plandefinitiongoaltarget_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("PlanDefinitionGoalTarget", v) - - -def population_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Population", v) - - -def practitioner_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Practitioner", v) - - -def practitionerqualification_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("PractitionerQualification", v) - - -def practitionerrole_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("PractitionerRole", v) - - -def practitionerroleavailabletime_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("PractitionerRoleAvailableTime", v) - - -def practitionerrolenotavailable_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("PractitionerRoleNotAvailable", v) - - -def procedure_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Procedure", v) - - -def procedurefocaldevice_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ProcedureFocalDevice", v) - - -def procedureperformer_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ProcedurePerformer", v) - - -def prodcharacteristic_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ProdCharacteristic", v) - - -def productshelflife_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ProductShelfLife", v) - - -def provenance_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Provenance", v) - - -def provenanceagent_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ProvenanceAgent", v) - - -def provenanceentity_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ProvenanceEntity", v) - - -def quantity_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Quantity", v) - - -def questionnaire_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Questionnaire", v) - - -def questionnaireitem_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("QuestionnaireItem", v) - - -def questionnaireitemansweroption_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("QuestionnaireItemAnswerOption", v) - - -def questionnaireitemenablewhen_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("QuestionnaireItemEnableWhen", v) - - -def questionnaireiteminitial_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("QuestionnaireItemInitial", v) - - -def questionnaireresponse_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("QuestionnaireResponse", v) - - -def questionnaireresponseitem_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("QuestionnaireResponseItem", v) - - -def questionnaireresponseitemanswer_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("QuestionnaireResponseItemAnswer", v) - - -def range_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Range", v) - - -def ratio_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Ratio", v) - - -def reference_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Reference", v) - - -def relatedartifact_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("RelatedArtifact", v) - - -def relatedperson_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("RelatedPerson", v) - - -def relatedpersoncommunication_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("RelatedPersonCommunication", v) - - -def requestgroup_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("RequestGroup", v) - - -def requestgroupaction_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("RequestGroupAction", v) - - -def requestgroupactioncondition_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("RequestGroupActionCondition", v) - - -def requestgroupactionrelatedaction_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("RequestGroupActionRelatedAction", v) - - -def researchdefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ResearchDefinition", v) - - -def researchelementdefinition_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ResearchElementDefinition", v) - - -def researchelementdefinitioncharacteristic_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ResearchElementDefinitionCharacteristic", v) - - -def researchstudy_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ResearchStudy", v) - - -def researchstudyarm_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ResearchStudyArm", v) - - -def researchstudyobjective_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ResearchStudyObjective", v) - - -def researchsubject_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ResearchSubject", v) - - -def resource_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Resource", v) - - -def riskassessment_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("RiskAssessment", v) - - -def riskassessmentprediction_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("RiskAssessmentPrediction", v) - - -def riskevidencesynthesis_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("RiskEvidenceSynthesis", v) - - -def riskevidencesynthesiscertainty_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("RiskEvidenceSynthesisCertainty", v) - - -def riskevidencesynthesiscertaintycertaintysubcomponent_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "RiskEvidenceSynthesisCertaintyCertaintySubcomponent", v - ) - - -def riskevidencesynthesisriskestimate_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("RiskEvidenceSynthesisRiskEstimate", v) - - -def riskevidencesynthesisriskestimateprecisionestimate_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("RiskEvidenceSynthesisRiskEstimatePrecisionEstimate", v) - - -def riskevidencesynthesissamplesize_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("RiskEvidenceSynthesisSampleSize", v) - - -def sampleddata_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SampledData", v) - - -def schedule_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Schedule", v) - - -def searchparameter_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SearchParameter", v) - - -def searchparametercomponent_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SearchParameterComponent", v) - - -def servicerequest_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ServiceRequest", v) - - -def signature_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Signature", v) - - -def slot_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Slot", v) - - -def specimen_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Specimen", v) - - -def specimencollection_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SpecimenCollection", v) - - -def specimencontainer_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SpecimenContainer", v) - - -def specimendefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SpecimenDefinition", v) - - -def specimendefinitiontypetested_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SpecimenDefinitionTypeTested", v) - - -def specimendefinitiontypetestedcontainer_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SpecimenDefinitionTypeTestedContainer", v) - - -def specimendefinitiontypetestedcontaineradditive_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SpecimenDefinitionTypeTestedContainerAdditive", v) - - -def specimendefinitiontypetestedhandling_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SpecimenDefinitionTypeTestedHandling", v) - - -def specimenprocessing_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SpecimenProcessing", v) - - -def structuredefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("StructureDefinition", v) - - -def structuredefinitioncontext_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("StructureDefinitionContext", v) - - -def structuredefinitiondifferential_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("StructureDefinitionDifferential", v) - - -def structuredefinitionmapping_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("StructureDefinitionMapping", v) - - -def structuredefinitionsnapshot_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("StructureDefinitionSnapshot", v) - - -def structuremap_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("StructureMap", v) - - -def structuremapgroup_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("StructureMapGroup", v) - - -def structuremapgroupinput_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("StructureMapGroupInput", v) - - -def structuremapgrouprule_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("StructureMapGroupRule", v) - - -def structuremapgroupruledependent_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("StructureMapGroupRuleDependent", v) - - -def structuremapgrouprulesource_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("StructureMapGroupRuleSource", v) - - -def structuremapgroupruletarget_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("StructureMapGroupRuleTarget", v) - - -def structuremapgroupruletargetparameter_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("StructureMapGroupRuleTargetParameter", v) - - -def structuremapstructure_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("StructureMapStructure", v) - - -def subscription_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Subscription", v) - - -def subscriptionchannel_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SubscriptionChannel", v) - - -def substance_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Substance", v) - - -def substanceamount_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SubstanceAmount", v) - - -def substanceamountreferencerange_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceAmountReferenceRange", v) - - -def substanceingredient_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SubstanceIngredient", v) - - -def substanceinstance_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SubstanceInstance", v) - - -def substancenucleicacid_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SubstanceNucleicAcid", v) - - -def substancenucleicacidsubunit_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceNucleicAcidSubunit", v) - - -def substancenucleicacidsubunitlinkage_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceNucleicAcidSubunitLinkage", v) - - -def substancenucleicacidsubunitsugar_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceNucleicAcidSubunitSugar", v) - - -def substancepolymer_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SubstancePolymer", v) - - -def substancepolymermonomerset_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstancePolymerMonomerSet", v) - - -def substancepolymermonomersetstartingmaterial_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstancePolymerMonomerSetStartingMaterial", v) - - -def substancepolymerrepeat_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SubstancePolymerRepeat", v) - - -def substancepolymerrepeatrepeatunit_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstancePolymerRepeatRepeatUnit", v) - - -def substancepolymerrepeatrepeatunitdegreeofpolymerisation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisation", v - ) - - -def substancepolymerrepeatrepeatunitstructuralrepresentation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "SubstancePolymerRepeatRepeatUnitStructuralRepresentation", v - ) - - -def substanceprotein_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SubstanceProtein", v) - - -def substanceproteinsubunit_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceProteinSubunit", v) - - -def substancereferenceinformation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceReferenceInformation", v) - - -def substancereferenceinformationclassification_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceReferenceInformationClassification", v) - - -def substancereferenceinformationgene_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceReferenceInformationGene", v) - - -def substancereferenceinformationgeneelement_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceReferenceInformationGeneElement", v) - - -def substancereferenceinformationtarget_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceReferenceInformationTarget", v) - - -def substancesourcematerial_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSourceMaterial", v) - - -def substancesourcematerialfractiondescription_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSourceMaterialFractionDescription", v) - - -def substancesourcematerialorganism_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSourceMaterialOrganism", v) - - -def substancesourcematerialorganismauthor_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSourceMaterialOrganismAuthor", v) - - -def substancesourcematerialorganismhybrid_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSourceMaterialOrganismHybrid", v) - - -def substancesourcematerialorganismorganismgeneral_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSourceMaterialOrganismOrganismGeneral", v) - - -def substancesourcematerialpartdescription_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSourceMaterialPartDescription", v) - - -def substancespecification_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SubstanceSpecification", v) - - -def substancespecificationcode_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSpecificationCode", v) - - -def substancespecificationmoiety_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSpecificationMoiety", v) - - -def substancespecificationname_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSpecificationName", v) - - -def substancespecificationnameofficial_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSpecificationNameOfficial", v) - - -def substancespecificationproperty_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSpecificationProperty", v) - - -def substancespecificationrelationship_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSpecificationRelationship", v) - - -def substancespecificationstructure_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSpecificationStructure", v) - - -def substancespecificationstructureisotope_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSpecificationStructureIsotope", v) - - -def substancespecificationstructureisotopemolecularweight_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator( - "SubstanceSpecificationStructureIsotopeMolecularWeight", v - ) - - -def substancespecificationstructurerepresentation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SubstanceSpecificationStructureRepresentation", v) - - -def supplydelivery_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SupplyDelivery", v) - - -def supplydeliverysupplieditem_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("SupplyDeliverySuppliedItem", v) - - -def supplyrequest_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SupplyRequest", v) - - -def supplyrequestparameter_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("SupplyRequestParameter", v) - - -def task_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Task", v) - - -def taskinput_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TaskInput", v) - - -def taskoutput_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TaskOutput", v) - - -def taskrestriction_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TaskRestriction", v) - - -def terminologycapabilities_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TerminologyCapabilities", v) - - -def terminologycapabilitiesclosure_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TerminologyCapabilitiesClosure", v) - - -def terminologycapabilitiescodesystem_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TerminologyCapabilitiesCodeSystem", v) - - -def terminologycapabilitiescodesystemversion_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TerminologyCapabilitiesCodeSystemVersion", v) - - -def terminologycapabilitiescodesystemversionfilter_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TerminologyCapabilitiesCodeSystemVersionFilter", v) - - -def terminologycapabilitiesexpansion_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TerminologyCapabilitiesExpansion", v) - - -def terminologycapabilitiesexpansionparameter_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TerminologyCapabilitiesExpansionParameter", v) - - -def terminologycapabilitiesimplementation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TerminologyCapabilitiesImplementation", v) - - -def terminologycapabilitiessoftware_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TerminologyCapabilitiesSoftware", v) - - -def terminologycapabilitiestranslation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TerminologyCapabilitiesTranslation", v) - - -def terminologycapabilitiesvalidatecode_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TerminologyCapabilitiesValidateCode", v) - - -def testreport_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestReport", v) - - -def testreportparticipant_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestReportParticipant", v) - - -def testreportsetup_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestReportSetup", v) - - -def testreportsetupaction_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestReportSetupAction", v) - - -def testreportsetupactionassert_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TestReportSetupActionAssert", v) - - -def testreportsetupactionoperation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TestReportSetupActionOperation", v) - - -def testreportteardown_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestReportTeardown", v) - - -def testreportteardownaction_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TestReportTeardownAction", v) - - -def testreporttest_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestReportTest", v) - - -def testreporttestaction_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestReportTestAction", v) - - -def testscript_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScript", v) - - -def testscriptdestination_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScriptDestination", v) - - -def testscriptfixture_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScriptFixture", v) - - -def testscriptmetadata_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScriptMetadata", v) - - -def testscriptmetadatacapability_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TestScriptMetadataCapability", v) - - -def testscriptmetadatalink_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScriptMetadataLink", v) - - -def testscriptorigin_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScriptOrigin", v) - - -def testscriptsetup_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScriptSetup", v) - - -def testscriptsetupaction_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScriptSetupAction", v) - - -def testscriptsetupactionassert_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TestScriptSetupActionAssert", v) - - -def testscriptsetupactionoperation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TestScriptSetupActionOperation", v) - - -def testscriptsetupactionoperationrequestheader_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TestScriptSetupActionOperationRequestHeader", v) - - -def testscriptteardown_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScriptTeardown", v) - - -def testscriptteardownaction_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("TestScriptTeardownAction", v) - - -def testscripttest_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScriptTest", v) - - -def testscripttestaction_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScriptTestAction", v) - - -def testscriptvariable_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TestScriptVariable", v) - - -def timing_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("Timing", v) - - -def timingrepeat_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TimingRepeat", v) - - -def triggerdefinition_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("TriggerDefinition", v) - - -def usagecontext_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("UsageContext", v) - - -def valueset_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ValueSet", v) - - -def valuesetcompose_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ValueSetCompose", v) - - -def valuesetcomposeinclude_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ValueSetComposeInclude", v) - - -def valuesetcomposeincludeconcept_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ValueSetComposeIncludeConcept", v) - - -def valuesetcomposeincludeconceptdesignation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ValueSetComposeIncludeConceptDesignation", v) - - -def valuesetcomposeincludefilter_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ValueSetComposeIncludeFilter", v) - - -def valuesetexpansion_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("ValueSetExpansion", v) - - -def valuesetexpansioncontains_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ValueSetExpansionContains", v) - - -def valuesetexpansionparameter_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("ValueSetExpansionParameter", v) - - -def verificationresult_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("VerificationResult", v) - - -def verificationresultattestation_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("VerificationResultAttestation", v) - - -def verificationresultprimarysource_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("VerificationResultPrimarySource", v) - - -def verificationresultvalidator_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("VerificationResultValidator", v) - - -def visionprescription_validator(v: Union[StrBytes, dict, Path, FHIRAbstractModel]): - - return fhir_model_validator("VisionPrescription", v) - - -def visionprescriptionlensspecification_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("VisionPrescriptionLensSpecification", v) - - -def visionprescriptionlensspecificationprism_validator( - v: Union[StrBytes, dict, Path, FHIRAbstractModel] -): - - return fhir_model_validator("VisionPrescriptionLensSpecificationPrism", v) - - -__all__ = [ - "fhirprimitiveextension_validator", - "account_validator", - "accountcoverage_validator", - "accountguarantor_validator", - "activitydefinition_validator", - "activitydefinitiondynamicvalue_validator", - "activitydefinitionparticipant_validator", - "address_validator", - "adverseevent_validator", - "adverseeventsuspectentity_validator", - "adverseeventsuspectentitycausality_validator", - "age_validator", - "allergyintolerance_validator", - "allergyintolerancereaction_validator", - "annotation_validator", - "appointment_validator", - "appointmentparticipant_validator", - "appointmentresponse_validator", - "attachment_validator", - "auditevent_validator", - "auditeventagent_validator", - "auditeventagentnetwork_validator", - "auditevententity_validator", - "auditevententitydetail_validator", - "auditeventsource_validator", - "backboneelement_validator", - "basic_validator", - "binary_validator", - "biologicallyderivedproduct_validator", - "biologicallyderivedproductcollection_validator", - "biologicallyderivedproductmanipulation_validator", - "biologicallyderivedproductprocessing_validator", - "biologicallyderivedproductstorage_validator", - "bodystructure_validator", - "bundle_validator", - "bundleentry_validator", - "bundleentryrequest_validator", - "bundleentryresponse_validator", - "bundleentrysearch_validator", - "bundlelink_validator", - "capabilitystatement_validator", - "capabilitystatementdocument_validator", - "capabilitystatementimplementation_validator", - "capabilitystatementmessaging_validator", - "capabilitystatementmessagingendpoint_validator", - "capabilitystatementmessagingsupportedmessage_validator", - "capabilitystatementrest_validator", - "capabilitystatementrestinteraction_validator", - "capabilitystatementrestresource_validator", - "capabilitystatementrestresourceinteraction_validator", - "capabilitystatementrestresourceoperation_validator", - "capabilitystatementrestresourcesearchparam_validator", - "capabilitystatementrestsecurity_validator", - "capabilitystatementsoftware_validator", - "careplan_validator", - "careplanactivity_validator", - "careplanactivitydetail_validator", - "careteam_validator", - "careteamparticipant_validator", - "catalogentry_validator", - "catalogentryrelatedentry_validator", - "chargeitem_validator", - "chargeitemdefinition_validator", - "chargeitemdefinitionapplicability_validator", - "chargeitemdefinitionpropertygroup_validator", - "chargeitemdefinitionpropertygrouppricecomponent_validator", - "chargeitemperformer_validator", - "claim_validator", - "claimaccident_validator", - "claimcareteam_validator", - "claimdiagnosis_validator", - "claiminsurance_validator", - "claimitem_validator", - "claimitemdetail_validator", - "claimitemdetailsubdetail_validator", - "claimpayee_validator", - "claimprocedure_validator", - "claimrelated_validator", - "claimresponse_validator", - "claimresponseadditem_validator", - "claimresponseadditemdetail_validator", - "claimresponseadditemdetailsubdetail_validator", - "claimresponseerror_validator", - "claimresponseinsurance_validator", - "claimresponseitem_validator", - "claimresponseitemadjudication_validator", - "claimresponseitemdetail_validator", - "claimresponseitemdetailsubdetail_validator", - "claimresponsepayment_validator", - "claimresponseprocessnote_validator", - "claimresponsetotal_validator", - "claimsupportinginfo_validator", - "clinicalimpression_validator", - "clinicalimpressionfinding_validator", - "clinicalimpressioninvestigation_validator", - "codesystem_validator", - "codesystemconcept_validator", - "codesystemconceptdesignation_validator", - "codesystemconceptproperty_validator", - "codesystemfilter_validator", - "codesystemproperty_validator", - "codeableconcept_validator", - "coding_validator", - "communication_validator", - "communicationpayload_validator", - "communicationrequest_validator", - "communicationrequestpayload_validator", - "compartmentdefinition_validator", - "compartmentdefinitionresource_validator", - "composition_validator", - "compositionattester_validator", - "compositionevent_validator", - "compositionrelatesto_validator", - "compositionsection_validator", - "conceptmap_validator", - "conceptmapgroup_validator", - "conceptmapgroupelement_validator", - "conceptmapgroupelementtarget_validator", - "conceptmapgroupelementtargetdependson_validator", - "conceptmapgroupunmapped_validator", - "condition_validator", - "conditionevidence_validator", - "conditionstage_validator", - "consent_validator", - "consentpolicy_validator", - "consentprovision_validator", - "consentprovisionactor_validator", - "consentprovisiondata_validator", - "consentverification_validator", - "contactdetail_validator", - "contactpoint_validator", - "contract_validator", - "contractcontentdefinition_validator", - "contractfriendly_validator", - "contractlegal_validator", - "contractrule_validator", - "contractsigner_validator", - "contractterm_validator", - "contracttermaction_validator", - "contracttermactionsubject_validator", - "contracttermasset_validator", - "contracttermassetcontext_validator", - "contracttermassetvalueditem_validator", - "contracttermoffer_validator", - "contracttermofferanswer_validator", - "contracttermofferparty_validator", - "contracttermsecuritylabel_validator", - "contributor_validator", - "count_validator", - "coverage_validator", - "coverageclass_validator", - "coveragecosttobeneficiary_validator", - "coveragecosttobeneficiaryexception_validator", - "coverageeligibilityrequest_validator", - "coverageeligibilityrequestinsurance_validator", - "coverageeligibilityrequestitem_validator", - "coverageeligibilityrequestitemdiagnosis_validator", - "coverageeligibilityrequestsupportinginfo_validator", - "coverageeligibilityresponse_validator", - "coverageeligibilityresponseerror_validator", - "coverageeligibilityresponseinsurance_validator", - "coverageeligibilityresponseinsuranceitem_validator", - "coverageeligibilityresponseinsuranceitembenefit_validator", - "datarequirement_validator", - "datarequirementcodefilter_validator", - "datarequirementdatefilter_validator", - "datarequirementsort_validator", - "detectedissue_validator", - "detectedissueevidence_validator", - "detectedissuemitigation_validator", - "device_validator", - "devicedefinition_validator", - "devicedefinitioncapability_validator", - "devicedefinitiondevicename_validator", - "devicedefinitionmaterial_validator", - "devicedefinitionproperty_validator", - "devicedefinitionspecialization_validator", - "devicedefinitionudideviceidentifier_validator", - "devicedevicename_validator", - "devicemetric_validator", - "devicemetriccalibration_validator", - "deviceproperty_validator", - "devicerequest_validator", - "devicerequestparameter_validator", - "devicespecialization_validator", - "deviceudicarrier_validator", - "deviceusestatement_validator", - "deviceversion_validator", - "diagnosticreport_validator", - "diagnosticreportmedia_validator", - "distance_validator", - "documentmanifest_validator", - "documentmanifestrelated_validator", - "documentreference_validator", - "documentreferencecontent_validator", - "documentreferencecontext_validator", - "documentreferencerelatesto_validator", - "domainresource_validator", - "dosage_validator", - "dosagedoseandrate_validator", - "duration_validator", - "effectevidencesynthesis_validator", - "effectevidencesynthesiscertainty_validator", - "effectevidencesynthesiscertaintycertaintysubcomponent_validator", - "effectevidencesynthesiseffectestimate_validator", - "effectevidencesynthesiseffectestimateprecisionestimate_validator", - "effectevidencesynthesisresultsbyexposure_validator", - "effectevidencesynthesissamplesize_validator", - "element_validator", - "elementdefinition_validator", - "elementdefinitionbase_validator", - "elementdefinitionbinding_validator", - "elementdefinitionconstraint_validator", - "elementdefinitionexample_validator", - "elementdefinitionmapping_validator", - "elementdefinitionslicing_validator", - "elementdefinitionslicingdiscriminator_validator", - "elementdefinitiontype_validator", - "encounter_validator", - "encounterclasshistory_validator", - "encounterdiagnosis_validator", - "encounterhospitalization_validator", - "encounterlocation_validator", - "encounterparticipant_validator", - "encounterstatushistory_validator", - "endpoint_validator", - "enrollmentrequest_validator", - "enrollmentresponse_validator", - "episodeofcare_validator", - "episodeofcarediagnosis_validator", - "episodeofcarestatushistory_validator", - "eventdefinition_validator", - "evidence_validator", - "evidencevariable_validator", - "evidencevariablecharacteristic_validator", - "examplescenario_validator", - "examplescenarioactor_validator", - "examplescenarioinstance_validator", - "examplescenarioinstancecontainedinstance_validator", - "examplescenarioinstanceversion_validator", - "examplescenarioprocess_validator", - "examplescenarioprocessstep_validator", - "examplescenarioprocessstepalternative_validator", - "examplescenarioprocessstepoperation_validator", - "explanationofbenefit_validator", - "explanationofbenefitaccident_validator", - "explanationofbenefitadditem_validator", - "explanationofbenefitadditemdetail_validator", - "explanationofbenefitadditemdetailsubdetail_validator", - "explanationofbenefitbenefitbalance_validator", - "explanationofbenefitbenefitbalancefinancial_validator", - "explanationofbenefitcareteam_validator", - "explanationofbenefitdiagnosis_validator", - "explanationofbenefitinsurance_validator", - "explanationofbenefititem_validator", - "explanationofbenefititemadjudication_validator", - "explanationofbenefititemdetail_validator", - "explanationofbenefititemdetailsubdetail_validator", - "explanationofbenefitpayee_validator", - "explanationofbenefitpayment_validator", - "explanationofbenefitprocedure_validator", - "explanationofbenefitprocessnote_validator", - "explanationofbenefitrelated_validator", - "explanationofbenefitsupportinginfo_validator", - "explanationofbenefittotal_validator", - "expression_validator", - "extension_validator", - "familymemberhistory_validator", - "familymemberhistorycondition_validator", - "flag_validator", - "goal_validator", - "goaltarget_validator", - "graphdefinition_validator", - "graphdefinitionlink_validator", - "graphdefinitionlinktarget_validator", - "graphdefinitionlinktargetcompartment_validator", - "group_validator", - "groupcharacteristic_validator", - "groupmember_validator", - "guidanceresponse_validator", - "healthcareservice_validator", - "healthcareserviceavailabletime_validator", - "healthcareserviceeligibility_validator", - "healthcareservicenotavailable_validator", - "humanname_validator", - "identifier_validator", - "imagingstudy_validator", - "imagingstudyseries_validator", - "imagingstudyseriesinstance_validator", - "imagingstudyseriesperformer_validator", - "immunization_validator", - "immunizationeducation_validator", - "immunizationevaluation_validator", - "immunizationperformer_validator", - "immunizationprotocolapplied_validator", - "immunizationreaction_validator", - "immunizationrecommendation_validator", - "immunizationrecommendationrecommendation_validator", - "immunizationrecommendationrecommendationdatecriterion_validator", - "implementationguide_validator", - "implementationguidedefinition_validator", - "implementationguidedefinitiongrouping_validator", - "implementationguidedefinitionpage_validator", - "implementationguidedefinitionparameter_validator", - "implementationguidedefinitionresource_validator", - "implementationguidedefinitiontemplate_validator", - "implementationguidedependson_validator", - "implementationguideglobal_validator", - "implementationguidemanifest_validator", - "implementationguidemanifestpage_validator", - "implementationguidemanifestresource_validator", - "insuranceplan_validator", - "insuranceplancontact_validator", - "insuranceplancoverage_validator", - "insuranceplancoveragebenefit_validator", - "insuranceplancoveragebenefitlimit_validator", - "insuranceplanplan_validator", - "insuranceplanplangeneralcost_validator", - "insuranceplanplanspecificcost_validator", - "insuranceplanplanspecificcostbenefit_validator", - "insuranceplanplanspecificcostbenefitcost_validator", - "invoice_validator", - "invoicelineitem_validator", - "invoicelineitempricecomponent_validator", - "invoiceparticipant_validator", - "library_validator", - "linkage_validator", - "linkageitem_validator", - "list_validator", - "listentry_validator", - "location_validator", - "locationhoursofoperation_validator", - "locationposition_validator", - "marketingstatus_validator", - "measure_validator", - "measuregroup_validator", - "measuregrouppopulation_validator", - "measuregroupstratifier_validator", - "measuregroupstratifiercomponent_validator", - "measurereport_validator", - "measurereportgroup_validator", - "measurereportgrouppopulation_validator", - "measurereportgroupstratifier_validator", - "measurereportgroupstratifierstratum_validator", - "measurereportgroupstratifierstratumcomponent_validator", - "measurereportgroupstratifierstratumpopulation_validator", - "measuresupplementaldata_validator", - "media_validator", - "medication_validator", - "medicationadministration_validator", - "medicationadministrationdosage_validator", - "medicationadministrationperformer_validator", - "medicationbatch_validator", - "medicationdispense_validator", - "medicationdispenseperformer_validator", - "medicationdispensesubstitution_validator", - "medicationingredient_validator", - "medicationknowledge_validator", - "medicationknowledgeadministrationguidelines_validator", - "medicationknowledgeadministrationguidelinesdosage_validator", - "medicationknowledgeadministrationguidelinespatientcharacteristics_validator", - "medicationknowledgecost_validator", - "medicationknowledgedrugcharacteristic_validator", - "medicationknowledgeingredient_validator", - "medicationknowledgekinetics_validator", - "medicationknowledgemedicineclassification_validator", - "medicationknowledgemonitoringprogram_validator", - "medicationknowledgemonograph_validator", - "medicationknowledgepackaging_validator", - "medicationknowledgeregulatory_validator", - "medicationknowledgeregulatorymaxdispense_validator", - "medicationknowledgeregulatoryschedule_validator", - "medicationknowledgeregulatorysubstitution_validator", - "medicationknowledgerelatedmedicationknowledge_validator", - "medicationrequest_validator", - "medicationrequestdispenserequest_validator", - "medicationrequestdispenserequestinitialfill_validator", - "medicationrequestsubstitution_validator", - "medicationstatement_validator", - "medicinalproduct_validator", - "medicinalproductauthorization_validator", - "medicinalproductauthorizationjurisdictionalauthorization_validator", - "medicinalproductauthorizationprocedure_validator", - "medicinalproductcontraindication_validator", - "medicinalproductcontraindicationothertherapy_validator", - "medicinalproductindication_validator", - "medicinalproductindicationothertherapy_validator", - "medicinalproductingredient_validator", - "medicinalproductingredientspecifiedsubstance_validator", - "medicinalproductingredientspecifiedsubstancestrength_validator", - "medicinalproductingredientspecifiedsubstancestrengthreferencestrength_validator", - "medicinalproductingredientsubstance_validator", - "medicinalproductinteraction_validator", - "medicinalproductinteractioninteractant_validator", - "medicinalproductmanufactured_validator", - "medicinalproductmanufacturingbusinessoperation_validator", - "medicinalproductname_validator", - "medicinalproductnamecountrylanguage_validator", - "medicinalproductnamenamepart_validator", - "medicinalproductpackaged_validator", - "medicinalproductpackagedbatchidentifier_validator", - "medicinalproductpackagedpackageitem_validator", - "medicinalproductpharmaceutical_validator", - "medicinalproductpharmaceuticalcharacteristics_validator", - "medicinalproductpharmaceuticalrouteofadministration_validator", - "medicinalproductpharmaceuticalrouteofadministrationtargetspecies_validator", - "medicinalproductpharmaceuticalrouteofadministrationtargetspecieswithdrawalperiod_validator", # noqa: B950 - "medicinalproductspecialdesignation_validator", - "medicinalproductundesirableeffect_validator", - "messagedefinition_validator", - "messagedefinitionallowedresponse_validator", - "messagedefinitionfocus_validator", - "messageheader_validator", - "messageheaderdestination_validator", - "messageheaderresponse_validator", - "messageheadersource_validator", - "meta_validator", - "metadataresource_validator", - "molecularsequence_validator", - "molecularsequencequality_validator", - "molecularsequencequalityroc_validator", - "molecularsequencereferenceseq_validator", - "molecularsequencerepository_validator", - "molecularsequencestructurevariant_validator", - "molecularsequencestructurevariantinner_validator", - "molecularsequencestructurevariantouter_validator", - "molecularsequencevariant_validator", - "money_validator", - "namingsystem_validator", - "namingsystemuniqueid_validator", - "narrative_validator", - "nutritionorder_validator", - "nutritionorderenteralformula_validator", - "nutritionorderenteralformulaadministration_validator", - "nutritionorderoraldiet_validator", - "nutritionorderoraldietnutrient_validator", - "nutritionorderoraldiettexture_validator", - "nutritionordersupplement_validator", - "observation_validator", - "observationcomponent_validator", - "observationdefinition_validator", - "observationdefinitionqualifiedinterval_validator", - "observationdefinitionquantitativedetails_validator", - "observationreferencerange_validator", - "operationdefinition_validator", - "operationdefinitionoverload_validator", - "operationdefinitionparameter_validator", - "operationdefinitionparameterbinding_validator", - "operationdefinitionparameterreferencedfrom_validator", - "operationoutcome_validator", - "operationoutcomeissue_validator", - "organization_validator", - "organizationaffiliation_validator", - "organizationcontact_validator", - "parameterdefinition_validator", - "parameters_validator", - "parametersparameter_validator", - "patient_validator", - "patientcommunication_validator", - "patientcontact_validator", - "patientlink_validator", - "paymentnotice_validator", - "paymentreconciliation_validator", - "paymentreconciliationdetail_validator", - "paymentreconciliationprocessnote_validator", - "period_validator", - "person_validator", - "personlink_validator", - "plandefinition_validator", - "plandefinitionaction_validator", - "plandefinitionactioncondition_validator", - "plandefinitionactiondynamicvalue_validator", - "plandefinitionactionparticipant_validator", - "plandefinitionactionrelatedaction_validator", - "plandefinitiongoal_validator", - "plandefinitiongoaltarget_validator", - "population_validator", - "practitioner_validator", - "practitionerqualification_validator", - "practitionerrole_validator", - "practitionerroleavailabletime_validator", - "practitionerrolenotavailable_validator", - "procedure_validator", - "procedurefocaldevice_validator", - "procedureperformer_validator", - "prodcharacteristic_validator", - "productshelflife_validator", - "provenance_validator", - "provenanceagent_validator", - "provenanceentity_validator", - "quantity_validator", - "questionnaire_validator", - "questionnaireitem_validator", - "questionnaireitemansweroption_validator", - "questionnaireitemenablewhen_validator", - "questionnaireiteminitial_validator", - "questionnaireresponse_validator", - "questionnaireresponseitem_validator", - "questionnaireresponseitemanswer_validator", - "range_validator", - "ratio_validator", - "reference_validator", - "relatedartifact_validator", - "relatedperson_validator", - "relatedpersoncommunication_validator", - "requestgroup_validator", - "requestgroupaction_validator", - "requestgroupactioncondition_validator", - "requestgroupactionrelatedaction_validator", - "researchdefinition_validator", - "researchelementdefinition_validator", - "researchelementdefinitioncharacteristic_validator", - "researchstudy_validator", - "researchstudyarm_validator", - "researchstudyobjective_validator", - "researchsubject_validator", - "resource_validator", - "riskassessment_validator", - "riskassessmentprediction_validator", - "riskevidencesynthesis_validator", - "riskevidencesynthesiscertainty_validator", - "riskevidencesynthesiscertaintycertaintysubcomponent_validator", - "riskevidencesynthesisriskestimate_validator", - "riskevidencesynthesisriskestimateprecisionestimate_validator", - "riskevidencesynthesissamplesize_validator", - "sampleddata_validator", - "schedule_validator", - "searchparameter_validator", - "searchparametercomponent_validator", - "servicerequest_validator", - "signature_validator", - "slot_validator", - "specimen_validator", - "specimencollection_validator", - "specimencontainer_validator", - "specimendefinition_validator", - "specimendefinitiontypetested_validator", - "specimendefinitiontypetestedcontainer_validator", - "specimendefinitiontypetestedcontaineradditive_validator", - "specimendefinitiontypetestedhandling_validator", - "specimenprocessing_validator", - "structuredefinition_validator", - "structuredefinitioncontext_validator", - "structuredefinitiondifferential_validator", - "structuredefinitionmapping_validator", - "structuredefinitionsnapshot_validator", - "structuremap_validator", - "structuremapgroup_validator", - "structuremapgroupinput_validator", - "structuremapgrouprule_validator", - "structuremapgroupruledependent_validator", - "structuremapgrouprulesource_validator", - "structuremapgroupruletarget_validator", - "structuremapgroupruletargetparameter_validator", - "structuremapstructure_validator", - "subscription_validator", - "subscriptionchannel_validator", - "substance_validator", - "substanceamount_validator", - "substanceamountreferencerange_validator", - "substanceingredient_validator", - "substanceinstance_validator", - "substancenucleicacid_validator", - "substancenucleicacidsubunit_validator", - "substancenucleicacidsubunitlinkage_validator", - "substancenucleicacidsubunitsugar_validator", - "substancepolymer_validator", - "substancepolymermonomerset_validator", - "substancepolymermonomersetstartingmaterial_validator", - "substancepolymerrepeat_validator", - "substancepolymerrepeatrepeatunit_validator", - "substancepolymerrepeatrepeatunitdegreeofpolymerisation_validator", - "substancepolymerrepeatrepeatunitstructuralrepresentation_validator", - "substanceprotein_validator", - "substanceproteinsubunit_validator", - "substancereferenceinformation_validator", - "substancereferenceinformationclassification_validator", - "substancereferenceinformationgene_validator", - "substancereferenceinformationgeneelement_validator", - "substancereferenceinformationtarget_validator", - "substancesourcematerial_validator", - "substancesourcematerialfractiondescription_validator", - "substancesourcematerialorganism_validator", - "substancesourcematerialorganismauthor_validator", - "substancesourcematerialorganismhybrid_validator", - "substancesourcematerialorganismorganismgeneral_validator", - "substancesourcematerialpartdescription_validator", - "substancespecification_validator", - "substancespecificationcode_validator", - "substancespecificationmoiety_validator", - "substancespecificationname_validator", - "substancespecificationnameofficial_validator", - "substancespecificationproperty_validator", - "substancespecificationrelationship_validator", - "substancespecificationstructure_validator", - "substancespecificationstructureisotope_validator", - "substancespecificationstructureisotopemolecularweight_validator", - "substancespecificationstructurerepresentation_validator", - "supplydelivery_validator", - "supplydeliverysupplieditem_validator", - "supplyrequest_validator", - "supplyrequestparameter_validator", - "task_validator", - "taskinput_validator", - "taskoutput_validator", - "taskrestriction_validator", - "terminologycapabilities_validator", - "terminologycapabilitiesclosure_validator", - "terminologycapabilitiescodesystem_validator", - "terminologycapabilitiescodesystemversion_validator", - "terminologycapabilitiescodesystemversionfilter_validator", - "terminologycapabilitiesexpansion_validator", - "terminologycapabilitiesexpansionparameter_validator", - "terminologycapabilitiesimplementation_validator", - "terminologycapabilitiessoftware_validator", - "terminologycapabilitiestranslation_validator", - "terminologycapabilitiesvalidatecode_validator", - "testreport_validator", - "testreportparticipant_validator", - "testreportsetup_validator", - "testreportsetupaction_validator", - "testreportsetupactionassert_validator", - "testreportsetupactionoperation_validator", - "testreportteardown_validator", - "testreportteardownaction_validator", - "testreporttest_validator", - "testreporttestaction_validator", - "testscript_validator", - "testscriptdestination_validator", - "testscriptfixture_validator", - "testscriptmetadata_validator", - "testscriptmetadatacapability_validator", - "testscriptmetadatalink_validator", - "testscriptorigin_validator", - "testscriptsetup_validator", - "testscriptsetupaction_validator", - "testscriptsetupactionassert_validator", - "testscriptsetupactionoperation_validator", - "testscriptsetupactionoperationrequestheader_validator", - "testscriptteardown_validator", - "testscriptteardownaction_validator", - "testscripttest_validator", - "testscripttestaction_validator", - "testscriptvariable_validator", - "timing_validator", - "timingrepeat_validator", - "triggerdefinition_validator", - "usagecontext_validator", - "valueset_validator", - "valuesetcompose_validator", - "valuesetcomposeinclude_validator", - "valuesetcomposeincludeconcept_validator", - "valuesetcomposeincludeconceptdesignation_validator", - "valuesetcomposeincludefilter_validator", - "valuesetexpansion_validator", - "valuesetexpansioncontains_validator", - "valuesetexpansionparameter_validator", - "verificationresult_validator", - "verificationresultattestation_validator", - "verificationresultprimarysource_validator", - "verificationresultvalidator_validator", - "visionprescription_validator", - "visionprescriptionlensspecification_validator", - "visionprescriptionlensspecificationprism_validator", -] diff --git a/fhir/resources/flag.py b/fhir/resources/flag.py deleted file mode 100644 index 43c419b5..00000000 --- a/fhir/resources/flag.py +++ /dev/null @@ -1,230 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Flag -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class Flag(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Key information to flag to healthcare providers. - Prospective warnings of potential issues when providing care to the - patient. - """ - - resource_type = Field("Flag", const=True) - - author: fhirtypes.ReferenceType = Field( - None, - alias="author", - title="Flag creator", - description="The person, organization or device that created the flag.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Device", - "Organization", - "Patient", - "Practitioner", - "PractitionerRole", - ], - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Clinical, administrative, etc.", - description=( - "Allows a flag to be divided into different categories like clinical, " - "administrative etc. Intended to be used as a means of filtering which " - "flags are displayed to particular user or in a given context." - ), - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Coded or textual message to display to user", - description=( - "The coded value or textual component of the flag to display to the " - "user." - ), - # if property is element of this resource. - element_property=True, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Alert relevant during encounter", - description="This alert is only relevant during the encounter.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier", - description=( - "Business identifiers assigned to this flag by the performer or other " - "systems which remain constant as the resource is updated and " - "propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Time period when flag is active", - description=( - "The period of time from the activation of the flag to inactivation of " - "the flag. If the flag is active, the end of the period should be " - "unspecified." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | inactive | entered-in-error", - description="Supports basic workflow.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "inactive", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Who/What is flag about?", - description=( - "The patient, location, group, organization, or practitioner etc. this " - "is about record this flag is associated with." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Location", - "Group", - "Organization", - "Practitioner", - "PlanDefinition", - "Medication", - "Procedure", - ], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Flag`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "category", - "code", - "subject", - "period", - "encounter", - "author", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_551( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/goal.py b/fhir/resources/goal.py deleted file mode 100644 index ba50c16e..00000000 --- a/fhir/resources/goal.py +++ /dev/null @@ -1,675 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Goal -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Goal(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Describes the intended objective(s) for a patient, group or organization. - Describes the intended objective(s) for a patient, group or organization - care, for example, weight loss, restoring an activity of daily living, - obtaining herd immunity via immunization, meeting a process improvement - objective, etc. - """ - - resource_type = Field("Goal", const=True) - - achievementStatus: fhirtypes.CodeableConceptType = Field( - None, - alias="achievementStatus", - title=( - "in-progress | improving | worsening | no-change | achieved | " - "sustaining | not-achieved | no-progress | not-attainable" - ), - description=( - "Describes the progression, or lack thereof, towards the goal against " - "the target." - ), - # if property is element of this resource. - element_property=True, - ) - - addresses: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="addresses", - title="Issues addressed by this goal", - description=( - "The identified conditions and other health record elements that are " - "intended to be addressed by the goal." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "MedicationStatement", - "NutritionOrder", - "ServiceRequest", - "RiskAssessment", - ], - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="E.g. Treatment, dietary, behavioral, etc.", - description="Indicates a category the goal falls within.", - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.CodeableConceptType = Field( - ..., - alias="description", - title="Code or text describing goal", - description=( - "Human-readable and/or coded description of a specific desired " - 'objective of care, such as "control blood pressure" or "negotiate an ' - 'obstacle course" or "dance with child at wedding".' - ), - # if property is element of this resource. - element_property=True, - ) - - expressedBy: fhirtypes.ReferenceType = Field( - None, - alias="expressedBy", - title="Who's responsible for creating Goal?", - description="Indicates whose goal this is - patient goal, practitioner goal, etc.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - ], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Ids for this goal", - description=( - "Business identifiers assigned to this goal by the performer or other " - "systems which remain constant as the resource is updated and " - "propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - lifecycleStatus: fhirtypes.Code = Field( - None, - alias="lifecycleStatus", - title=( - "proposed | planned | accepted | active | on-hold | completed | " - "cancelled | entered-in-error | rejected" - ), - description="The state of the goal throughout its lifecycle.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "proposed", - "planned", - "accepted", - "active", - "on-hold", - "completed", - "cancelled", - "entered-in-error", - "rejected", - ], - ) - lifecycleStatus__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lifecycleStatus", title="Extension field for ``lifecycleStatus``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments about the goal", - description="Any comments related to the goal.", - # if property is element of this resource. - element_property=True, - ) - - outcomeCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="outcomeCode", - title="What result was achieved regarding the goal?", - description=( - "Identifies the change (or lack of change) at the point when the status" - " of the goal is assessed." - ), - # if property is element of this resource. - element_property=True, - ) - - outcomeReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="outcomeReference", - title="Observation that resulted from goal", - description="Details of what's changed (or not changed).", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Observation"], - ) - - priority: fhirtypes.CodeableConceptType = Field( - None, - alias="priority", - title="high-priority | medium-priority | low-priority", - description=( - "Identifies the mutually agreed level of importance associated with " - "reaching/sustaining the goal." - ), - # if property is element of this resource. - element_property=True, - ) - - startCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="startCodeableConcept", - title="When goal pursuit begins", - description="The date or event after which the goal should begin being pursued.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e start[x] - one_of_many="start", - one_of_many_required=False, - ) - - startDate: fhirtypes.Date = Field( - None, - alias="startDate", - title="When goal pursuit begins", - description="The date or event after which the goal should begin being pursued.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e start[x] - one_of_many="start", - one_of_many_required=False, - ) - startDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_startDate", title="Extension field for ``startDate``." - ) - - statusDate: fhirtypes.Date = Field( - None, - alias="statusDate", - title="When goal status took effect", - description=( - "Identifies when the current status. I.e. When initially created, when" - " achieved, when cancelled, etc." - ), - # if property is element of this resource. - element_property=True, - ) - statusDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_statusDate", title="Extension field for ``statusDate``." - ) - - statusReason: fhirtypes.String = Field( - None, - alias="statusReason", - title="Reason for current status", - description="Captures the reason for the current status.", - # if property is element of this resource. - element_property=True, - ) - statusReason__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_statusReason", title="Extension field for ``statusReason``." - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Who this goal is intended for", - description=( - "Identifies the patient, group or organization for whom the goal is " - "being established." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group", "Organization"], - ) - - target: typing.List[fhirtypes.GoalTargetType] = Field( - None, - alias="target", - title="Target outcome for the goal", - description="Indicates what should be done by when.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Goal`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "lifecycleStatus", - "achievementStatus", - "category", - "priority", - "description", - "subject", - "startDate", - "startCodeableConcept", - "target", - "statusDate", - "statusReason", - "expressedBy", - "addresses", - "note", - "outcomeCode", - "outcomeReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_566( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("lifecycleStatus", "lifecycleStatus__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_566( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"start": ["startCodeableConcept", "startDate"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class GoalTarget(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Target outcome for the goal. - Indicates what should be done by when. - """ - - resource_type = Field("GoalTarget", const=True) - - detailBoolean: bool = Field( - None, - alias="detailBoolean", - title="The target value to be achieved", - description=( - "The target value of the focus to be achieved to signify the " - "fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low" - " or both values of the range can be specified. When a low value is " - "missing, it indicates that the goal is achieved at any focus value at " - "or below the high value. Similarly, if the high value is missing, it " - "indicates that the goal is achieved at any focus value at or above the" - " low value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e detail[x] - one_of_many="detail", - one_of_many_required=False, - ) - detailBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_detailBoolean", title="Extension field for ``detailBoolean``." - ) - - detailCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="detailCodeableConcept", - title="The target value to be achieved", - description=( - "The target value of the focus to be achieved to signify the " - "fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low" - " or both values of the range can be specified. When a low value is " - "missing, it indicates that the goal is achieved at any focus value at " - "or below the high value. Similarly, if the high value is missing, it " - "indicates that the goal is achieved at any focus value at or above the" - " low value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e detail[x] - one_of_many="detail", - one_of_many_required=False, - ) - - detailInteger: fhirtypes.Integer = Field( - None, - alias="detailInteger", - title="The target value to be achieved", - description=( - "The target value of the focus to be achieved to signify the " - "fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low" - " or both values of the range can be specified. When a low value is " - "missing, it indicates that the goal is achieved at any focus value at " - "or below the high value. Similarly, if the high value is missing, it " - "indicates that the goal is achieved at any focus value at or above the" - " low value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e detail[x] - one_of_many="detail", - one_of_many_required=False, - ) - detailInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_detailInteger", title="Extension field for ``detailInteger``." - ) - - detailQuantity: fhirtypes.QuantityType = Field( - None, - alias="detailQuantity", - title="The target value to be achieved", - description=( - "The target value of the focus to be achieved to signify the " - "fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low" - " or both values of the range can be specified. When a low value is " - "missing, it indicates that the goal is achieved at any focus value at " - "or below the high value. Similarly, if the high value is missing, it " - "indicates that the goal is achieved at any focus value at or above the" - " low value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e detail[x] - one_of_many="detail", - one_of_many_required=False, - ) - - detailRange: fhirtypes.RangeType = Field( - None, - alias="detailRange", - title="The target value to be achieved", - description=( - "The target value of the focus to be achieved to signify the " - "fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low" - " or both values of the range can be specified. When a low value is " - "missing, it indicates that the goal is achieved at any focus value at " - "or below the high value. Similarly, if the high value is missing, it " - "indicates that the goal is achieved at any focus value at or above the" - " low value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e detail[x] - one_of_many="detail", - one_of_many_required=False, - ) - - detailRatio: fhirtypes.RatioType = Field( - None, - alias="detailRatio", - title="The target value to be achieved", - description=( - "The target value of the focus to be achieved to signify the " - "fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low" - " or both values of the range can be specified. When a low value is " - "missing, it indicates that the goal is achieved at any focus value at " - "or below the high value. Similarly, if the high value is missing, it " - "indicates that the goal is achieved at any focus value at or above the" - " low value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e detail[x] - one_of_many="detail", - one_of_many_required=False, - ) - - detailString: fhirtypes.String = Field( - None, - alias="detailString", - title="The target value to be achieved", - description=( - "The target value of the focus to be achieved to signify the " - "fulfillment of the goal, e.g. 150 pounds, 7.0%. Either the high or low" - " or both values of the range can be specified. When a low value is " - "missing, it indicates that the goal is achieved at any focus value at " - "or below the high value. Similarly, if the high value is missing, it " - "indicates that the goal is achieved at any focus value at or above the" - " low value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e detail[x] - one_of_many="detail", - one_of_many_required=False, - ) - detailString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_detailString", title="Extension field for ``detailString``." - ) - - dueDate: fhirtypes.Date = Field( - None, - alias="dueDate", - title="Reach goal on or before", - description=( - "Indicates either the date or the duration after start by which the " - "goal should be met." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e due[x] - one_of_many="due", - one_of_many_required=False, - ) - dueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_dueDate", title="Extension field for ``dueDate``." - ) - - dueDuration: fhirtypes.DurationType = Field( - None, - alias="dueDuration", - title="Reach goal on or before", - description=( - "Indicates either the date or the duration after start by which the " - "goal should be met." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e due[x] - one_of_many="due", - one_of_many_required=False, - ) - - measure: fhirtypes.CodeableConceptType = Field( - None, - alias="measure", - title="The parameter whose value is being tracked", - description=( - "The parameter whose value is being tracked, e.g. body weight, blood " - "pressure, or hemoglobin A1c level." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``GoalTarget`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "measure", - "detailQuantity", - "detailRange", - "detailCodeableConcept", - "detailString", - "detailBoolean", - "detailInteger", - "detailRatio", - "dueDate", - "dueDuration", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1189( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "detail": [ - "detailBoolean", - "detailCodeableConcept", - "detailInteger", - "detailQuantity", - "detailRange", - "detailRatio", - "detailString", - ], - "due": ["dueDate", "dueDuration"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/graphdefinition.py b/fhir/resources/graphdefinition.py deleted file mode 100644 index 536700ff..00000000 --- a/fhir/resources/graphdefinition.py +++ /dev/null @@ -1,773 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/GraphDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class GraphDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Definition of a graph of resources. - A formal computable definition of a graph of resources - that is, a - coherent set of resources that form a graph by following references. The - Graph Definition resource defines a set and makes rules about the set. - """ - - resource_type = Field("GraphDefinition", const=True) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the graph definition was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the graph definition changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the graph definition", - description=( - "A free text natural language description of the graph definition from " - "a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this graph definition is authored for" - " testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for graph definition (if applicable)", - description=( - "A legal or geographic region in which the graph definition is intended" - " to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - link: typing.List[fhirtypes.GraphDefinitionLinkType] = Field( - None, - alias="link", - title="Links this graph makes rules about", - description=None, - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this graph definition (computer friendly)", - description=( - "A natural language name identifying the graph definition. This name " - "should be usable as an identifier for the module by machine processing" - " applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - profile: fhirtypes.Canonical = Field( - None, - alias="profile", - title="Profile on base resource", - description="The profile that describes the use of the base resource.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - profile__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_profile", title="Extension field for ``profile``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the graph " - "definition." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this graph definition is defined", - description=( - "Explanation of why this graph definition is needed and why it has been" - " designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - start: fhirtypes.Code = Field( - None, - alias="start", - title="Type of resource at which the graph starts", - description="The type of FHIR resource at which instances of this graph start.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - start__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_start", title="Extension field for ``start``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this graph definition. Enables tracking the life-cycle " - "of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this graph definition, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this graph definition when it" - " is referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this graph definition is (or will be) published. This URL " - "can be the target of a canonical reference. It SHALL remain the same " - "when the graph definition is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate graph definition instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the graph definition", - description=( - "The identifier that is used to identify this version of the graph " - "definition when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the graph definition " - "author and is not expected to be globally unique. For example, it " - "might be a timestamp (e.g. yyyymmdd) if a managed version is not " - "available. There is also no expectation that versions can be placed in" - " a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``GraphDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "version", - "name", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "start", - "profile", - "link", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1712( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("name", "name__ext"), - ("start", "start__ext"), - ("status", "status__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class GraphDefinitionLink(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Links this graph makes rules about. - """ - - resource_type = Field("GraphDefinitionLink", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Why this link is specified", - description=( - "Information about why this link is of interest in this graph " - "definition." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - max: fhirtypes.String = Field( - None, - alias="max", - title="Maximum occurrences for this link", - description=None, - # if property is element of this resource. - element_property=True, - ) - max__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_max", title="Extension field for ``max``." - ) - - min: fhirtypes.Integer = Field( - None, - alias="min", - title="Minimum occurrences for this link", - description=None, - # if property is element of this resource. - element_property=True, - ) - min__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_min", title="Extension field for ``min``." - ) - - path: fhirtypes.String = Field( - None, - alias="path", - title="Path in the resource that contains the link", - description=( - "A FHIR expression that identifies one of FHIR References to other " - "resources." - ), - # if property is element of this resource. - element_property=True, - ) - path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_path", title="Extension field for ``path``." - ) - - sliceName: fhirtypes.String = Field( - None, - alias="sliceName", - title="Which slice (if profiled)", - description=None, - # if property is element of this resource. - element_property=True, - ) - sliceName__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sliceName", title="Extension field for ``sliceName``." - ) - - target: typing.List[fhirtypes.GraphDefinitionLinkTargetType] = Field( - None, - alias="target", - title="Potential target for the link", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``GraphDefinitionLink`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "path", - "sliceName", - "min", - "max", - "description", - "target", - ] - - -class GraphDefinitionLinkTarget(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Potential target for the link. - """ - - resource_type = Field("GraphDefinitionLinkTarget", const=True) - - compartment: typing.List[ - fhirtypes.GraphDefinitionLinkTargetCompartmentType - ] = Field( - None, - alias="compartment", - title="Compartment Consistency Rules", - description=None, - # if property is element of this resource. - element_property=True, - ) - - link: typing.List[fhirtypes.GraphDefinitionLinkType] = Field( - None, - alias="link", - title="Additional links from target resource", - description=None, - # if property is element of this resource. - element_property=True, - ) - - params: fhirtypes.String = Field( - None, - alias="params", - title="Criteria for reverse lookup", - description="A set of parameters to look up.", - # if property is element of this resource. - element_property=True, - ) - params__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_params", title="Extension field for ``params``." - ) - - profile: fhirtypes.Canonical = Field( - None, - alias="profile", - title="Profile for the target resource", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - profile__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_profile", title="Extension field for ``profile``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="Type of resource this link refers to", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``GraphDefinitionLinkTarget`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "params", - "profile", - "compartment", - "link", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2731( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class GraphDefinitionLinkTargetCompartment(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Compartment Consistency Rules. - """ - - resource_type = Field("GraphDefinitionLinkTargetCompartment", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Patient | Encounter | RelatedPerson | Practitioner | Device", - description="Identifies the compartment.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["Patient", "Encounter", "RelatedPerson", "Practitioner", "Device"], - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Documentation for FHIRPath expression", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - expression: fhirtypes.String = Field( - None, - alias="expression", - title="Custom rule, as a FHIRPath expression", - description=None, - # if property is element of this resource. - element_property=True, - ) - expression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expression", title="Extension field for ``expression``." - ) - - rule: fhirtypes.Code = Field( - None, - alias="rule", - title="identical | matching | different | custom", - description="identical | matching | different | no-rule | custom.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["identical", "matching", "different", "custom"], - ) - rule__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_rule", title="Extension field for ``rule``." - ) - - use: fhirtypes.Code = Field( - None, - alias="use", - title="condition | requirement", - description=( - "Defines how the compartment rule is used - whether it it is used to " - "test whether resources are subject to the rule, or whether it is a " - "rule that must be followed." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["condition", "requirement"], - ) - use__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_use", title="Extension field for ``use``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``GraphDefinitionLinkTargetCompartment`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "use", - "code", - "rule", - "expression", - "description", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3893( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("code", "code__ext"), - ("rule", "rule__ext"), - ("use", "use__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/group.py b/fhir/resources/group.py deleted file mode 100644 index ebfe871a..00000000 --- a/fhir/resources/group.py +++ /dev/null @@ -1,584 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Group -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Group(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Group of multiple entities. - Represents a defined collection of entities that may be discussed or acted - upon collectively but which are not expected to act collectively, and are - not formally or legally recognized; i.e. a collection of entities that - isn't an Organization. - """ - - resource_type = Field("Group", const=True) - - active: bool = Field( - None, - alias="active", - title="Whether this group's record is in active use", - description=( - "Indicates whether the record for the group is available for use or is " - "merely being retained for historical purposes." - ), - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - actual: bool = Field( - None, - alias="actual", - title="Descriptive or actual", - description=( - "If true, indicates that the resource refers to a specific group of " - "real individuals. If false, the group defines a set of intended " - "individuals." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - actual__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_actual", title="Extension field for ``actual``." - ) - - characteristic: typing.List[fhirtypes.GroupCharacteristicType] = Field( - None, - alias="characteristic", - title="Include / Exclude group members by Trait", - description=( - "Identifies traits whose presence r absence is shared by members of the" - " group." - ), - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Kind of Group members", - description=( - 'Provides a specific type of resource the group includes; e.g. "cow", ' - '"syringe", etc.' - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Unique id", - description="A unique business identifier for this group.", - # if property is element of this resource. - element_property=True, - ) - - managingEntity: fhirtypes.ReferenceType = Field( - None, - alias="managingEntity", - title="Entity that is the custodian of the Group's definition", - description=( - "Entity responsible for defining and maintaining Group characteristics " - "and/or registered members." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Organization", - "RelatedPerson", - "Practitioner", - "PractitionerRole", - ], - ) - - member: typing.List[fhirtypes.GroupMemberType] = Field( - None, - alias="member", - title="Who or what is in group", - description="Identifies the resource instances that are members of the group.", - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Label for Group", - description=( - "A label assigned to the group for human identification and " - "communication." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - quantity: fhirtypes.UnsignedInt = Field( - None, - alias="quantity", - title="Number of members", - description=( - "A count of the number of resource instances that are part of the " "group." - ), - # if property is element of this resource. - element_property=True, - ) - quantity__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_quantity", title="Extension field for ``quantity``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="person | animal | practitioner | device | medication | substance", - description=( - "Identifies the broad classification of the kind of resources the group" - " includes." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "person", - "animal", - "practitioner", - "device", - "medication", - "substance", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Group`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "active", - "type", - "actual", - "code", - "name", - "quantity", - "managingEntity", - "characteristic", - "member", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_708( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("actual", "actual__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class GroupCharacteristic(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Include / Exclude group members by Trait. - Identifies traits whose presence r absence is shared by members of the - group. - """ - - resource_type = Field("GroupCharacteristic", const=True) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Kind of characteristic", - description="A code that identifies the kind of trait being asserted.", - # if property is element of this resource. - element_property=True, - ) - - exclude: bool = Field( - None, - alias="exclude", - title="Group includes or excludes", - description=( - "If true, indicates the characteristic is one that is NOT held by " - "members of the group." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - exclude__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_exclude", title="Extension field for ``exclude``." - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Period over which characteristic is tested", - description=( - "The period over which the characteristic is tested; e.g. the patient " - "had an operation during the month of June." - ), - # if property is element of this resource. - element_property=True, - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Value held by characteristic", - description=( - "The value of the trait that holds (or does not hold - see 'exclude') " - "for members of the group." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="Value held by characteristic", - description=( - "The value of the trait that holds (or does not hold - see 'exclude') " - "for members of the group." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Value held by characteristic", - description=( - "The value of the trait that holds (or does not hold - see 'exclude') " - "for members of the group." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueRange: fhirtypes.RangeType = Field( - None, - alias="valueRange", - title="Value held by characteristic", - description=( - "The value of the trait that holds (or does not hold - see 'exclude') " - "for members of the group." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="Value held by characteristic", - description=( - "The value of the trait that holds (or does not hold - see 'exclude') " - "for members of the group." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``GroupCharacteristic`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "valueCodeableConcept", - "valueBoolean", - "valueQuantity", - "valueRange", - "valueReference", - "exclude", - "period", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2144( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("exclude", "exclude__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2144( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueBoolean", - "valueCodeableConcept", - "valueQuantity", - "valueRange", - "valueReference", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class GroupMember(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Who or what is in group. - Identifies the resource instances that are members of the group. - """ - - resource_type = Field("GroupMember", const=True) - - entity: fhirtypes.ReferenceType = Field( - ..., - alias="entity", - title="Reference to the group member", - description=( - "A reference to the entity that is a member of the group. Must be " - "consistent with Group.type. If the entity is another group, then the " - "type must be the same." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "Device", - "Medication", - "Substance", - "Group", - ], - ) - - inactive: bool = Field( - None, - alias="inactive", - title="If member is no longer in group", - description=( - "A flag to indicate that the member is no longer in the group, but " - "previously may have been a member." - ), - # if property is element of this resource. - element_property=True, - ) - inactive__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_inactive", title="Extension field for ``inactive``." - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Period member belonged to the group", - description="The period that the member was in the group, if known.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``GroupMember`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "entity", "period", "inactive"] diff --git a/fhir/resources/guidanceresponse.py b/fhir/resources/guidanceresponse.py deleted file mode 100644 index 2276a76f..00000000 --- a/fhir/resources/guidanceresponse.py +++ /dev/null @@ -1,430 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/GuidanceResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class GuidanceResponse(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The formal response to a guidance request. - A guidance response is the formal response to a guidance request, including - any output parameters returned by the evaluation, as well as the - description of any proposed actions to be taken. - """ - - resource_type = Field("GuidanceResponse", const=True) - - dataRequirement: typing.List[fhirtypes.DataRequirementType] = Field( - None, - alias="dataRequirement", - title="Additional required data", - description=( - "If the evaluation could not be completed due to lack of information, " - "or additional information would potentially result in a more accurate " - "response, this element will a description of the data required in " - "order to proceed with the evaluation. A subsequent request to the " - "service should include this data." - ), - # if property is element of this resource. - element_property=True, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter during which the response was returned", - description=( - "The encounter during which this response was created or to which the " - "creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - evaluationMessage: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="evaluationMessage", - title="Messages resulting from the evaluation of the artifact or artifacts", - description=( - "Messages resulting from the evaluation of the artifact or artifacts. " - "As part of evaluating the request, the engine may produce " - "informational or warning messages. These messages will be provided by " - "this element." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["OperationOutcome"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier", - description=( - "Allows a service to provide unique, business identifiers for the " - "response." - ), - # if property is element of this resource. - element_property=True, - ) - - moduleCanonical: fhirtypes.Canonical = Field( - None, - alias="moduleCanonical", - title="What guidance was requested", - description=( - "An identifier, CodeableConcept or canonical reference to the guidance " - "that was requested." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e module[x] - one_of_many="module", - one_of_many_required=True, - ) - moduleCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_moduleCanonical", title="Extension field for ``moduleCanonical``." - ) - - moduleCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="moduleCodeableConcept", - title="What guidance was requested", - description=( - "An identifier, CodeableConcept or canonical reference to the guidance " - "that was requested." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e module[x] - one_of_many="module", - one_of_many_required=True, - ) - - moduleUri: fhirtypes.Uri = Field( - None, - alias="moduleUri", - title="What guidance was requested", - description=( - "An identifier, CodeableConcept or canonical reference to the guidance " - "that was requested." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e module[x] - one_of_many="module", - one_of_many_required=True, - ) - moduleUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_moduleUri", title="Extension field for ``moduleUri``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Additional notes about the response", - description=( - "Provides a mechanism to communicate additional information about the " - "response." - ), - # if property is element of this resource. - element_property=True, - ) - - occurrenceDateTime: fhirtypes.DateTime = Field( - None, - alias="occurrenceDateTime", - title="When the guidance response was processed", - description="Indicates when the guidance response was processed.", - # if property is element of this resource. - element_property=True, - ) - occurrenceDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurrenceDateTime", - title="Extension field for ``occurrenceDateTime``.", - ) - - outputParameters: fhirtypes.ReferenceType = Field( - None, - alias="outputParameters", - title="The output parameters of the evaluation, if any", - description=( - "The output parameters of the evaluation, if any. Many modules will " - "result in the return of specific resources such as procedure or " - "communication requests that are returned as part of the operation " - "result. However, modules may define specific outputs that would be " - "returned as the result of the evaluation, and these would be returned " - "in this element." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Parameters"], - ) - - performer: fhirtypes.ReferenceType = Field( - None, - alias="performer", - title="Device returning the guidance", - description="Provides a reference to the device that performed the guidance.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why guidance is needed", - description=( - "Describes the reason for the guidance response in coded or textual " - "form." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why guidance is needed", - description=( - "Indicates the reason the request was initiated. This is typically " - "provided as a parameter to the evaluation and echoed by the service, " - "although for some use cases, such as subscription- or event-based " - "scenarios, it may provide an indication of the cause for the response." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "DiagnosticReport", - "DocumentReference", - ], - ) - - requestIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="requestIdentifier", - title="The identifier of the request associated with this response, if any", - description=( - "The identifier of the request associated with this response. If an " - "identifier was given as part of the request, it will be reproduced " - "here to enable the requester to more easily identify the response in a" - " multi-request scenario." - ), - # if property is element of this resource. - element_property=True, - ) - - result: fhirtypes.ReferenceType = Field( - None, - alias="result", - title="Proposed actions, if any", - description="The actions, if any, produced by the evaluation of the artifact.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CarePlan", "RequestGroup"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "success | data-requested | data-required | in-progress | failure | " - "entered-in-error" - ), - description=( - "The status of the response. If the evaluation is completed " - "successfully, the status will indicate success. However, in order to " - "complete the evaluation, the engine may require more information. In " - "this case, the status will be data-required, and the response will " - "contain a description of the additional required information. If the " - "evaluation completed successfully, but the engine determines that a " - "potentially more accurate response could be provided if more data was " - "available, the status will be data-requested, and the response will " - "contain a description of the additional requested information." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "success", - "data-requested", - "data-required", - "in-progress", - "failure", - "entered-in-error", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Patient the request was performed for", - description="The patient for which the request was processed.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``GuidanceResponse`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "requestIdentifier", - "identifier", - "moduleUri", - "moduleCanonical", - "moduleCodeableConcept", - "status", - "subject", - "encounter", - "occurrenceDateTime", - "performer", - "reasonCode", - "reasonReference", - "note", - "evaluationMessage", - "outputParameters", - "result", - "dataRequirement", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1819( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1819( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "module": ["moduleCanonical", "moduleCodeableConcept", "moduleUri"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/healthcareservice.py b/fhir/resources/healthcareservice.py deleted file mode 100644 index 84fe8150..00000000 --- a/fhir/resources/healthcareservice.py +++ /dev/null @@ -1,617 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/HealthcareService -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class HealthcareService(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The details of a healthcare service available at a location. - """ - - resource_type = Field("HealthcareService", const=True) - - active: bool = Field( - None, - alias="active", - title="Whether this HealthcareService record is in active use", - description=( - "This flag is used to mark the record to not be used. This is not used " - "when a center is closed for maintenance, or for holidays, the " - "notAvailable period is to be used for this." - ), - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - appointmentRequired: bool = Field( - None, - alias="appointmentRequired", - title="If an appointment is required for access to this service", - description=( - "Indicates whether or not a prospective consumer will require an " - "appointment for a particular service at a site to be provided by the " - "Organization. Indicates if an appointment is required for access to " - "this service." - ), - # if property is element of this resource. - element_property=True, - ) - appointmentRequired__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_appointmentRequired", - title="Extension field for ``appointmentRequired``.", - ) - - availabilityExceptions: fhirtypes.String = Field( - None, - alias="availabilityExceptions", - title="Description of availability exceptions", - description=( - "A description of site availability exceptions, e.g. public holiday " - "availability. Succinctly describing all possible exceptions to normal " - "site availability as details in the available Times and not available " - "Times." - ), - # if property is element of this resource. - element_property=True, - ) - availabilityExceptions__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_availabilityExceptions", - title="Extension field for ``availabilityExceptions``.", - ) - - availableTime: typing.List[fhirtypes.HealthcareServiceAvailableTimeType] = Field( - None, - alias="availableTime", - title="Times the Service Site is available", - description="A collection of times that the Service Site is available.", - # if property is element of this resource. - element_property=True, - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Broad category of service being performed or delivered", - description="Identifies the broad category of service being performed or delivered.", - # if property is element of this resource. - element_property=True, - ) - - characteristic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="characteristic", - title="Collection of characteristics (attributes)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title=( - "Additional description and/or any specific issues not covered " "elsewhere" - ), - description=( - "Any additional description of the service and/or any specific issues " - "not covered by the other attributes, which can be displayed as further" - " detail under the serviceName." - ), - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - communication: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="communication", - title="The language that this service is offered in", - description=( - "Some services are specifically made available in multiple languages, " - "this property permits a directory to declare the languages this is " - "offered in. Typically this is only provided where a service operates " - "in communities with mixed languages used." - ), - # if property is element of this resource. - element_property=True, - ) - - coverageArea: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="coverageArea", - title="Location(s) service is intended for/available to", - description=( - "The location(s) that this service is available to (not where the " - "service is provided)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - eligibility: typing.List[fhirtypes.HealthcareServiceEligibilityType] = Field( - None, - alias="eligibility", - title="Specific eligibility requirements required to use the service", - description=( - "Does this service have specific eligibility requirements that need to " - "be met in order to use the service?" - ), - # if property is element of this resource. - element_property=True, - ) - - endpoint: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="endpoint", - title=( - "Technical endpoints providing access to electronic services operated " - "for the healthcare service" - ), - description=( - "Technical endpoints providing access to services operated for the " - "specific healthcare services defined at this resource." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Endpoint"], - ) - - extraDetails: fhirtypes.Markdown = Field( - None, - alias="extraDetails", - title=( - "Extra details about the service that can't be placed in the other " - "fields" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - extraDetails__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_extraDetails", title="Extension field for ``extraDetails``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External identifiers for this item", - description=None, - # if property is element of this resource. - element_property=True, - ) - - location: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="location", - title="Location(s) where service may be provided", - description="The location(s) where this healthcare service may be provided.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Description of service as presented to a consumer while searching", - description=( - "Further description of the service as it would be presented to a " - "consumer while searching." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - notAvailable: typing.List[fhirtypes.HealthcareServiceNotAvailableType] = Field( - None, - alias="notAvailable", - title="Not available during this time due to provided reason", - description=( - "The HealthcareService is not available during this period of time due " - "to the provided reason." - ), - # if property is element of this resource. - element_property=True, - ) - - photo: fhirtypes.AttachmentType = Field( - None, - alias="photo", - title="Facilitates quick identification of the service", - description=( - "If there is a photo/symbol associated with this HealthcareService, it " - "may be included here to facilitate quick identification of the service" - " in a list." - ), - # if property is element of this resource. - element_property=True, - ) - - program: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="program", - title="Programs that this service is applicable to", - description=None, - # if property is element of this resource. - element_property=True, - ) - - providedBy: fhirtypes.ReferenceType = Field( - None, - alias="providedBy", - title="Organization that provides this service", - description="The organization that provides this healthcare service.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - referralMethod: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="referralMethod", - title="Ways that the service accepts referrals", - description=( - "Ways that the service accepts referrals, if this is not provided then " - "it is implied that no referral is required." - ), - # if property is element of this resource. - element_property=True, - ) - - serviceProvisionCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="serviceProvisionCode", - title="Conditions under which service is available/offered", - description=( - "The code(s) that detail the conditions under which the healthcare " - "service is available/offered." - ), - # if property is element of this resource. - element_property=True, - ) - - specialty: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="specialty", - title="Specialties handled by the HealthcareService", - description=( - "Collection of specialties handled by the service site. This is more of" - " a medical term." - ), - # if property is element of this resource. - element_property=True, - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="Contacts related to the healthcare service", - description="List of contacts related to this specific healthcare service.", - # if property is element of this resource. - element_property=True, - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Type of service that may be delivered or performed", - description="The specific type of service that may be delivered or performed.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``HealthcareService`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "active", - "providedBy", - "category", - "type", - "specialty", - "location", - "name", - "comment", - "extraDetails", - "photo", - "telecom", - "coverageArea", - "serviceProvisionCode", - "eligibility", - "program", - "characteristic", - "communication", - "referralMethod", - "appointmentRequired", - "availableTime", - "notAvailable", - "availabilityExceptions", - "endpoint", - ] - - -class HealthcareServiceAvailableTime(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Times the Service Site is available. - A collection of times that the Service Site is available. - """ - - resource_type = Field("HealthcareServiceAvailableTime", const=True) - - allDay: bool = Field( - None, - alias="allDay", - title="Always available? e.g. 24 hour service", - description=( - "Is this always available? (hence times are irrelevant) e.g. 24 hour " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - allDay__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_allDay", title="Extension field for ``allDay``." - ) - - availableEndTime: fhirtypes.Time = Field( - None, - alias="availableEndTime", - title="Closing time of day (ignored if allDay = true)", - description=( - "The closing time of day. Note: If the AllDay flag is set, then this " - "time is ignored." - ), - # if property is element of this resource. - element_property=True, - ) - availableEndTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_availableEndTime", - title="Extension field for ``availableEndTime``.", - ) - - availableStartTime: fhirtypes.Time = Field( - None, - alias="availableStartTime", - title="Opening time of day (ignored if allDay = true)", - description=( - "The opening time of day. Note: If the AllDay flag is set, then this " - "time is ignored." - ), - # if property is element of this resource. - element_property=True, - ) - availableStartTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_availableStartTime", - title="Extension field for ``availableStartTime``.", - ) - - daysOfWeek: typing.List[fhirtypes.Code] = Field( - None, - alias="daysOfWeek", - title="mon | tue | wed | thu | fri | sat | sun", - description=( - "Indicates which days of the week are available between the start and " - "end Times." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["mon", "tue", "wed", "thu", "fri", "sat", "sun"], - ) - daysOfWeek__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_daysOfWeek", title="Extension field for ``daysOfWeek``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``HealthcareServiceAvailableTime`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "daysOfWeek", - "allDay", - "availableStartTime", - "availableEndTime", - ] - - -class HealthcareServiceEligibility(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Specific eligibility requirements required to use the service. - Does this service have specific eligibility requirements that need to be - met in order to use the service? - """ - - resource_type = Field("HealthcareServiceEligibility", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Coded value for the eligibility", - description=None, - # if property is element of this resource. - element_property=True, - ) - - comment: fhirtypes.Markdown = Field( - None, - alias="comment", - title="Describes the eligibility conditions for the service", - description=None, - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``HealthcareServiceEligibility`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "comment"] - - -class HealthcareServiceNotAvailable(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Not available during this time due to provided reason. - The HealthcareService is not available during this period of time due to - the provided reason. - """ - - resource_type = Field("HealthcareServiceNotAvailable", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Reason presented to the user explaining why time not available", - description=( - "The reason that can be presented to the user as to why this time is " - "not available." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - during: fhirtypes.PeriodType = Field( - None, - alias="during", - title="Service not available from this date", - description=( - "Service is not available (seasonally or for a public holiday) from " - "this date." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``HealthcareServiceNotAvailable`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "description", "during"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3105( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("description", "description__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/humanname.py b/fhir/resources/humanname.py deleted file mode 100644 index 7eecc0fb..00000000 --- a/fhir/resources/humanname.py +++ /dev/null @@ -1,153 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/HumanName -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import element, fhirtypes - - -class HumanName(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Name of a human - parts and usage. - A human's name with the ability to identify parts and usage. - """ - - resource_type = Field("HumanName", const=True) - - family: fhirtypes.String = Field( - None, - alias="family", - title="Family name (often called 'Surname')", - description=( - "The part of a name that links to the genealogy. In some cultures (e.g." - " Eritrea) the family name of a son is the first name of his father." - ), - # if property is element of this resource. - element_property=True, - ) - family__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_family", title="Extension field for ``family``." - ) - - given: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="given", - title="Given names (not always 'first'). Includes middle names", - description="Given name.", - # if property is element of this resource. - element_property=True, - ) - given__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_given", title="Extension field for ``given``.") - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Time period when name was/is in use", - description=( - "Indicates the period of time when this name was valid for the named " - "person." - ), - # if property is element of this resource. - element_property=True, - ) - - prefix: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="prefix", - title="Parts that come before the name", - description=( - "Part of the name that is acquired as a title due to academic, legal, " - "employment or nobility status, etc. and that appears at the start of " - "the name." - ), - # if property is element of this resource. - element_property=True, - ) - prefix__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_prefix", title="Extension field for ``prefix``.") - - suffix: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="suffix", - title="Parts that come after the name", - description=( - "Part of the name that is acquired as a title due to academic, legal, " - "employment or nobility status, etc. and that appears at the end of the" - " name." - ), - # if property is element of this resource. - element_property=True, - ) - suffix__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_suffix", title="Extension field for ``suffix``.") - - text: fhirtypes.String = Field( - None, - alias="text", - title="Text representation of the full name", - description=( - "Specifies the entire name as it should be displayed e.g. on an " - "application UI. This may be provided instead of or as well as the " - "specific parts." - ), - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - use: fhirtypes.Code = Field( - None, - alias="use", - title="usual | official | temp | nickname | anonymous | old | maiden", - description="Identifies the purpose for this name.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "usual", - "official", - "temp", - "nickname", - "anonymous", - "old", - "maiden", - ], - ) - use__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_use", title="Extension field for ``use``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``HumanName`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "use", - "text", - "family", - "given", - "prefix", - "suffix", - "period", - ] diff --git a/fhir/resources/identifier.py b/fhir/resources/identifier.py deleted file mode 100644 index 85118226..00000000 --- a/fhir/resources/identifier.py +++ /dev/null @@ -1,118 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Identifier -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import element, fhirtypes - - -class Identifier(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An identifier intended for computation. - An identifier - identifies some entity uniquely and unambiguously. - Typically this is used for business identifiers. - """ - - resource_type = Field("Identifier", const=True) - - assigner: fhirtypes.ReferenceType = Field( - None, - alias="assigner", - title="Organization that issued id (may be just text)", - description="Organization that issued/manages the identifier.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Time period when id is/was valid for use", - description="Time period during which identifier is/was valid for use.", - # if property is element of this resource. - element_property=True, - ) - - system: fhirtypes.Uri = Field( - None, - alias="system", - title="The namespace for the identifier value", - description=( - "Establishes the namespace for the value - that is, a URL that " - "describes a set values that are unique." - ), - # if property is element of this resource. - element_property=True, - ) - system__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_system", title="Extension field for ``system``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Description of identifier", - description=( - "A coded type for the identifier that can be used to determine which " - "identifier to use for a specific purpose." - ), - # if property is element of this resource. - element_property=True, - ) - - use: fhirtypes.Code = Field( - None, - alias="use", - title="usual | official | temp | secondary | old (If known)", - description="The purpose of this identifier.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["usual", "official", "temp", "secondary", "old"], - ) - use__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_use", title="Extension field for ``use``." - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="The value that is unique", - description=( - "The portion of the identifier typically relevant to the user and which" - " is unique within the context of the system." - ), - # if property is element of this resource. - element_property=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Identifier`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "use", - "type", - "system", - "value", - "period", - "assigner", - ] diff --git a/fhir/resources/imagingstudy.py b/fhir/resources/imagingstudy.py deleted file mode 100644 index 598f80ec..00000000 --- a/fhir/resources/imagingstudy.py +++ /dev/null @@ -1,836 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ImagingStudy -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ImagingStudy(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A set of images produced in single study (one or more series of references - images). - Representation of the content produced in a DICOM imaging study. A study - comprises a set of series, each of which includes a set of Service-Object - Pair Instances (SOP Instances - images or other data) acquired or produced - in a common context. A series is of only one modality (e.g. X-ray, CT, MR, - ultrasound), but a study may have multiple series of different modalities. - """ - - resource_type = Field("ImagingStudy", const=True) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Request fulfilled", - description=( - "A list of the diagnostic requests that resulted in this imaging study " - "being performed." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "CarePlan", - "ServiceRequest", - "Appointment", - "AppointmentResponse", - "Task", - ], - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Institution-generated description", - description=( - "The Imaging Manager description of the study. Institution-generated " - "description or classification of the Study (component) performed." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter with which this imaging study is associated", - description=( - "The healthcare event (e.g. a patient and healthcare provider " - "interaction) during which this ImagingStudy is made." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - endpoint: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="endpoint", - title="Study access endpoint", - description=( - "The network service providing access (e.g., query, view, or retrieval)" - " for the study. See implementation notes for information about using " - "DICOM endpoints. A study-level endpoint applies to each series in the " - "study, unless overridden by a series-level endpoint with the same " - "Endpoint.connectionType." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Endpoint"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Identifiers for the whole study", - description=( - "Identifiers for the ImagingStudy such as DICOM Study Instance UID, and" - " Accession Number." - ), - # if property is element of this resource. - element_property=True, - ) - - interpreter: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="interpreter", - title="Who interpreted images", - description="Who read the study and interpreted the images or other content.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - location: fhirtypes.ReferenceType = Field( - None, - alias="location", - title="Where ImagingStudy occurred", - description="The principal physical location where the ImagingStudy was performed.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - modality: typing.List[fhirtypes.CodingType] = Field( - None, - alias="modality", - title="All series modality if actual acquisition modalities", - description=( - "A list of all the series.modality values that are actual acquisition " - "modalities, i.e. those in the DICOM Context Group 29 (value set OID " - "1.2.840.10008.6.1.19)." - ), - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="User-defined comments", - description=( - "Per the recommended DICOM mapping, this element is derived from the " - "Study Description attribute (0008,1030). Observations or findings " - "about the imaging study should be recorded in another resource, e.g. " - "Observation, and not in this element." - ), - # if property is element of this resource. - element_property=True, - ) - - numberOfInstances: fhirtypes.UnsignedInt = Field( - None, - alias="numberOfInstances", - title="Number of Study Related Instances", - description=( - "Number of SOP Instances in Study. This value given may be larger than " - "the number of instance elements this resource contains due to resource" - " availability, security, or other factors. This element should be " - "present if any instance elements are present." - ), - # if property is element of this resource. - element_property=True, - ) - numberOfInstances__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_numberOfInstances", - title="Extension field for ``numberOfInstances``.", - ) - - numberOfSeries: fhirtypes.UnsignedInt = Field( - None, - alias="numberOfSeries", - title="Number of Study Related Series", - description=( - "Number of Series in the Study. This value given may be larger than the" - " number of series elements this Resource contains due to resource " - "availability, security, or other factors. This element should be " - "present if any series elements are present." - ), - # if property is element of this resource. - element_property=True, - ) - numberOfSeries__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_numberOfSeries", title="Extension field for ``numberOfSeries``." - ) - - procedureCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="procedureCode", - title="The performed procedure code", - description="The code for the performed procedure type.", - # if property is element of this resource. - element_property=True, - ) - - procedureReference: fhirtypes.ReferenceType = Field( - None, - alias="procedureReference", - title="The performed Procedure reference", - description="The procedure which this ImagingStudy was part of.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Procedure"], - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why the study was requested", - description=( - "Description of clinical condition indicating why the ImagingStudy was " - "requested." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why was study performed", - description="Indicates another resource whose existence justifies this Study.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "Media", - "DiagnosticReport", - "DocumentReference", - ], - ) - - referrer: fhirtypes.ReferenceType = Field( - None, - alias="referrer", - title="Referring physician", - description="The requesting/referring physician.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - series: typing.List[fhirtypes.ImagingStudySeriesType] = Field( - None, - alias="series", - title="Each study has one or more series of instances", - description="Each study has one or more series of images or other content.", - # if property is element of this resource. - element_property=True, - ) - - started: fhirtypes.DateTime = Field( - None, - alias="started", - title="When the study was started", - description="Date and time the study started.", - # if property is element of this resource. - element_property=True, - ) - started__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_started", title="Extension field for ``started``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="registered | available | cancelled | entered-in-error | unknown", - description="The current state of the ImagingStudy.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "registered", - "available", - "cancelled", - "entered-in-error", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Who or what is the subject of the study", - description="The subject, typically a patient, of the imaging study.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Device", "Group"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImagingStudy`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "modality", - "subject", - "encounter", - "started", - "basedOn", - "referrer", - "interpreter", - "endpoint", - "numberOfSeries", - "numberOfInstances", - "procedureReference", - "procedureCode", - "location", - "reasonCode", - "reasonReference", - "note", - "description", - "series", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1431( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ImagingStudySeries(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Each study has one or more series of instances. - Each study has one or more series of images or other content. - """ - - resource_type = Field("ImagingStudySeries", const=True) - - bodySite: fhirtypes.CodingType = Field( - None, - alias="bodySite", - title="Body part examined", - description=( - "The anatomic structures examined. See DICOM Part 16 Annex L (http://di" - "com.nema.org/medical/dicom/current/output/chtml/part16/chapter_L.html)" - " for DICOM to SNOMED-CT mappings. The bodySite may indicate the " - "laterality of body part imaged; if so, it shall be consistent with any" - " content of ImagingStudy.series.laterality." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="A short human readable summary of the series", - description="A description of the series.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - endpoint: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="endpoint", - title="Series access endpoint", - description=( - "The network service providing access (e.g., query, view, or retrieval)" - " for this series. See implementation notes for information about using" - " DICOM endpoints. A series-level endpoint, if present, has precedence " - "over a study-level endpoint with the same Endpoint.connectionType." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Endpoint"], - ) - - instance: typing.List[fhirtypes.ImagingStudySeriesInstanceType] = Field( - None, - alias="instance", - title="A single SOP instance from the series", - description=( - "A single SOP instance within the series, e.g. an image, or " - "presentation state." - ), - # if property is element of this resource. - element_property=True, - ) - - laterality: fhirtypes.CodingType = Field( - None, - alias="laterality", - title="Body part laterality", - description=( - "The laterality of the (possibly paired) anatomic structures examined. " - "E.g., the left knee, both lungs, or unpaired abdomen. If present, " - "shall be consistent with any laterality information indicated in " - "ImagingStudy.series.bodySite." - ), - # if property is element of this resource. - element_property=True, - ) - - modality: fhirtypes.CodingType = Field( - ..., - alias="modality", - title="The modality of the instances in the series", - description="The modality of this series sequence.", - # if property is element of this resource. - element_property=True, - ) - - number: fhirtypes.UnsignedInt = Field( - None, - alias="number", - title="Numeric identifier of this series", - description="The numeric identifier of this series in the study.", - # if property is element of this resource. - element_property=True, - ) - number__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_number", title="Extension field for ``number``." - ) - - numberOfInstances: fhirtypes.UnsignedInt = Field( - None, - alias="numberOfInstances", - title="Number of Series Related Instances", - description=( - "Number of SOP Instances in the Study. The value given may be larger " - "than the number of instance elements this resource contains due to " - "resource availability, security, or other factors. This element should" - " be present if any instance elements are present." - ), - # if property is element of this resource. - element_property=True, - ) - numberOfInstances__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_numberOfInstances", - title="Extension field for ``numberOfInstances``.", - ) - - performer: typing.List[fhirtypes.ImagingStudySeriesPerformerType] = Field( - None, - alias="performer", - title="Who performed the series", - description="Indicates who or what performed the series and how they were involved.", - # if property is element of this resource. - element_property=True, - ) - - specimen: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="specimen", - title="Specimen imaged", - description="The specimen imaged, e.g., for whole slide imaging of a biopsy.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Specimen"], - ) - - started: fhirtypes.DateTime = Field( - None, - alias="started", - title="When the series started", - description="The date and time the series was started.", - # if property is element of this resource. - element_property=True, - ) - started__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_started", title="Extension field for ``started``." - ) - - uid: fhirtypes.Id = Field( - None, - alias="uid", - title="DICOM Series Instance UID for the series", - description="The DICOM Series Instance UID for the series.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - uid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_uid", title="Extension field for ``uid``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImagingStudySeries`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "uid", - "number", - "modality", - "description", - "numberOfInstances", - "endpoint", - "bodySite", - "laterality", - "specimen", - "started", - "performer", - "instance", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2044( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("uid", "uid__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ImagingStudySeriesInstance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A single SOP instance from the series. - A single SOP instance within the series, e.g. an image, or presentation - state. - """ - - resource_type = Field("ImagingStudySeriesInstance", const=True) - - number: fhirtypes.UnsignedInt = Field( - None, - alias="number", - title="The number of this instance in the series", - description="The number of instance in the series.", - # if property is element of this resource. - element_property=True, - ) - number__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_number", title="Extension field for ``number``." - ) - - sopClass: fhirtypes.CodingType = Field( - ..., - alias="sopClass", - title="DICOM class type", - description="DICOM instance type.", - # if property is element of this resource. - element_property=True, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Description of instance", - description="The description of the instance.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - uid: fhirtypes.Id = Field( - None, - alias="uid", - title="DICOM SOP Instance UID", - description="The DICOM SOP Instance UID for this image or other DICOM content.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - uid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_uid", title="Extension field for ``uid``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImagingStudySeriesInstance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "uid", - "sopClass", - "number", - "title", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2851( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("uid", "uid__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ImagingStudySeriesPerformer(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Who performed the series. - Indicates who or what performed the series and how they were involved. - """ - - resource_type = Field("ImagingStudySeriesPerformer", const=True) - - actor: fhirtypes.ReferenceType = Field( - ..., - alias="actor", - title="Who performed the series", - description="Indicates who or what performed the series.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "CareTeam", - "Patient", - "Device", - "RelatedPerson", - ], - ) - - function: fhirtypes.CodeableConceptType = Field( - None, - alias="function", - title="Type of performance", - description="Distinguishes the type of involvement of the performer in the series.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImagingStudySeriesPerformer`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "function", "actor"] diff --git a/fhir/resources/immunization.py b/fhir/resources/immunization.py deleted file mode 100644 index 8b3bcd21..00000000 --- a/fhir/resources/immunization.py +++ /dev/null @@ -1,882 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Immunization -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Immunization(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Immunization event information. - Describes the event of a patient being administered a vaccine or a record - of an immunization as reported by a patient, a clinician or another party. - """ - - resource_type = Field("Immunization", const=True) - - doseQuantity: fhirtypes.QuantityType = Field( - None, - alias="doseQuantity", - title="Amount of vaccine administered", - description="The quantity of vaccine product that was administered.", - # if property is element of this resource. - element_property=True, - ) - - education: typing.List[fhirtypes.ImmunizationEducationType] = Field( - None, - alias="education", - title="Educational material presented to patient", - description=( - "Educational material presented to the patient (or guardian) at the " - "time of vaccine administration." - ), - # if property is element of this resource. - element_property=True, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter immunization was part of", - description=( - "The visit or admission or other contact between patient and health " - "care provider the immunization was performed as part of." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - expirationDate: fhirtypes.Date = Field( - None, - alias="expirationDate", - title="Vaccine expiration date", - description="Date vaccine batch expires.", - # if property is element of this resource. - element_property=True, - ) - expirationDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expirationDate", title="Extension field for ``expirationDate``." - ) - - fundingSource: fhirtypes.CodeableConceptType = Field( - None, - alias="fundingSource", - title="Funding source for the vaccine", - description=( - "Indicates the source of the vaccine actually administered. This may be" - " different than the patient eligibility (e.g. the patient may be " - "eligible for a publically purchased vaccine but due to inventory " - "issues, vaccine purchased with private funds was actually " - "administered)." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier", - description="A unique identifier assigned to this immunization record.", - # if property is element of this resource. - element_property=True, - ) - - isSubpotent: bool = Field( - None, - alias="isSubpotent", - title="Dose potency", - description=( - "Indication if a dose is considered to be subpotent. By default, a dose" - " should be considered to be potent." - ), - # if property is element of this resource. - element_property=True, - ) - isSubpotent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_isSubpotent", title="Extension field for ``isSubpotent``." - ) - - location: fhirtypes.ReferenceType = Field( - None, - alias="location", - title="Where immunization occurred", - description=( - "The service delivery location where the vaccine administration " - "occurred." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - lotNumber: fhirtypes.String = Field( - None, - alias="lotNumber", - title="Vaccine lot number", - description="Lot number of the vaccine product.", - # if property is element of this resource. - element_property=True, - ) - lotNumber__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lotNumber", title="Extension field for ``lotNumber``." - ) - - manufacturer: fhirtypes.ReferenceType = Field( - None, - alias="manufacturer", - title="Vaccine manufacturer", - description="Name of vaccine manufacturer.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Additional immunization notes", - description=( - "Extra information about the immunization that is not conveyed by the " - "other attributes." - ), - # if property is element of this resource. - element_property=True, - ) - - occurrenceDateTime: fhirtypes.DateTime = Field( - None, - alias="occurrenceDateTime", - title="Vaccine administration date", - description="Date vaccine administered or was to be administered.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=True, - ) - occurrenceDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurrenceDateTime", - title="Extension field for ``occurrenceDateTime``.", - ) - - occurrenceString: fhirtypes.String = Field( - None, - alias="occurrenceString", - title="Vaccine administration date", - description="Date vaccine administered or was to be administered.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=True, - ) - occurrenceString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurrenceString", - title="Extension field for ``occurrenceString``.", - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="Who was immunized", - description="The patient who either received or did not receive the immunization.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - performer: typing.List[fhirtypes.ImmunizationPerformerType] = Field( - None, - alias="performer", - title="Who performed event", - description="Indicates who performed the immunization event.", - # if property is element of this resource. - element_property=True, - ) - - primarySource: bool = Field( - None, - alias="primarySource", - title="Indicates context the data was recorded in", - description=( - "An indication that the content of the record is based on information " - "from the person who administered the vaccine. This reflects the " - "context under which the data was originally recorded." - ), - # if property is element of this resource. - element_property=True, - ) - primarySource__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_primarySource", title="Extension field for ``primarySource``." - ) - - programEligibility: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="programEligibility", - title="Patient eligibility for a vaccination program", - description="Indicates a patient's eligibility for a funding program.", - # if property is element of this resource. - element_property=True, - ) - - protocolApplied: typing.List[fhirtypes.ImmunizationProtocolAppliedType] = Field( - None, - alias="protocolApplied", - title="Protocol followed by the provider", - description=( - "The protocol (set of recommendations) being followed by the provider " - "who administered the dose." - ), - # if property is element of this resource. - element_property=True, - ) - - reaction: typing.List[fhirtypes.ImmunizationReactionType] = Field( - None, - alias="reaction", - title="Details of a reaction that follows immunization", - description=( - "Categorical data indicating that an adverse event is associated in " - "time to an immunization." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why immunization occurred", - description="Reasons why the vaccine was administered.", - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why immunization occurred", - description=( - "Condition, Observation or DiagnosticReport that supports why the " - "immunization was administered." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition", "Observation", "DiagnosticReport"], - ) - - recorded: fhirtypes.DateTime = Field( - None, - alias="recorded", - title="When the immunization was first captured in the subject's record", - description=( - "The date the occurrence of the immunization was first captured in the " - "record - potentially significantly after the occurrence of the event." - ), - # if property is element of this resource. - element_property=True, - ) - recorded__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_recorded", title="Extension field for ``recorded``." - ) - - reportOrigin: fhirtypes.CodeableConceptType = Field( - None, - alias="reportOrigin", - title="Indicates the source of a secondarily reported record", - description=( - "The source of the data when the report of the immunization event is " - "not based on information from the person who administered the vaccine." - ), - # if property is element of this resource. - element_property=True, - ) - - route: fhirtypes.CodeableConceptType = Field( - None, - alias="route", - title="How vaccine entered body", - description="The path by which the vaccine product is taken into the body.", - # if property is element of this resource. - element_property=True, - ) - - site: fhirtypes.CodeableConceptType = Field( - None, - alias="site", - title="Body site vaccine was administered", - description="Body site where vaccine was administered.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="completed | entered-in-error | not-done", - description="Indicates the current status of the immunization event.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["completed", "entered-in-error", "not-done"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReason: fhirtypes.CodeableConceptType = Field( - None, - alias="statusReason", - title="Reason not done", - description="Indicates the reason the immunization event was not performed.", - # if property is element of this resource. - element_property=True, - ) - - subpotentReason: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="subpotentReason", - title="Reason for being subpotent", - description="Reason why a dose is considered to be subpotent.", - # if property is element of this resource. - element_property=True, - ) - - vaccineCode: fhirtypes.CodeableConceptType = Field( - ..., - alias="vaccineCode", - title="Vaccine product administered", - description="Vaccine that was administered or was to be administered.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Immunization`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "statusReason", - "vaccineCode", - "patient", - "encounter", - "occurrenceDateTime", - "occurrenceString", - "recorded", - "primarySource", - "reportOrigin", - "location", - "manufacturer", - "lotNumber", - "expirationDate", - "site", - "route", - "doseQuantity", - "performer", - "note", - "reasonCode", - "reasonReference", - "isSubpotent", - "subpotentReason", - "education", - "programEligibility", - "fundingSource", - "reaction", - "protocolApplied", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1467( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1467( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"occurrence": ["occurrenceDateTime", "occurrenceString"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ImmunizationEducation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Educational material presented to patient. - Educational material presented to the patient (or guardian) at the time of - vaccine administration. - """ - - resource_type = Field("ImmunizationEducation", const=True) - - documentType: fhirtypes.String = Field( - None, - alias="documentType", - title="Educational material document identifier", - description="Identifier of the material presented to the patient.", - # if property is element of this resource. - element_property=True, - ) - documentType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentType", title="Extension field for ``documentType``." - ) - - presentationDate: fhirtypes.DateTime = Field( - None, - alias="presentationDate", - title="Educational material presentation date", - description="Date the educational material was given to the patient.", - # if property is element of this resource. - element_property=True, - ) - presentationDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_presentationDate", - title="Extension field for ``presentationDate``.", - ) - - publicationDate: fhirtypes.DateTime = Field( - None, - alias="publicationDate", - title="Educational material publication date", - description="Date the educational material was published.", - # if property is element of this resource. - element_property=True, - ) - publicationDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publicationDate", title="Extension field for ``publicationDate``." - ) - - reference: fhirtypes.Uri = Field( - None, - alias="reference", - title="Educational material reference pointer", - description=( - "Reference pointer to the educational material given to the patient if " - "the information was on line." - ), - # if property is element of this resource. - element_property=True, - ) - reference__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_reference", title="Extension field for ``reference``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImmunizationEducation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "documentType", - "reference", - "publicationDate", - "presentationDate", - ] - - -class ImmunizationPerformer(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Who performed event. - Indicates who performed the immunization event. - """ - - resource_type = Field("ImmunizationPerformer", const=True) - - actor: fhirtypes.ReferenceType = Field( - ..., - alias="actor", - title="Individual or organization who was performing", - description="The practitioner or organization who performed the action.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - function: fhirtypes.CodeableConceptType = Field( - None, - alias="function", - title="What type of performance was done", - description=( - "Describes the type of performance (e.g. ordering provider, " - "administering provider, etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImmunizationPerformer`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "function", "actor"] - - -class ImmunizationProtocolApplied(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Protocol followed by the provider. - The protocol (set of recommendations) being followed by the provider who - administered the dose. - """ - - resource_type = Field("ImmunizationProtocolApplied", const=True) - - authority: fhirtypes.ReferenceType = Field( - None, - alias="authority", - title="Who is responsible for publishing the recommendations", - description=( - "Indicates the authority who published the protocol (e.g. ACIP) that is" - " being followed." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - doseNumberPositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="doseNumberPositiveInt", - title="Dose number within series", - description="Nominal position in a series.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e doseNumber[x] - one_of_many="doseNumber", - one_of_many_required=True, - ) - doseNumberPositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_doseNumberPositiveInt", - title="Extension field for ``doseNumberPositiveInt``.", - ) - - doseNumberString: fhirtypes.String = Field( - None, - alias="doseNumberString", - title="Dose number within series", - description="Nominal position in a series.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e doseNumber[x] - one_of_many="doseNumber", - one_of_many_required=True, - ) - doseNumberString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_doseNumberString", - title="Extension field for ``doseNumberString``.", - ) - - series: fhirtypes.String = Field( - None, - alias="series", - title="Name of vaccine series", - description=( - "One possible path to achieve presumed immunity against a disease - " - "within the context of an authority." - ), - # if property is element of this resource. - element_property=True, - ) - series__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_series", title="Extension field for ``series``." - ) - - seriesDosesPositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="seriesDosesPositiveInt", - title="Recommended number of doses for immunity", - description="The recommended number of doses to achieve immunity.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e seriesDoses[x] - one_of_many="seriesDoses", - one_of_many_required=False, - ) - seriesDosesPositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_seriesDosesPositiveInt", - title="Extension field for ``seriesDosesPositiveInt``.", - ) - - seriesDosesString: fhirtypes.String = Field( - None, - alias="seriesDosesString", - title="Recommended number of doses for immunity", - description="The recommended number of doses to achieve immunity.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e seriesDoses[x] - one_of_many="seriesDoses", - one_of_many_required=False, - ) - seriesDosesString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_seriesDosesString", - title="Extension field for ``seriesDosesString``.", - ) - - targetDisease: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="targetDisease", - title="Vaccine preventatable disease being targetted", - description=( - "The vaccine preventable disease the dose is being administered " "against." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImmunizationProtocolApplied`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "series", - "authority", - "targetDisease", - "doseNumberPositiveInt", - "doseNumberString", - "seriesDosesPositiveInt", - "seriesDosesString", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3010( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "doseNumber": ["doseNumberPositiveInt", "doseNumberString"], - "seriesDoses": ["seriesDosesPositiveInt", "seriesDosesString"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ImmunizationReaction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Details of a reaction that follows immunization. - Categorical data indicating that an adverse event is associated in time to - an immunization. - """ - - resource_type = Field("ImmunizationReaction", const=True) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="When reaction started", - description="Date of reaction to the immunization.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - detail: fhirtypes.ReferenceType = Field( - None, - alias="detail", - title="Additional information on reaction", - description="Details of the reaction.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Observation"], - ) - - reported: bool = Field( - None, - alias="reported", - title="Indicates self-reported reaction", - description="Self-reported indicator.", - # if property is element of this resource. - element_property=True, - ) - reported__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_reported", title="Extension field for ``reported``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImmunizationReaction`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "date", "detail", "reported"] diff --git a/fhir/resources/immunizationevaluation.py b/fhir/resources/immunizationevaluation.py deleted file mode 100644 index 83aaaa89..00000000 --- a/fhir/resources/immunizationevaluation.py +++ /dev/null @@ -1,365 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ImmunizationEvaluation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class ImmunizationEvaluation(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Immunization evaluation information. - Describes a comparison of an immunization event against published - recommendations to determine if the administration is "valid" in relation - to those recommendations. - """ - - resource_type = Field("ImmunizationEvaluation", const=True) - - authority: fhirtypes.ReferenceType = Field( - None, - alias="authority", - title="Who is responsible for publishing the recommendations", - description="Indicates the authority who published the protocol (e.g. ACIP).", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date evaluation was performed", - description=( - "The date the evaluation of the vaccine administration event was " - "performed." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Evaluation notes", - description="Additional information about the evaluation.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - doseNumberPositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="doseNumberPositiveInt", - title="Dose number within series", - description="Nominal position in a series.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e doseNumber[x] - one_of_many="doseNumber", - one_of_many_required=False, - ) - doseNumberPositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_doseNumberPositiveInt", - title="Extension field for ``doseNumberPositiveInt``.", - ) - - doseNumberString: fhirtypes.String = Field( - None, - alias="doseNumberString", - title="Dose number within series", - description="Nominal position in a series.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e doseNumber[x] - one_of_many="doseNumber", - one_of_many_required=False, - ) - doseNumberString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_doseNumberString", - title="Extension field for ``doseNumberString``.", - ) - - doseStatus: fhirtypes.CodeableConceptType = Field( - ..., - alias="doseStatus", - title="Status of the dose relative to published recommendations", - description=( - "Indicates if the dose is valid or not valid with respect to the " - "published recommendations." - ), - # if property is element of this resource. - element_property=True, - ) - - doseStatusReason: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="doseStatusReason", - title="Reason for the dose status", - description=( - "Provides an explanation as to why the vaccine administration event is " - "valid or not relative to the published recommendations." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier", - description="A unique identifier assigned to this immunization evaluation record.", - # if property is element of this resource. - element_property=True, - ) - - immunizationEvent: fhirtypes.ReferenceType = Field( - ..., - alias="immunizationEvent", - title="Immunization being evaluated", - description="The vaccine administration event being evaluated.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Immunization"], - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="Who this evaluation is for", - description="The individual for whom the evaluation is being done.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - series: fhirtypes.String = Field( - None, - alias="series", - title="Name of vaccine series", - description=( - "One possible path to achieve presumed immunity against a disease - " - "within the context of an authority." - ), - # if property is element of this resource. - element_property=True, - ) - series__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_series", title="Extension field for ``series``." - ) - - seriesDosesPositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="seriesDosesPositiveInt", - title="Recommended number of doses for immunity", - description="The recommended number of doses to achieve immunity.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e seriesDoses[x] - one_of_many="seriesDoses", - one_of_many_required=False, - ) - seriesDosesPositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_seriesDosesPositiveInt", - title="Extension field for ``seriesDosesPositiveInt``.", - ) - - seriesDosesString: fhirtypes.String = Field( - None, - alias="seriesDosesString", - title="Recommended number of doses for immunity", - description="The recommended number of doses to achieve immunity.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e seriesDoses[x] - one_of_many="seriesDoses", - one_of_many_required=False, - ) - seriesDosesString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_seriesDosesString", - title="Extension field for ``seriesDosesString``.", - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="completed | entered-in-error", - description=( - "Indicates the current status of the evaluation of the vaccination " - "administration event." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["completed", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - targetDisease: fhirtypes.CodeableConceptType = Field( - ..., - alias="targetDisease", - title="Evaluation target disease", - description="The vaccine preventable disease the dose is being evaluated against.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImmunizationEvaluation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "patient", - "date", - "authority", - "targetDisease", - "immunizationEvent", - "doseStatus", - "doseStatusReason", - "description", - "series", - "doseNumberPositiveInt", - "doseNumberString", - "seriesDosesPositiveInt", - "seriesDosesString", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2515( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2515( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "doseNumber": ["doseNumberPositiveInt", "doseNumberString"], - "seriesDoses": ["seriesDosesPositiveInt", "seriesDosesString"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/immunizationrecommendation.py b/fhir/resources/immunizationrecommendation.py deleted file mode 100644 index f3448538..00000000 --- a/fhir/resources/immunizationrecommendation.py +++ /dev/null @@ -1,546 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ImmunizationRecommendation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ImmunizationRecommendation(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Guidance or advice relating to an immunization. - A patient's point-in-time set of recommendations (i.e. forecasting) - according to a published schedule with optional supporting justification. - """ - - resource_type = Field("ImmunizationRecommendation", const=True) - - authority: fhirtypes.ReferenceType = Field( - None, - alias="authority", - title="Who is responsible for protocol", - description="Indicates the authority who published the protocol (e.g. ACIP).", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date recommendation(s) created", - description="The date the immunization recommendation(s) were created.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier", - description="A unique identifier assigned to this particular recommendation record.", - # if property is element of this resource. - element_property=True, - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="Who this profile is for", - description="The patient the recommendation(s) are for.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - recommendation: typing.List[ - fhirtypes.ImmunizationRecommendationRecommendationType - ] = Field( - ..., - alias="recommendation", - title="Vaccine administration recommendations", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImmunizationRecommendation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "patient", - "date", - "authority", - "recommendation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2928( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("date", "date__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ImmunizationRecommendationRecommendation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Vaccine administration recommendations. - """ - - resource_type = Field("ImmunizationRecommendationRecommendation", const=True) - - contraindicatedVaccineCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="contraindicatedVaccineCode", - title="Vaccine which is contraindicated to fulfill the recommendation", - description="Vaccine(s) which should not be used to fulfill the recommendation.", - # if property is element of this resource. - element_property=True, - ) - - dateCriterion: typing.List[ - fhirtypes.ImmunizationRecommendationRecommendationDateCriterionType - ] = Field( - None, - alias="dateCriterion", - title="Dates governing proposed immunization", - description=( - "Vaccine date recommendations. For example, earliest date to " - "administer, latest date to administer, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Protocol details", - description=( - "Contains the description about the protocol under which the vaccine " - "was administered." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - doseNumberPositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="doseNumberPositiveInt", - title="Recommended dose number within series", - description=( - "Nominal position of the recommended dose in a series (e.g. dose 2 is " - "the next recommended dose)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e doseNumber[x] - one_of_many="doseNumber", - one_of_many_required=False, - ) - doseNumberPositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_doseNumberPositiveInt", - title="Extension field for ``doseNumberPositiveInt``.", - ) - - doseNumberString: fhirtypes.String = Field( - None, - alias="doseNumberString", - title="Recommended dose number within series", - description=( - "Nominal position of the recommended dose in a series (e.g. dose 2 is " - "the next recommended dose)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e doseNumber[x] - one_of_many="doseNumber", - one_of_many_required=False, - ) - doseNumberString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_doseNumberString", - title="Extension field for ``doseNumberString``.", - ) - - forecastReason: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="forecastReason", - title="Vaccine administration status reason", - description="The reason for the assigned forecast status.", - # if property is element of this resource. - element_property=True, - ) - - forecastStatus: fhirtypes.CodeableConceptType = Field( - ..., - alias="forecastStatus", - title="Vaccine recommendation status", - description=( - "Indicates the patient status with respect to the path to immunity for " - "the target disease." - ), - # if property is element of this resource. - element_property=True, - ) - - series: fhirtypes.String = Field( - None, - alias="series", - title="Name of vaccination series", - description=( - "One possible path to achieve presumed immunity against a disease - " - "within the context of an authority." - ), - # if property is element of this resource. - element_property=True, - ) - series__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_series", title="Extension field for ``series``." - ) - - seriesDosesPositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="seriesDosesPositiveInt", - title="Recommended number of doses for immunity", - description="The recommended number of doses to achieve immunity.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e seriesDoses[x] - one_of_many="seriesDoses", - one_of_many_required=False, - ) - seriesDosesPositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_seriesDosesPositiveInt", - title="Extension field for ``seriesDosesPositiveInt``.", - ) - - seriesDosesString: fhirtypes.String = Field( - None, - alias="seriesDosesString", - title="Recommended number of doses for immunity", - description="The recommended number of doses to achieve immunity.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e seriesDoses[x] - one_of_many="seriesDoses", - one_of_many_required=False, - ) - seriesDosesString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_seriesDosesString", - title="Extension field for ``seriesDosesString``.", - ) - - supportingImmunization: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingImmunization", - title="Past immunizations supporting recommendation", - description=( - "Immunization event history and/or evaluation that supports the status " - "and recommendation." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Immunization", "ImmunizationEvaluation"], - ) - - supportingPatientInformation: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingPatientInformation", - title="Patient observations supporting recommendation", - description=( - "Patient Information that supports the status and recommendation. This" - " includes patient observations, adverse reactions and " - "allergy/intolerance information." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - targetDisease: fhirtypes.CodeableConceptType = Field( - None, - alias="targetDisease", - title="Disease to be immunized against", - description="The targeted disease for the recommendation.", - # if property is element of this resource. - element_property=True, - ) - - vaccineCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="vaccineCode", - title="Vaccine or vaccine group recommendation applies to", - description="Vaccine(s) or vaccine group that pertain to the recommendation.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImmunizationRecommendationRecommendation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "vaccineCode", - "targetDisease", - "contraindicatedVaccineCode", - "forecastStatus", - "forecastReason", - "dateCriterion", - "description", - "series", - "doseNumberPositiveInt", - "doseNumberString", - "seriesDosesPositiveInt", - "seriesDosesString", - "supportingImmunization", - "supportingPatientInformation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4389( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "doseNumber": ["doseNumberPositiveInt", "doseNumberString"], - "seriesDoses": ["seriesDosesPositiveInt", "seriesDosesString"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ImmunizationRecommendationRecommendationDateCriterion( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Dates governing proposed immunization. - Vaccine date recommendations. For example, earliest date to administer, - latest date to administer, etc. - """ - - resource_type = Field( - "ImmunizationRecommendationRecommendationDateCriterion", const=True - ) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Type of date", - description=( - "Date classification of recommendation. For example, earliest date to " - "give, latest date to give, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.DateTime = Field( - None, - alias="value", - title="Recommended date", - description="The date whose meaning is specified by dateCriterion.code.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImmunizationRecommendationRecommendationDateCriterion`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "value"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_5714( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("value", "value__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/implementationguide.py b/fhir/resources/implementationguide.py deleted file mode 100644 index c92ffad9..00000000 --- a/fhir/resources/implementationguide.py +++ /dev/null @@ -1,1841 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ImplementationGuide -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ImplementationGuide(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A set of rules about how FHIR is used. - A set of rules of how a particular interoperability or standards problem is - solved - typically through the use of FHIR resources. This resource is used - to gather all the parts of an implementation guide into a logical whole and - to publish a computable definition of all the parts. - """ - - resource_type = Field("ImplementationGuide", const=True) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the implementation guide and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the implementation guide." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the implementation guide was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the implementation guide " - "changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - definition: fhirtypes.ImplementationGuideDefinitionType = Field( - None, - alias="definition", - title="Information needed to build the IG", - description=( - "The information needed by an IG publisher tool to publish the whole " - "implementation guide." - ), - # if property is element of this resource. - element_property=True, - ) - - dependsOn: typing.List[fhirtypes.ImplementationGuideDependsOnType] = Field( - None, - alias="dependsOn", - title="Another Implementation guide this depends on", - description=( - "Another implementation guide that this implementation depends on. " - "Typically, an implementation guide uses value sets, profiles " - "etc.defined in other implementation guides." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the implementation guide", - description=( - "A free text natural language description of the implementation guide " - "from a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this implementation guide is authored" - " for testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - fhirVersion: typing.List[fhirtypes.Code] = Field( - None, - alias="fhirVersion", - title="FHIR Version(s) this Implementation Guide targets", - description=( - "The version(s) of the FHIR specification that this ImplementationGuide" - " targets - e.g. describes how to use. The value of this element is the" - " formal version of the specification, without the revision number, " - "e.g. [publication].[major].[minor], which is 4.0.1. for this version." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - fhirVersion__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_fhirVersion", title="Extension field for ``fhirVersion``.") - - global_fhir: typing.List[fhirtypes.ImplementationGuideGlobalType] = Field( - None, - alias="global", - title="Profiles that apply globally", - description=( - "A set of profiles that all resources covered by this implementation " - "guide must conform to." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for implementation guide (if applicable)", - description=( - "A legal or geographic region in which the implementation guide is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - license: fhirtypes.Code = Field( - None, - alias="license", - title="SPDX license code for this IG (or not-open-source)", - description=( - "The license that applies to this Implementation Guide, using an SPDX " - "license code, or 'not-open-source'." - ), - # if property is element of this resource. - element_property=True, - ) - license__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_license", title="Extension field for ``license``." - ) - - manifest: fhirtypes.ImplementationGuideManifestType = Field( - None, - alias="manifest", - title="Information about an assembled IG", - description=( - "Information about an assembled implementation guide, created by the " - "publication tooling." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this implementation guide (computer friendly)", - description=( - "A natural language name identifying the implementation guide. This " - "name should be usable as an identifier for the module by machine " - "processing applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - packageId: fhirtypes.Id = Field( - None, - alias="packageId", - title="NPM Package name for IG", - description=( - "The NPM package name for this Implementation Guide, used in the NPM " - "package distribution, which is the primary mechanism by which FHIR " - "based tooling manages IG dependencies. This value must be globally " - "unique, and should be assigned with care." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - packageId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_packageId", title="Extension field for ``packageId``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the " - "implementation guide." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this implementation guide. Enables tracking the life-" - "cycle of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this implementation guide (human friendly)", - description=( - "A short, descriptive, user-friendly title for the implementation " "guide." - ), - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this implementation guide, represented as a " - "URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this implementation guide " - "when it is referenced in a specification, model, design or an " - "instance; also called its canonical identifier. This SHOULD be " - "globally unique and SHOULD be a literal address at which at which an " - "authoritative instance of this implementation guide is (or will be) " - "published. This URL can be the target of a canonical reference. It " - "SHALL remain the same when the implementation guide is stored on " - "different servers." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate implementation guide instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the implementation guide", - description=( - "The identifier that is used to identify this version of the " - "implementation guide when it is referenced in a specification, model, " - "design or instance. This is an arbitrary value managed by the " - "implementation guide author and is not expected to be globally unique." - " For example, it might be a timestamp (e.g. yyyymmdd) if a managed " - "version is not available. There is also no expectation that versions " - "can be placed in a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuide`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "version", - "name", - "title", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "copyright", - "packageId", - "license", - "fhirVersion", - "dependsOn", - "global", - "definition", - "manifest", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2146( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("fhirVersion", "fhirVersion__ext"), - ("name", "name__ext"), - ("packageId", "packageId__ext"), - ("status", "status__ext"), - ("url", "url__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ImplementationGuideDefinition(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information needed to build the IG. - The information needed by an IG publisher tool to publish the whole - implementation guide. - """ - - resource_type = Field("ImplementationGuideDefinition", const=True) - - grouping: typing.List[fhirtypes.ImplementationGuideDefinitionGroupingType] = Field( - None, - alias="grouping", - title="Grouping used to present related resources in the IG", - description=( - "A logical group of resources. Logical groups can be used when building" - " pages." - ), - # if property is element of this resource. - element_property=True, - ) - - page: fhirtypes.ImplementationGuideDefinitionPageType = Field( - None, - alias="page", - title="Page/Section in the Guide", - description=( - "A page / section in the implementation guide. The root page is the " - "implementation guide home page." - ), - # if property is element of this resource. - element_property=True, - ) - - parameter: typing.List[ - fhirtypes.ImplementationGuideDefinitionParameterType - ] = Field( - None, - alias="parameter", - title="Defines how IG is built by tools", - description=None, - # if property is element of this resource. - element_property=True, - ) - - resource: typing.List[fhirtypes.ImplementationGuideDefinitionResourceType] = Field( - ..., - alias="resource", - title="Resource in the implementation guide", - description=( - "A resource that is part of the implementation guide. Conformance " - "resources (value set, structure definition, capability statements " - "etc.) are obvious candidates for inclusion, but any kind of resource " - "can be included as an example resource." - ), - # if property is element of this resource. - element_property=True, - ) - - template: typing.List[fhirtypes.ImplementationGuideDefinitionTemplateType] = Field( - None, - alias="template", - title="A template for building resources", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuideDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "grouping", - "resource", - "page", - "parameter", - "template", - ] - - -class ImplementationGuideDefinitionGrouping(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Grouping used to present related resources in the IG. - A logical group of resources. Logical groups can be used when building - pages. - """ - - resource_type = Field("ImplementationGuideDefinitionGrouping", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Human readable text describing the package", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Descriptive name for the package", - description=( - "The human-readable title to display for the package of resources when " - "rendering the implementation guide." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuideDefinitionGrouping`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "name", "description"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4024( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ImplementationGuideDefinitionPage(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Page/Section in the Guide. - A page / section in the implementation guide. The root page is the - implementation guide home page. - """ - - resource_type = Field("ImplementationGuideDefinitionPage", const=True) - - generation: fhirtypes.Code = Field( - None, - alias="generation", - title="html | markdown | xml | generated", - description="A code that indicates how the page is generated.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["html", "markdown", "xml", "generated"], - ) - generation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_generation", title="Extension field for ``generation``." - ) - - nameReference: fhirtypes.ReferenceType = Field( - None, - alias="nameReference", - title="Where to find that page", - description="The source address for the page.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e name[x] - one_of_many="name", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Binary"], - ) - - nameUrl: fhirtypes.Url = Field( - None, - alias="nameUrl", - title="Where to find that page", - description="The source address for the page.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e name[x] - one_of_many="name", - one_of_many_required=True, - ) - nameUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_nameUrl", title="Extension field for ``nameUrl``." - ) - - page: typing.List[fhirtypes.ImplementationGuideDefinitionPageType] = Field( - None, - alias="page", - title="Nested Pages / Sections", - description="Nested Pages/Sections under this page.", - # if property is element of this resource. - element_property=True, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Short title shown for navigational assistance", - description=( - "A short title used to represent this page in navigational structures " - "such as table of contents, bread crumbs, etc." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuideDefinitionPage`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "nameUrl", - "nameReference", - "title", - "generation", - "page", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3560( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("generation", "generation__ext"), ("title", "title__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3560( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"name": ["nameReference", "nameUrl"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ImplementationGuideDefinitionParameter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Defines how IG is built by tools. - """ - - resource_type = Field("ImplementationGuideDefinitionParameter", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title=( - "apply | path-resource | path-pages | path-tx-cache | expansion-" - "parameter | rule-broken-links | generate-xml | generate-json | " - "generate-turtle | html-template" - ), - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "apply", - "path-resource", - "path-pages", - "path-tx-cache", - "expansion-parameter", - "rule-broken-links", - "generate-xml", - "generate-json", - "generate-turtle", - "html-template", - ], - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="Value for named type", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuideDefinitionParameter`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "value"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4121( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext"), ("value", "value__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ImplementationGuideDefinitionResource(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Resource in the implementation guide. - A resource that is part of the implementation guide. Conformance resources - (value set, structure definition, capability statements etc.) are obvious - candidates for inclusion, but any kind of resource can be included as an - example resource. - """ - - resource_type = Field("ImplementationGuideDefinitionResource", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Reason why included in guide", - description=( - "A description of the reason that a resource has been included in the " - "implementation guide." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - exampleBoolean: bool = Field( - None, - alias="exampleBoolean", - title="Is an example/What is this an example of?", - description=( - "If true or a reference, indicates the resource is an example instance." - " If a reference is present, indicates that the example is an example " - "of the specified profile." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e example[x] - one_of_many="example", - one_of_many_required=False, - ) - exampleBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_exampleBoolean", title="Extension field for ``exampleBoolean``." - ) - - exampleCanonical: fhirtypes.Canonical = Field( - None, - alias="exampleCanonical", - title="Is an example/What is this an example of?", - description=( - "If true or a reference, indicates the resource is an example instance." - " If a reference is present, indicates that the example is an example " - "of the specified profile." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e example[x] - one_of_many="example", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - exampleCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_exampleCanonical", - title="Extension field for ``exampleCanonical``.", - ) - - fhirVersion: typing.List[fhirtypes.Code] = Field( - None, - alias="fhirVersion", - title="Versions this applies to (if different to IG)", - description=( - "Indicates the FHIR Version(s) this artifact is intended to apply to. " - "If no versions are specified, the resource is assumed to apply to all " - "the versions stated in ImplementationGuide.fhirVersion." - ), - # if property is element of this resource. - element_property=True, - ) - fhirVersion__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_fhirVersion", title="Extension field for ``fhirVersion``.") - - groupingId: fhirtypes.Id = Field( - None, - alias="groupingId", - title="Grouping this is part of", - description="Reference to the id of the grouping this resource appears in.", - # if property is element of this resource. - element_property=True, - ) - groupingId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_groupingId", title="Extension field for ``groupingId``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Human Name for the resource", - description=( - "A human assigned name for the resource. All resources SHOULD have a " - "name, but the name may be extracted from the resource (e.g. " - "ValueSet.name)." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - reference: fhirtypes.ReferenceType = Field( - ..., - alias="reference", - title="Location of the resource", - description="Where this resource is found.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuideDefinitionResource`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "reference", - "fhirVersion", - "name", - "description", - "exampleBoolean", - "exampleCanonical", - "groupingId", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4019( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"example": ["exampleBoolean", "exampleCanonical"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ImplementationGuideDefinitionTemplate(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A template for building resources. - """ - - resource_type = Field("ImplementationGuideDefinitionTemplate", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Type of template specified", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - scope: fhirtypes.String = Field( - None, - alias="scope", - title="The scope in which the template applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - scope__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_scope", title="Extension field for ``scope``." - ) - - source: fhirtypes.String = Field( - None, - alias="source", - title="The source location for the template", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - source__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_source", title="Extension field for ``source``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuideDefinitionTemplate`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "source", "scope"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4007( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext"), ("source", "source__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ImplementationGuideDependsOn(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Another Implementation guide this depends on. - Another implementation guide that this implementation depends on. - Typically, an implementation guide uses value sets, profiles etc.defined in - other implementation guides. - """ - - resource_type = Field("ImplementationGuideDependsOn", const=True) - - packageId: fhirtypes.Id = Field( - None, - alias="packageId", - title="NPM Package name for IG this depends on", - description=( - "The NPM package name for the Implementation Guide that this IG depends" - " on." - ), - # if property is element of this resource. - element_property=True, - ) - packageId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_packageId", title="Extension field for ``packageId``." - ) - - uri: fhirtypes.Canonical = Field( - None, - alias="uri", - title="Identity of the IG that this depends on", - description="A canonical reference to the Implementation guide for the dependency.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ImplementationGuide"], - ) - uri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_uri", title="Extension field for ``uri``." - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Version of the IG", - description=( - "The version of the IG that is depended on, when the correct version is" - " required to understand the IG correctly." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuideDependsOn`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "uri", "packageId", "version"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3051( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("uri", "uri__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ImplementationGuideGlobal(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Profiles that apply globally. - A set of profiles that all resources covered by this implementation guide - must conform to. - """ - - resource_type = Field("ImplementationGuideGlobal", const=True) - - profile: fhirtypes.Canonical = Field( - None, - alias="profile", - title="Profile that all resources must conform to", - description="A reference to the profile that all instances must conform to.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - profile__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_profile", title="Extension field for ``profile``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="Type this profile applies to", - description="The type of resource that all instances must conform to.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuideGlobal`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "profile"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2746( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("profile", "profile__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ImplementationGuideManifest(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about an assembled IG. - Information about an assembled implementation guide, created by the - publication tooling. - """ - - resource_type = Field("ImplementationGuideManifest", const=True) - - image: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="image", - title="Image within the IG", - description="Indicates a relative path to an image that exists within the IG.", - # if property is element of this resource. - element_property=True, - ) - image__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_image", title="Extension field for ``image``.") - - other: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="other", - title="Additional linkable file in IG", - description=( - "Indicates the relative path of an additional non-page, non-image file " - "that is part of the IG - e.g. zip, jar and similar files that could be" - " the target of a hyperlink in a derived IG." - ), - # if property is element of this resource. - element_property=True, - ) - other__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_other", title="Extension field for ``other``.") - - page: typing.List[fhirtypes.ImplementationGuideManifestPageType] = Field( - None, - alias="page", - title="HTML page within the parent IG", - description="Information about a page within the IG.", - # if property is element of this resource. - element_property=True, - ) - - rendering: fhirtypes.Url = Field( - None, - alias="rendering", - title="Location of rendered implementation guide", - description=( - "A pointer to official web page, PDF or other rendering of the " - "implementation guide." - ), - # if property is element of this resource. - element_property=True, - ) - rendering__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_rendering", title="Extension field for ``rendering``." - ) - - resource: typing.List[fhirtypes.ImplementationGuideManifestResourceType] = Field( - ..., - alias="resource", - title="Resource in the implementation guide", - description=( - "A resource that is part of the implementation guide. Conformance " - "resources (value set, structure definition, capability statements " - "etc.) are obvious candidates for inclusion, but any kind of resource " - "can be included as an example resource." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuideManifest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "rendering", - "resource", - "page", - "image", - "other", - ] - - -class ImplementationGuideManifestPage(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - HTML page within the parent IG. - Information about a page within the IG. - """ - - resource_type = Field("ImplementationGuideManifestPage", const=True) - - anchor: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="anchor", - title="Anchor available on the page", - description="The name of an anchor available on the page.", - # if property is element of this resource. - element_property=True, - ) - anchor__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_anchor", title="Extension field for ``anchor``.") - - name: fhirtypes.String = Field( - None, - alias="name", - title="HTML page name", - description="Relative path to the page.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Title of the page, for references", - description="Label for the page intended for human display.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuideManifestPage`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "name", "title", "anchor"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3350( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ImplementationGuideManifestResource(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Resource in the implementation guide. - A resource that is part of the implementation guide. Conformance resources - (value set, structure definition, capability statements etc.) are obvious - candidates for inclusion, but any kind of resource can be included as an - example resource. - """ - - resource_type = Field("ImplementationGuideManifestResource", const=True) - - exampleBoolean: bool = Field( - None, - alias="exampleBoolean", - title="Is an example/What is this an example of?", - description=( - "If true or a reference, indicates the resource is an example instance." - " If a reference is present, indicates that the example is an example " - "of the specified profile." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e example[x] - one_of_many="example", - one_of_many_required=False, - ) - exampleBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_exampleBoolean", title="Extension field for ``exampleBoolean``." - ) - - exampleCanonical: fhirtypes.Canonical = Field( - None, - alias="exampleCanonical", - title="Is an example/What is this an example of?", - description=( - "If true or a reference, indicates the resource is an example instance." - " If a reference is present, indicates that the example is an example " - "of the specified profile." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e example[x] - one_of_many="example", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - exampleCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_exampleCanonical", - title="Extension field for ``exampleCanonical``.", - ) - - reference: fhirtypes.ReferenceType = Field( - ..., - alias="reference", - title="Location of the resource", - description="Where this resource is found.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - relativePath: fhirtypes.Url = Field( - None, - alias="relativePath", - title="Relative path for page in IG", - description="The relative path for primary page for this resource within the IG.", - # if property is element of this resource. - element_property=True, - ) - relativePath__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_relativePath", title="Extension field for ``relativePath``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ImplementationGuideManifestResource`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "reference", - "exampleBoolean", - "exampleCanonical", - "relativePath", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3809( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"example": ["exampleBoolean", "exampleCanonical"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/insuranceplan.py b/fhir/resources/insuranceplan.py deleted file mode 100644 index 42f7b32d..00000000 --- a/fhir/resources/insuranceplan.py +++ /dev/null @@ -1,767 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/InsurancePlan -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class InsurancePlan(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Details of a Health Insurance product/plan provided by an organization. - """ - - resource_type = Field("InsurancePlan", const=True) - - administeredBy: fhirtypes.ReferenceType = Field( - None, - alias="administeredBy", - title="Product administrator", - description=( - "An organization which administer other services such as underwriting, " - "customer service and/or claims processing on behalf of the health " - "insurance product owner." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - alias: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="alias", - title="Alternate names", - description=( - "A list of alternate names that the product is known as, or was known " - "as in the past." - ), - # if property is element of this resource. - element_property=True, - ) - alias__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_alias", title="Extension field for ``alias``.") - - contact: typing.List[fhirtypes.InsurancePlanContactType] = Field( - None, - alias="contact", - title="Contact for the product", - description="The contact for the health insurance product for a certain purpose.", - # if property is element of this resource. - element_property=True, - ) - - coverage: typing.List[fhirtypes.InsurancePlanCoverageType] = Field( - None, - alias="coverage", - title="Coverage details", - description="Details about the coverage offered by the insurance product.", - # if property is element of this resource. - element_property=True, - ) - - coverageArea: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="coverageArea", - title="Where product applies", - description=( - "The geographic region in which a health insurance product's benefits " - "apply." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - endpoint: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="endpoint", - title="Technical endpoint", - description=( - "The technical endpoints providing access to services operated for the " - "health insurance product." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Endpoint"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for Product", - description=( - "Business identifiers assigned to this health insurance product which " - "remain constant as the resource is updated and propagates from server " - "to server." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Official name", - description=( - "Official name of the health insurance product as designated by the " - "owner." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - network: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="network", - title="What networks are Included", - description="Reference to the network included in the health insurance product.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - ownedBy: fhirtypes.ReferenceType = Field( - None, - alias="ownedBy", - title="Plan issuer", - description=( - "The entity that is providing the health insurance product and " - "underwriting the risk. This is typically an insurance carriers, other" - " third-party payers, or health plan sponsors comonly referred to as " - "'payers'." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="When the product is available", - description="The period of time that the health insurance product is available.", - # if property is element of this resource. - element_property=True, - ) - - plan: typing.List[fhirtypes.InsurancePlanPlanType] = Field( - None, - alias="plan", - title="Plan details", - description="Details about an insurance plan.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description="The current state of the health insurance product.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Kind of product", - description="The kind of health insurance product.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InsurancePlan`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "type", - "name", - "alias", - "period", - "ownedBy", - "administeredBy", - "coverageArea", - "contact", - "endpoint", - "network", - "coverage", - "plan", - ] - - -class InsurancePlanContact(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contact for the product. - The contact for the health insurance product for a certain purpose. - """ - - resource_type = Field("InsurancePlanContact", const=True) - - address: fhirtypes.AddressType = Field( - None, - alias="address", - title="Visiting or postal addresses for the contact", - description=None, - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.HumanNameType = Field( - None, - alias="name", - title="A name associated with the contact", - description=None, - # if property is element of this resource. - element_property=True, - ) - - purpose: fhirtypes.CodeableConceptType = Field( - None, - alias="purpose", - title="The type of contact", - description="Indicates a purpose for which the contact can be reached.", - # if property is element of this resource. - element_property=True, - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="Contact details (telephone, email, etc.) for a contact", - description=( - "A contact detail (e.g. a telephone number or an email address) by " - "which the party may be contacted." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InsurancePlanContact`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "purpose", - "name", - "telecom", - "address", - ] - - -class InsurancePlanCoverage(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Coverage details. - Details about the coverage offered by the insurance product. - """ - - resource_type = Field("InsurancePlanCoverage", const=True) - - benefit: typing.List[fhirtypes.InsurancePlanCoverageBenefitType] = Field( - ..., - alias="benefit", - title="List of benefits", - description="Specific benefits under this type of coverage.", - # if property is element of this resource. - element_property=True, - ) - - network: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="network", - title="What networks provide coverage", - description="Reference to the network that providing the type of coverage.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Type of coverage", - description=( - "Type of coverage (Medical; Dental; Mental Health; Substance Abuse; " - "Vision; Drug; Short Term; Long Term Care; Hospice; Home Health)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InsurancePlanCoverage`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "network", "benefit"] - - -class InsurancePlanCoverageBenefit(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - List of benefits. - Specific benefits under this type of coverage. - """ - - resource_type = Field("InsurancePlanCoverageBenefit", const=True) - - limit: typing.List[fhirtypes.InsurancePlanCoverageBenefitLimitType] = Field( - None, - alias="limit", - title="Benefit limits", - description="The specific limits on the benefit.", - # if property is element of this resource. - element_property=True, - ) - - requirement: fhirtypes.String = Field( - None, - alias="requirement", - title="Referral requirements", - description="The referral requirements to have access/coverage for this benefit.", - # if property is element of this resource. - element_property=True, - ) - requirement__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_requirement", title="Extension field for ``requirement``." - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Type of benefit", - description=( - "Type of benefit (primary care; speciality care; inpatient; " "outpatient)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InsurancePlanCoverageBenefit`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "requirement", "limit"] - - -class InsurancePlanCoverageBenefitLimit(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Benefit limits. - The specific limits on the benefit. - """ - - resource_type = Field("InsurancePlanCoverageBenefitLimit", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Benefit limit details", - description="The specific limit on the benefit.", - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.QuantityType = Field( - None, - alias="value", - title="Maximum value allowed", - description=( - "The maximum amount of a service item a plan will pay for a covered " - "benefit. For examples. wellness visits, or eyeglasses." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InsurancePlanCoverageBenefitLimit`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "value", "code"] - - -class InsurancePlanPlan(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Plan details. - Details about an insurance plan. - """ - - resource_type = Field("InsurancePlanPlan", const=True) - - coverageArea: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="coverageArea", - title="Where product applies", - description=( - "The geographic region in which a health insurance plan's benefits " - "apply." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - generalCost: typing.List[fhirtypes.InsurancePlanPlanGeneralCostType] = Field( - None, - alias="generalCost", - title="Overall costs", - description="Overall costs associated with the plan.", - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for Product", - description=( - "Business identifiers assigned to this health insurance plan which " - "remain constant as the resource is updated and propagates from server " - "to server." - ), - # if property is element of this resource. - element_property=True, - ) - - network: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="network", - title="What networks provide coverage", - description="Reference to the network that providing the type of coverage.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - specificCost: typing.List[fhirtypes.InsurancePlanPlanSpecificCostType] = Field( - None, - alias="specificCost", - title="Specific costs", - description="Costs associated with the coverage provided by the product.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of plan", - description='Type of plan. For example, "Platinum" or "High Deductable".', - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InsurancePlanPlan`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "type", - "coverageArea", - "network", - "generalCost", - "specificCost", - ] - - -class InsurancePlanPlanGeneralCost(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Overall costs. - Overall costs associated with the plan. - """ - - resource_type = Field("InsurancePlanPlanGeneralCost", const=True) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Additional cost information", - description=( - "Additional information about the general costs associated with this " - "plan." - ), - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - cost: fhirtypes.MoneyType = Field( - None, - alias="cost", - title="Cost value", - description="Value of the cost.", - # if property is element of this resource. - element_property=True, - ) - - groupSize: fhirtypes.PositiveInt = Field( - None, - alias="groupSize", - title="Number of enrollees", - description="Number of participants enrolled in the plan.", - # if property is element of this resource. - element_property=True, - ) - groupSize__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_groupSize", title="Extension field for ``groupSize``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of cost", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InsurancePlanPlanGeneralCost`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "groupSize", - "cost", - "comment", - ] - - -class InsurancePlanPlanSpecificCost(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Specific costs. - Costs associated with the coverage provided by the product. - """ - - resource_type = Field("InsurancePlanPlanSpecificCost", const=True) - - benefit: typing.List[fhirtypes.InsurancePlanPlanSpecificCostBenefitType] = Field( - None, - alias="benefit", - title="Benefits list", - description="List of the specific benefits under this category of benefit.", - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.CodeableConceptType = Field( - ..., - alias="category", - title="General category of benefit", - description=( - "General category of benefit (Medical; Dental; Vision; Drug; Mental " - "Health; Substance Abuse; Hospice, Home Health)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InsurancePlanPlanSpecificCost`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "category", "benefit"] - - -class InsurancePlanPlanSpecificCostBenefit(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Benefits list. - List of the specific benefits under this category of benefit. - """ - - resource_type = Field("InsurancePlanPlanSpecificCostBenefit", const=True) - - cost: typing.List[fhirtypes.InsurancePlanPlanSpecificCostBenefitCostType] = Field( - None, - alias="cost", - title="List of the costs", - description="List of the costs associated with a specific benefit.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Type of specific benefit", - description=( - "Type of specific benefit (preventative; primary care office visit; " - "speciality office visit; hospitalization; emergency room; urgent " - "care)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InsurancePlanPlanSpecificCostBenefit`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "cost"] - - -class InsurancePlanPlanSpecificCostBenefitCost(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - List of the costs. - List of the costs associated with a specific benefit. - """ - - resource_type = Field("InsurancePlanPlanSpecificCostBenefitCost", const=True) - - applicability: fhirtypes.CodeableConceptType = Field( - None, - alias="applicability", - title="in-network | out-of-network | other", - description=( - "Whether the cost applies to in-network or out-of-network providers " - "(in-network; out-of-network; other)." - ), - # if property is element of this resource. - element_property=True, - ) - - qualifiers: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="qualifiers", - title="Additional information about the cost", - description=( - "Additional information about the cost, such as information about " - "funding sources (e.g. HSA, HRA, FSA, RRA)." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Type of cost", - description=( - "Type of cost (copay; individual cap; family cap; coinsurance; " - "deductible)." - ), - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.QuantityType = Field( - None, - alias="value", - title="The actual cost value", - description=( - "The actual cost value. (some of the costs may be represented as " - "percentages rather than currency, e.g. 10% coinsurance)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InsurancePlanPlanSpecificCostBenefitCost`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "applicability", - "qualifiers", - "value", - ] diff --git a/fhir/resources/invoice.py b/fhir/resources/invoice.py deleted file mode 100644 index a30ef268..00000000 --- a/fhir/resources/invoice.py +++ /dev/null @@ -1,669 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Invoice -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Invoice(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Invoice containing ChargeItems from an Account. - Invoice containing collected ChargeItems from an Account with calculated - individual and total price for Billing purpose. - """ - - resource_type = Field("Invoice", const=True) - - account: fhirtypes.ReferenceType = Field( - None, - alias="account", - title="Account that is being balanced", - description="Account which is supposed to be balanced with this Invoice.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Account"], - ) - - cancelledReason: fhirtypes.String = Field( - None, - alias="cancelledReason", - title="Reason for cancellation of this Invoice", - description=( - "In case of Invoice cancellation a reason must be given (entered in " - "error, superseded by corrected invoice etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - cancelledReason__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_cancelledReason", title="Extension field for ``cancelledReason``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Invoice date / posting date", - description="Date/time(s) of when this Invoice was posted.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for item", - description=( - "Identifier of this Invoice, often used for reference in correspondence" - " about this invoice or for tracking of payments." - ), - # if property is element of this resource. - element_property=True, - ) - - issuer: fhirtypes.ReferenceType = Field( - None, - alias="issuer", - title="Issuing Organization of Invoice", - description="The organizationissuing the Invoice.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - lineItem: typing.List[fhirtypes.InvoiceLineItemType] = Field( - None, - alias="lineItem", - title="Line items of this Invoice", - description=( - "Each line item represents one charge for goods and services rendered. " - "Details such as date, code and amount are found in the referenced " - "ChargeItem resource." - ), - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments made about the invoice", - description=( - "Comments made about the invoice by the issuer, subject, or other " - "participants." - ), - # if property is element of this resource. - element_property=True, - ) - - participant: typing.List[fhirtypes.InvoiceParticipantType] = Field( - None, - alias="participant", - title="Participant in creation of this Invoice", - description=( - "Indicates who or what performed or participated in the charged " "service." - ), - # if property is element of this resource. - element_property=True, - ) - - paymentTerms: fhirtypes.Markdown = Field( - None, - alias="paymentTerms", - title="Payment details", - description=( - "Payment details such as banking details, period of payment, " - "deductibles, methods of payment." - ), - # if property is element of this resource. - element_property=True, - ) - paymentTerms__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_paymentTerms", title="Extension field for ``paymentTerms``." - ) - - recipient: fhirtypes.ReferenceType = Field( - None, - alias="recipient", - title="Recipient of this invoice", - description=( - "The individual or Organization responsible for balancing of this " - "invoice." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization", "Patient", "RelatedPerson"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | issued | balanced | cancelled | entered-in-error", - description="The current state of the Invoice.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "issued", "balanced", "cancelled", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Recipient(s) of goods and services", - description=( - "The individual or set of individuals receiving the goods and services " - "billed in this invoice." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - totalGross: fhirtypes.MoneyType = Field( - None, - alias="totalGross", - title="Gross total of this Invoice", - description="Invoice total, tax included.", - # if property is element of this resource. - element_property=True, - ) - - totalNet: fhirtypes.MoneyType = Field( - None, - alias="totalNet", - title="Net total of this Invoice", - description="Invoice total , taxes excluded.", - # if property is element of this resource. - element_property=True, - ) - - totalPriceComponent: typing.List[ - fhirtypes.InvoiceLineItemPriceComponentType - ] = Field( - None, - alias="totalPriceComponent", - title="Components of Invoice total", - description=( - "The total amount for the Invoice may be calculated as the sum of the " - "line items with surcharges/deductions that apply in certain " - "conditions. The priceComponent element can be used to offer " - "transparency to the recipient of the Invoice of how the total price " - "was calculated." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of Invoice", - description=( - "Type of Invoice depending on domain, realm an usage (e.g. " - "internal/external, dental, preliminary)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Invoice`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "cancelledReason", - "type", - "subject", - "recipient", - "date", - "participant", - "issuer", - "account", - "lineItem", - "totalPriceComponent", - "totalNet", - "totalGross", - "paymentTerms", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_891( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class InvoiceLineItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Line items of this Invoice. - Each line item represents one charge for goods and services rendered. - Details such as date, code and amount are found in the referenced - ChargeItem resource. - """ - - resource_type = Field("InvoiceLineItem", const=True) - - chargeItemCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="chargeItemCodeableConcept", - title=( - "Reference to ChargeItem containing details of this line item or an " - "inline billing code" - ), - description=( - "The ChargeItem contains information such as the billing code, date, " - "amount etc. If no further details are required for the lineItem, " - "inline billing codes can be added using the CodeableConcept data type " - "instead of the Reference." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e chargeItem[x] - one_of_many="chargeItem", - one_of_many_required=True, - ) - - chargeItemReference: fhirtypes.ReferenceType = Field( - None, - alias="chargeItemReference", - title=( - "Reference to ChargeItem containing details of this line item or an " - "inline billing code" - ), - description=( - "The ChargeItem contains information such as the billing code, date, " - "amount etc. If no further details are required for the lineItem, " - "inline billing codes can be added using the CodeableConcept data type " - "instead of the Reference." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e chargeItem[x] - one_of_many="chargeItem", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ChargeItem"], - ) - - priceComponent: typing.List[fhirtypes.InvoiceLineItemPriceComponentType] = Field( - None, - alias="priceComponent", - title="Components of total line item price", - description=( - "The price for a ChargeItem may be calculated as a base price with " - "surcharges/deductions that apply in certain conditions. A " - "ChargeItemDefinition resource that defines the prices, factors and " - "conditions that apply to a billing code is currently under " - "development. The priceComponent element can be used to offer " - "transparency to the recipient of the Invoice as to how the prices have" - " been calculated." - ), - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.PositiveInt = Field( - None, - alias="sequence", - title="Sequence number of line item", - description="Sequence in which the items appear on the invoice.", - # if property is element of this resource. - element_property=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InvoiceLineItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "sequence", - "chargeItemReference", - "chargeItemCodeableConcept", - "priceComponent", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1690( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "chargeItem": ["chargeItemCodeableConcept", "chargeItemReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class InvoiceLineItemPriceComponent(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Components of total line item price. - The price for a ChargeItem may be calculated as a base price with - surcharges/deductions that apply in certain conditions. A - ChargeItemDefinition resource that defines the prices, factors and - conditions that apply to a billing code is currently under development. The - priceComponent element can be used to offer transparency to the recipient - of the Invoice as to how the prices have been calculated. - """ - - resource_type = Field("InvoiceLineItemPriceComponent", const=True) - - amount: fhirtypes.MoneyType = Field( - None, - alias="amount", - title="Monetary amount associated with this component", - description="The amount calculated for this component.", - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Code identifying the specific component", - description=( - "A code that identifies the component. Codes may be used to " - "differentiate between kinds of taxes, surcharges, discounts etc." - ), - # if property is element of this resource. - element_property=True, - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Factor used for calculating this component", - description=( - "The factor that has been applied on the base price for calculating " - "this component." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="base | surcharge | deduction | discount | tax | informational", - description="This code identifies the type of the component.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "base", - "surcharge", - "deduction", - "discount", - "tax", - "informational", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InvoiceLineItemPriceComponent`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "code", - "factor", - "amount", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3143( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class InvoiceParticipant(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Participant in creation of this Invoice. - Indicates who or what performed or participated in the charged service. - """ - - resource_type = Field("InvoiceParticipant", const=True) - - actor: fhirtypes.ReferenceType = Field( - ..., - alias="actor", - title="Individual who was involved", - description=( - "The device, practitioner, etc. who performed or participated in the " - "service." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "Organization", - "Patient", - "PractitionerRole", - "Device", - "RelatedPerson", - ], - ) - - role: fhirtypes.CodeableConceptType = Field( - None, - alias="role", - title="Type of involvement in creation of this Invoice", - description=( - "Describes the type of involvement (e.g. transcriptionist, creator " - "etc.). If the invoice has been created automatically, the Participant " - "may be a billing engine or another kind of device." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``InvoiceParticipant`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "role", "actor"] diff --git a/fhir/resources/library.py b/fhir/resources/library.py deleted file mode 100644 index 5cfef06f..00000000 --- a/fhir/resources/library.py +++ /dev/null @@ -1,643 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Library -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class Library(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Represents a library of quality improvement components. - The Library resource is a general-purpose container for knowledge asset - definitions. It can be used to describe and expose existing knowledge - assets such as logic libraries and information model descriptions, as well - as to describe a collection of knowledge assets. - """ - - resource_type = Field("Library", const=True) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the library was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - author: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="author", - title="Who authored the content", - description=( - "An individiual or organization primarily involved in the creation and " - "maintenance of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - content: typing.List[fhirtypes.AttachmentType] = Field( - None, - alias="content", - title="Contents of the library, either embedded or referenced", - description=( - "The content of the library as an Attachment. The content may be a " - "reference to a url, or may be directly embedded as a base-64 string. " - "Either way, the contentType of the attachment determines how to " - "interpret the content." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the library and/or its contents. " - "Copyright statements are generally legal restrictions on the use and " - "publishing of the library." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - dataRequirement: typing.List[fhirtypes.DataRequirementType] = Field( - None, - alias="dataRequirement", - title="What data is referenced by this library", - description=( - "Describes a set of data that must be provided in order to be able to " - "successfully perform the computations defined by the library." - ), - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the library was published. The " - "date must change when the business version changes and it must change " - "if the status code changes. In addition, it should change when the " - "substantive content of the library changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the library", - description=( - "A free text natural language description of the library from a " - "consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - editor: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="editor", - title="Who edited the content", - description=( - "An individual or organization primarily responsible for internal " - "coherence of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the library is expected to be used", - description=( - "The period during which the library content was or is planned to be in" - " active use." - ), - # if property is element of this resource. - element_property=True, - ) - - endorser: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="endorser", - title="Who endorsed the content", - description=( - "An individual or organization responsible for officially endorsing the" - " content for use in some setting." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this library is authored for testing " - "purposes (or education/evaluation/marketing) and is not intended to be" - " used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the library", - description=( - "A formal identifier that is used to identify this library when it is " - "represented in other formats, or referenced in a specification, model," - " design or an instance. e.g. CMS or NQF identifiers for a measure " - "artifact. Note that at least one identifier is required for non-" - "experimental active artifacts." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for library (if applicable)", - description=( - "A legal or geographic region in which the library is intended to be " - "used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the library was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this library (computer friendly)", - description=( - "A natural language name identifying the library. This name should be " - "usable as an identifier for the module by machine processing " - "applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - parameter: typing.List[fhirtypes.ParameterDefinitionType] = Field( - None, - alias="parameter", - title="Parameters defined by the library", - description="The parameter element defines parameters used by the library.", - # if property is element of this resource. - element_property=True, - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description="The name of the organization or individual that published the library.", - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this library is defined", - description=( - "Explanation of why this library is needed and why it has been designed" - " as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="Additional documentation, citations, etc.", - description=( - "Related artifacts such as additional documentation, justification, or " - "bibliographic references." - ), - # if property is element of this resource. - element_property=True, - ) - - reviewer: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="reviewer", - title="Who reviewed the content", - description=( - "An individual or organization primarily responsible for review of some" - " aspect of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this library. Enables tracking the life-cycle of the " - "content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subjectCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="subjectCodeableConcept", - title="Type of individual the library content is focused on", - description=( - "A code or group definition that describes the intended subject of the " - "contents of the library." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - ) - - subjectReference: fhirtypes.ReferenceType = Field( - None, - alias="subjectReference", - title="Type of individual the library content is focused on", - description=( - "A code or group definition that describes the intended subject of the " - "contents of the library." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Group"], - ) - - subtitle: fhirtypes.String = Field( - None, - alias="subtitle", - title="Subordinate title of the library", - description=( - "An explanatory or alternate title for the library giving additional " - "information about its content." - ), - # if property is element of this resource. - element_property=True, - ) - subtitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subtitle", title="Extension field for ``subtitle``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this library (human friendly)", - description="A short, descriptive, user-friendly title for the library.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="topic", - title="E.g. Education, Treatment, Assessment, etc.", - description=( - "Descriptive topics related to the content of the library. Topics " - "provide a high-level categorization of the library that can be useful " - "for filtering and searching." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title=( - "logic-library | model-definition | asset-collection | module-" "definition" - ), - description=( - "Identifies the type of library such as a Logic Library, Model " - "Definition, Asset Collection, or Module Definition." - ), - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this library, represented as a URI (globally " - "unique)" - ), - description=( - "An absolute URI that is used to identify this library when it is " - "referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this library is (or will be) published. This URL can be " - "the target of a canonical reference. It SHALL remain the same when the" - " library is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - usage: fhirtypes.String = Field( - None, - alias="usage", - title="Describes the clinical usage of the library", - description=( - "A detailed description of how the library is used from a clinical " - "perspective." - ), - # if property is element of this resource. - element_property=True, - ) - usage__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_usage", title="Extension field for ``usage``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate library instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the library", - description=( - "The identifier that is used to identify this version of the library " - "when it is referenced in a specification, model, design or instance. " - "This is an arbitrary value managed by the library author and is not " - "expected to be globally unique. For example, it might be a timestamp " - "(e.g. yyyymmdd) if a managed version is not available. There is also " - "no expectation that versions can be placed in a lexicographical " - "sequence. To provide a version consistent with the Decision Support " - "Service specification, use the format Major.Minor.Revision (e.g. " - "1.0.0). For more information on versioning knowledge assets, refer to " - "the Decision Support Service specification. Note that a version is " - "required for non-experimental active artifacts." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Library`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "subtitle", - "status", - "experimental", - "type", - "subjectCodeableConcept", - "subjectReference", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "usage", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "topic", - "author", - "editor", - "reviewer", - "endorser", - "relatedArtifact", - "parameter", - "dataRequirement", - "content", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_922( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_922( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"subject": ["subjectCodeableConcept", "subjectReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/linkage.py b/fhir/resources/linkage.py deleted file mode 100644 index 3a0adbda..00000000 --- a/fhir/resources/linkage.py +++ /dev/null @@ -1,202 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Linkage -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Linkage(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Links records for 'same' item. - Identifies two or more records (resource instances) that refer to the same - real-world "occurrence". - """ - - resource_type = Field("Linkage", const=True) - - active: bool = Field( - None, - alias="active", - title="Whether this linkage assertion is active or not", - description=( - "Indicates whether the asserted set of linkages are considered to be " - '"in effect".' - ), - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - author: fhirtypes.ReferenceType = Field( - None, - alias="author", - title="Who is responsible for linkages", - description=( - "Identifies the user or organization responsible for asserting the " - "linkages as well as the user or organization who establishes the " - "context in which the nature of each linkage is evaluated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - item: typing.List[fhirtypes.LinkageItemType] = Field( - ..., - alias="item", - title="Item to be linked", - description=( - "Identifies which record considered as the reference to the same real-" - "world occurrence as well as how the items should be evaluated within " - "the collection of linked items." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Linkage`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "active", - "author", - "item", - ] - - -class LinkageItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Item to be linked. - Identifies which record considered as the reference to the same real-world - occurrence as well as how the items should be evaluated within the - collection of linked items. - """ - - resource_type = Field("LinkageItem", const=True) - - resource: fhirtypes.ReferenceType = Field( - ..., - alias="resource", - title="Resource being linked", - description="The resource instance being linked as part of the group.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="source | alternate | historical", - description=( - 'Distinguishes which item is "source of truth" (if any) and which items' - " are no longer considered to be current representations." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["source", "alternate", "historical"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``LinkageItem`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "resource"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1283( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/list.py b/fhir/resources/list.py deleted file mode 100644 index 88528542..00000000 --- a/fhir/resources/list.py +++ /dev/null @@ -1,349 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/List -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class List(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A list is a curated collection of resources. - """ - - resource_type = Field("List", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="What the purpose of this list is", - description="This code defines the purpose of the list - why it was created.", - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="When the list was prepared", - description="The date that the list was prepared.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - emptyReason: fhirtypes.CodeableConceptType = Field( - None, - alias="emptyReason", - title="Why list is empty", - description="If the list is empty, why the list is empty.", - # if property is element of this resource. - element_property=True, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Context in which list created", - description="The encounter that is the context in which this list was created.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - entry: typing.List[fhirtypes.ListEntryType] = Field( - None, - alias="entry", - title="Entries in the list", - description="Entries in this list.", - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier", - description=( - "Identifier for the List assigned for business purposes outside the " - "context of FHIR." - ), - # if property is element of this resource. - element_property=True, - ) - - mode: fhirtypes.Code = Field( - None, - alias="mode", - title="working | snapshot | changes", - description=( - "How this list was prepared - whether it is a working list that is " - "suitable for being maintained on an ongoing basis, or if it represents" - " a snapshot of a list of items from another source, or whether it is a" - " prepared list where items may be marked as added, modified or " - "deleted." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["working", "snapshot", "changes"], - ) - mode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mode", title="Extension field for ``mode``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments about the list", - description="Comments that apply to the overall list.", - # if property is element of this resource. - element_property=True, - ) - - orderedBy: fhirtypes.CodeableConceptType = Field( - None, - alias="orderedBy", - title="What order the list has", - description="What order applies to the items in the list.", - # if property is element of this resource. - element_property=True, - ) - - source: fhirtypes.ReferenceType = Field( - None, - alias="source", - title="Who and/or what defined the list contents (aka Author)", - description=( - "The entity responsible for deciding what the contents of the list " - "were. Where the list was created by a human, this is the same as the " - "author of the list." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Patient", "Device"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="current | retired | entered-in-error", - description="Indicates the current state of this list.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["current", "retired", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="If all resources have the same subject", - description=( - "The common subject (or patient) of the resources that are in the list " - "if there is one." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group", "Device", "Location"], - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Descriptive name for the list", - description="A label for the list assigned by the author.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``List`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "mode", - "title", - "code", - "subject", - "encounter", - "date", - "source", - "orderedBy", - "note", - "entry", - "emptyReason", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_604( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("mode", "mode__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ListEntry(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Entries in the list. - Entries in this list. - """ - - resource_type = Field("ListEntry", const=True) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="When item added to list", - description="When this item was added to the list.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - deleted: bool = Field( - None, - alias="deleted", - title="If this item is actually marked as deleted", - description="True if this item is marked as deleted in the list.", - # if property is element of this resource. - element_property=True, - ) - deleted__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_deleted", title="Extension field for ``deleted``." - ) - - flag: fhirtypes.CodeableConceptType = Field( - None, - alias="flag", - title="Status/Workflow information about this item", - description=( - "The flag allows the system constructing the list to indicate the role " - "and significance of the item in the list." - ), - # if property is element of this resource. - element_property=True, - ) - - item: fhirtypes.ReferenceType = Field( - ..., - alias="item", - title="Actual entry", - description="A reference to the actual resource from which data was derived.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ListEntry`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "flag", - "deleted", - "date", - "item", - ] diff --git a/fhir/resources/location.py b/fhir/resources/location.py deleted file mode 100644 index ca4cf7f8..00000000 --- a/fhir/resources/location.py +++ /dev/null @@ -1,505 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Location -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Location(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Details and position information for a physical place. - Details and position information for a physical place where services are - provided and resources and participants may be stored, found, contained, or - accommodated. - """ - - resource_type = Field("Location", const=True) - - address: fhirtypes.AddressType = Field( - None, - alias="address", - title="Physical location", - description=None, - # if property is element of this resource. - element_property=True, - ) - - alias: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="alias", - title=( - "A list of alternate names that the location is known as, or was known " - "as, in the past" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - alias__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_alias", title="Extension field for ``alias``.") - - availabilityExceptions: fhirtypes.String = Field( - None, - alias="availabilityExceptions", - title="Description of availability exceptions", - description=( - "A description of when the locations opening ours are different to " - "normal, e.g. public holiday availability. Succinctly describing all " - "possible exceptions to normal site availability as detailed in the " - "opening hours Times." - ), - # if property is element of this resource. - element_property=True, - ) - availabilityExceptions__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_availabilityExceptions", - title="Extension field for ``availabilityExceptions``.", - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title=( - "Additional details about the location that could be displayed as " - "further information to identify the location beyond its name" - ), - description=( - "Description of the Location, which helps in finding or referencing the" - " place." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - endpoint: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="endpoint", - title=( - "Technical endpoints providing access to services operated for the " - "location" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Endpoint"], - ) - - hoursOfOperation: typing.List[fhirtypes.LocationHoursOfOperationType] = Field( - None, - alias="hoursOfOperation", - title="What days/times during a week is this location usually open", - description=None, - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Unique code or number identifying the location to its users", - description=None, - # if property is element of this resource. - element_property=True, - ) - - managingOrganization: fhirtypes.ReferenceType = Field( - None, - alias="managingOrganization", - title="Organization responsible for provisioning and upkeep", - description=( - "The organization responsible for the provisioning and upkeep of the " - "location." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - mode: fhirtypes.Code = Field( - None, - alias="mode", - title="instance | kind", - description=( - "Indicates whether a resource instance represents a specific location " - "or a class of locations." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["instance", "kind"], - ) - mode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mode", title="Extension field for ``mode``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name of the location as used by humans", - description="Name of the location as used by humans. Does not need to be unique.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - operationalStatus: fhirtypes.CodingType = Field( - None, - alias="operationalStatus", - title="The operational status of the location (typically only for a bed/room)", - description=( - "The operational status covers operation values most relevant to beds " - "(but can also apply to rooms/units/chairs/etc. such as an isolation " - "unit/dialysis chair). This typically covers concepts such as " - "contamination, housekeeping, and other activities like maintenance." - ), - # if property is element of this resource. - element_property=True, - ) - - partOf: fhirtypes.ReferenceType = Field( - None, - alias="partOf", - title="Another Location this one is physically a part of", - description="Another Location of which this Location is physically a part of.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - physicalType: fhirtypes.CodeableConceptType = Field( - None, - alias="physicalType", - title="Physical form of the location", - description="Physical form of the location, e.g. building, room, vehicle, road.", - # if property is element of this resource. - element_property=True, - ) - - position: fhirtypes.LocationPositionType = Field( - None, - alias="position", - title="The absolute geographic location", - description=( - "The absolute geographic location of the Location, expressed using the " - "WGS84 datum (This is the same co-ordinate system used in KML)." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | suspended | inactive", - description=( - "The status property covers the general availability of the resource, " - "not the current value which may be covered by the operationStatus, or " - "by a schedule/slots if they are configured for the location." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "suspended", "inactive"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="Contact details of the location", - description=( - "The contact details of communication devices available at the " - "location. This can include phone numbers, fax numbers, mobile numbers," - " email addresses and web sites." - ), - # if property is element of this resource. - element_property=True, - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Type of function performed", - description="Indicates the type of function performed at the location.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Location`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "operationalStatus", - "name", - "alias", - "description", - "mode", - "type", - "telecom", - "address", - "physicalType", - "position", - "managingOrganization", - "partOf", - "hoursOfOperation", - "availabilityExceptions", - "endpoint", - ] - - -class LocationHoursOfOperation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What days/times during a week is this location usually open. - """ - - resource_type = Field("LocationHoursOfOperation", const=True) - - allDay: bool = Field( - None, - alias="allDay", - title="The Location is open all day", - description=None, - # if property is element of this resource. - element_property=True, - ) - allDay__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_allDay", title="Extension field for ``allDay``." - ) - - closingTime: fhirtypes.Time = Field( - None, - alias="closingTime", - title="Time that the Location closes", - description=None, - # if property is element of this resource. - element_property=True, - ) - closingTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_closingTime", title="Extension field for ``closingTime``." - ) - - daysOfWeek: typing.List[fhirtypes.Code] = Field( - None, - alias="daysOfWeek", - title="mon | tue | wed | thu | fri | sat | sun", - description=( - "Indicates which days of the week are available between the start and " - "end Times." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["mon", "tue", "wed", "thu", "fri", "sat", "sun"], - ) - daysOfWeek__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_daysOfWeek", title="Extension field for ``daysOfWeek``.") - - openingTime: fhirtypes.Time = Field( - None, - alias="openingTime", - title="Time that the Location opens", - description=None, - # if property is element of this resource. - element_property=True, - ) - openingTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_openingTime", title="Extension field for ``openingTime``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``LocationHoursOfOperation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "daysOfWeek", - "allDay", - "openingTime", - "closingTime", - ] - - -class LocationPosition(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The absolute geographic location. - The absolute geographic location of the Location, expressed using the WGS84 - datum (This is the same co-ordinate system used in KML). - """ - - resource_type = Field("LocationPosition", const=True) - - altitude: fhirtypes.Decimal = Field( - None, - alias="altitude", - title="Altitude with WGS84 datum", - description=( - "Altitude. The value domain and the interpretation are the same as for " - "the text of the altitude element in KML (see notes below)." - ), - # if property is element of this resource. - element_property=True, - ) - altitude__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_altitude", title="Extension field for ``altitude``." - ) - - latitude: fhirtypes.Decimal = Field( - None, - alias="latitude", - title="Latitude with WGS84 datum", - description=( - "Latitude. The value domain and the interpretation are the same as for " - "the text of the latitude element in KML (see notes below)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - latitude__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_latitude", title="Extension field for ``latitude``." - ) - - longitude: fhirtypes.Decimal = Field( - None, - alias="longitude", - title="Longitude with WGS84 datum", - description=( - "Longitude. The value domain and the interpretation are the same as for" - " the text of the longitude element in KML (see notes below)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - longitude__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_longitude", title="Extension field for ``longitude``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``LocationPosition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "longitude", - "latitude", - "altitude", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1864( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("latitude", "latitude__ext"), - ("longitude", "longitude__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/marketingstatus.py b/fhir/resources/marketingstatus.py deleted file mode 100644 index 28a637c1..00000000 --- a/fhir/resources/marketingstatus.py +++ /dev/null @@ -1,119 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MarketingStatus -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import backboneelement, fhirtypes - - -class MarketingStatus(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The marketing status describes the date when a medicinal product is - actually put on the market or the date as of which it is no longer - available. - """ - - resource_type = Field("MarketingStatus", const=True) - - country: fhirtypes.CodeableConceptType = Field( - ..., - alias="country", - title=( - "The country in which the marketing authorisation has been granted " - "shall be specified It should be specified using the ISO 3166 \u2011 1 " - "alpha-2 code elements" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - dateRange: fhirtypes.PeriodType = Field( - ..., - alias="dateRange", - title=( - "The date when the Medicinal Product is placed on the market by the " - "Marketing Authorisation Holder (or where applicable, the " - "manufacturer/distributor) in a country and/or jurisdiction shall be " - "provided A complete date consisting of day, month and year shall be " - "specified using the ISO 8601 date format NOTE \u201cPlaced on the market\u201d " - "refers to the release of the Medicinal Product into the distribution " - "chain" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: fhirtypes.CodeableConceptType = Field( - None, - alias="jurisdiction", - title=( - "Where a Medicines Regulatory Agency has granted a marketing " - "authorisation for which specific provisions within a jurisdiction " - "apply, the jurisdiction can be specified using an appropriate " - "controlled terminology The controlled term and the controlled term " - "identifier shall be specified" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - restoreDate: fhirtypes.DateTime = Field( - None, - alias="restoreDate", - title=( - "The date when the Medicinal Product is placed on the market by the " - "Marketing Authorisation Holder (or where applicable, the " - "manufacturer/distributor) in a country and/or jurisdiction shall be " - "provided A complete date consisting of day, month and year shall be " - "specified using the ISO 8601 date format NOTE \u201cPlaced on the market\u201d " - "refers to the release of the Medicinal Product into the distribution " - "chain" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - restoreDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_restoreDate", title="Extension field for ``restoreDate``." - ) - - status: fhirtypes.CodeableConceptType = Field( - ..., - alias="status", - title=( - "This attribute provides information on the status of the marketing of " - "the medicinal product See ISO/TS 20443 for more information and " - "examples" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MarketingStatus`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "country", - "jurisdiction", - "status", - "dateRange", - "restoreDate", - ] diff --git a/fhir/resources/measure.py b/fhir/resources/measure.py deleted file mode 100644 index 10fb07ee..00000000 --- a/fhir/resources/measure.py +++ /dev/null @@ -1,1185 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Measure -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Measure(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A quality measure definition. - The Measure resource provides the definition of a quality measure. - """ - - resource_type = Field("Measure", const=True) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the measure was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - author: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="author", - title="Who authored the content", - description=( - "An individiual or organization primarily involved in the creation and " - "maintenance of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - clinicalRecommendationStatement: fhirtypes.Markdown = Field( - None, - alias="clinicalRecommendationStatement", - title="Summary of clinical guidelines", - description=( - "Provides a summary of relevant clinical guidelines or other clinical " - "recommendations supporting the measure." - ), - # if property is element of this resource. - element_property=True, - ) - clinicalRecommendationStatement__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_clinicalRecommendationStatement", - title="Extension field for ``clinicalRecommendationStatement``.", - ) - - compositeScoring: fhirtypes.CodeableConceptType = Field( - None, - alias="compositeScoring", - title="opportunity | all-or-nothing | linear | weighted", - description=( - "If this is a composite measure, the scoring method used to combine the" - " component measures to determine the composite score." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the measure and/or its contents. " - "Copyright statements are generally legal restrictions on the use and " - "publishing of the measure." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the measure was published. The " - "date must change when the business version changes and it must change " - "if the status code changes. In addition, it should change when the " - "substantive content of the measure changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - definition: typing.List[fhirtypes.Markdown] = Field( - None, - alias="definition", - title="Defined terms used in the measure documentation", - description="Provides a description of an individual term used within the measure.", - # if property is element of this resource. - element_property=True, - ) - definition__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_definition", title="Extension field for ``definition``.") - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the measure", - description=( - "A free text natural language description of the measure from a " - "consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - disclaimer: fhirtypes.Markdown = Field( - None, - alias="disclaimer", - title="Disclaimer for use of the measure or its referenced content", - description=( - "Notices and disclaimers regarding the use of the measure or related to" - " intellectual property (such as code systems) referenced by the " - "measure." - ), - # if property is element of this resource. - element_property=True, - ) - disclaimer__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_disclaimer", title="Extension field for ``disclaimer``." - ) - - editor: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="editor", - title="Who edited the content", - description=( - "An individual or organization primarily responsible for internal " - "coherence of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the measure is expected to be used", - description=( - "The period during which the measure content was or is planned to be in" - " active use." - ), - # if property is element of this resource. - element_property=True, - ) - - endorser: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="endorser", - title="Who endorsed the content", - description=( - "An individual or organization responsible for officially endorsing the" - " content for use in some setting." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this measure is authored for testing " - "purposes (or education/evaluation/marketing) and is not intended to be" - " used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - group: typing.List[fhirtypes.MeasureGroupType] = Field( - None, - alias="group", - title="Population criteria group", - description="A group of population criteria for the measure.", - # if property is element of this resource. - element_property=True, - ) - - guidance: fhirtypes.Markdown = Field( - None, - alias="guidance", - title="Additional guidance for implementers", - description=( - "Additional guidance for the measure including how it can be used in a " - "clinical context, and the intent of the measure." - ), - # if property is element of this resource. - element_property=True, - ) - guidance__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_guidance", title="Extension field for ``guidance``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the measure", - description=( - "A formal identifier that is used to identify this measure when it is " - "represented in other formats, or referenced in a specification, model," - " design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - improvementNotation: fhirtypes.CodeableConceptType = Field( - None, - alias="improvementNotation", - title="increase | decrease", - description=( - "Information on whether an increase or decrease in score is the " - "preferred result (e.g., a higher score indicates better quality OR a " - "lower score indicates better quality OR quality is within a range)." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for measure (if applicable)", - description=( - "A legal or geographic region in which the measure is intended to be " - "used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the measure was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - library: typing.List[fhirtypes.Canonical] = Field( - None, - alias="library", - title="Logic used by the measure", - description=( - "A reference to a Library resource containing the formal logic used by " - "the measure." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Library"], - ) - library__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_library", title="Extension field for ``library``.") - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this measure (computer friendly)", - description=( - "A natural language name identifying the measure. This name should be " - "usable as an identifier for the module by machine processing " - "applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description="The name of the organization or individual that published the measure.", - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this measure is defined", - description=( - "Explanation of why this measure is needed and why it has been designed" - " as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - rateAggregation: fhirtypes.String = Field( - None, - alias="rateAggregation", - title="How is rate aggregation performed for this measure", - description=( - "Describes how to combine the information calculated, based on logic in" - " each of several populations, into one summarized result." - ), - # if property is element of this resource. - element_property=True, - ) - rateAggregation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_rateAggregation", title="Extension field for ``rateAggregation``." - ) - - rationale: fhirtypes.Markdown = Field( - None, - alias="rationale", - title="Detailed description of why the measure exists", - description=( - "Provides a succinct statement of the need for the measure. Usually " - "includes statements pertaining to importance criterion: impact, gap in" - " care, and evidence." - ), - # if property is element of this resource. - element_property=True, - ) - rationale__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_rationale", title="Extension field for ``rationale``." - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="Additional documentation, citations, etc.", - description=( - "Related artifacts such as additional documentation, justification, or " - "bibliographic references." - ), - # if property is element of this resource. - element_property=True, - ) - - reviewer: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="reviewer", - title="Who reviewed the content", - description=( - "An individual or organization primarily responsible for review of some" - " aspect of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - riskAdjustment: fhirtypes.String = Field( - None, - alias="riskAdjustment", - title="How risk adjustment is applied for this measure", - description=( - "A description of the risk adjustment factors that may impact the " - "resulting score for the measure and how they may be accounted for when" - " computing and reporting measure results." - ), - # if property is element of this resource. - element_property=True, - ) - riskAdjustment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_riskAdjustment", title="Extension field for ``riskAdjustment``." - ) - - scoring: fhirtypes.CodeableConceptType = Field( - None, - alias="scoring", - title="proportion | ratio | continuous-variable | cohort", - description=( - "Indicates how the calculation is performed for the measure, including " - "proportion, ratio, continuous-variable, and cohort. The value set is " - "extensible, allowing additional measure scoring types to be " - "represented." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this measure. Enables tracking the life-cycle of the " - "content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subjectCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="subjectCodeableConcept", - title=( - "E.g. Patient, Practitioner, RelatedPerson, Organization, Location, " - "Device" - ), - description=( - "The intended subjects for the measure. If this element is not " - "provided, a Patient subject is assumed, but the subject of the measure" - " can be anything." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - ) - - subjectReference: fhirtypes.ReferenceType = Field( - None, - alias="subjectReference", - title=( - "E.g. Patient, Practitioner, RelatedPerson, Organization, Location, " - "Device" - ), - description=( - "The intended subjects for the measure. If this element is not " - "provided, a Patient subject is assumed, but the subject of the measure" - " can be anything." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Group"], - ) - - subtitle: fhirtypes.String = Field( - None, - alias="subtitle", - title="Subordinate title of the measure", - description=( - "An explanatory or alternate title for the measure giving additional " - "information about its content." - ), - # if property is element of this resource. - element_property=True, - ) - subtitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subtitle", title="Extension field for ``subtitle``." - ) - - supplementalData: typing.List[fhirtypes.MeasureSupplementalDataType] = Field( - None, - alias="supplementalData", - title="What other data should be reported with the measure", - description=( - "The supplemental data criteria for the measure report, specified as " - "either the name of a valid CQL expression within a referenced library," - " or a valid FHIR Resource Path." - ), - # if property is element of this resource. - element_property=True, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this measure (human friendly)", - description="A short, descriptive, user-friendly title for the measure.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="topic", - title=( - "The category of the measure, such as Education, Treatment, Assessment," - " etc." - ), - description=( - "Descriptive topics related to the content of the measure. Topics " - "provide a high-level categorization grouping types of measures that " - "can be useful for filtering and searching." - ), - # if property is element of this resource. - element_property=True, - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="process | outcome | structure | patient-reported-outcome | composite", - description=( - "Indicates whether the measure is used to examine a process, an outcome" - " over time, a patient-reported outcome, or a structure measure such as" - " utilization." - ), - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this measure, represented as a URI (globally " - "unique)" - ), - description=( - "An absolute URI that is used to identify this measure when it is " - "referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this measure is (or will be) published. This URL can be " - "the target of a canonical reference. It SHALL remain the same when the" - " measure is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - usage: fhirtypes.String = Field( - None, - alias="usage", - title="Describes the clinical usage of the measure", - description=( - "A detailed description, from a clinical perspective, of how the " - "measure is used." - ), - # if property is element of this resource. - element_property=True, - ) - usage__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_usage", title="Extension field for ``usage``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate measure instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the measure", - description=( - "The identifier that is used to identify this version of the measure " - "when it is referenced in a specification, model, design or instance. " - "This is an arbitrary value managed by the measure author and is not " - "expected to be globally unique. For example, it might be a timestamp " - "(e.g. yyyymmdd) if a managed version is not available. There is also " - "no expectation that versions can be placed in a lexicographical " - "sequence. To provide a version consistent with the Decision Support " - "Service specification, use the format Major.Minor.Revision (e.g. " - "1.0.0). For more information on versioning knowledge assets, refer to " - "the Decision Support Service specification. Note that a version is " - "required for non-experimental active artifacts." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Measure`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "subtitle", - "status", - "experimental", - "subjectCodeableConcept", - "subjectReference", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "usage", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "topic", - "author", - "editor", - "reviewer", - "endorser", - "relatedArtifact", - "library", - "disclaimer", - "scoring", - "compositeScoring", - "type", - "riskAdjustment", - "rateAggregation", - "rationale", - "clinicalRecommendationStatement", - "improvementNotation", - "definition", - "guidance", - "group", - "supplementalData", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_900( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_900( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"subject": ["subjectCodeableConcept", "subjectReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class MeasureGroup(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Population criteria group. - A group of population criteria for the measure. - """ - - resource_type = Field("MeasureGroup", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Meaning of the group", - description=( - "Indicates a meaning for the group. This can be as simple as a unique " - "identifier, or it can establish meaning in a broader context by " - "drawing from a terminology, allowing groups to be correlated across " - "measures." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Summary description", - description="The human readable description of this population group.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - population: typing.List[fhirtypes.MeasureGroupPopulationType] = Field( - None, - alias="population", - title="Population criteria", - description="A population criteria for the measure.", - # if property is element of this resource. - element_property=True, - ) - - stratifier: typing.List[fhirtypes.MeasureGroupStratifierType] = Field( - None, - alias="stratifier", - title="Stratifier criteria for the measure", - description=( - "The stratifier criteria for the measure report, specified as either " - "the name of a valid CQL expression defined within a referenced library" - " or a valid FHIR Resource Path." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureGroup`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "description", - "population", - "stratifier", - ] - - -class MeasureGroupPopulation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Population criteria. - A population criteria for the measure. - """ - - resource_type = Field("MeasureGroupPopulation", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title=( - "initial-population | numerator | numerator-exclusion | denominator | " - "denominator-exclusion | denominator-exception | measure-population | " - "measure-population-exclusion | measure-observation" - ), - description="The type of population criteria.", - # if property is element of this resource. - element_property=True, - ) - - criteria: fhirtypes.ExpressionType = Field( - ..., - alias="criteria", - title="The criteria that defines this population", - description=( - "An expression that specifies the criteria for the population, " - "typically the name of an expression in a library." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="The human readable description of this population criteria", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureGroupPopulation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "description", - "criteria", - ] - - -class MeasureGroupStratifier(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Stratifier criteria for the measure. - The stratifier criteria for the measure report, specified as either the - name of a valid CQL expression defined within a referenced library or a - valid FHIR Resource Path. - """ - - resource_type = Field("MeasureGroupStratifier", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Meaning of the stratifier", - description=( - "Indicates a meaning for the stratifier. This can be as simple as a " - "unique identifier, or it can establish meaning in a broader context by" - " drawing from a terminology, allowing stratifiers to be correlated " - "across measures." - ), - # if property is element of this resource. - element_property=True, - ) - - component: typing.List[fhirtypes.MeasureGroupStratifierComponentType] = Field( - None, - alias="component", - title="Stratifier criteria component for the measure", - description=( - "A component of the stratifier criteria for the measure report, " - "specified as either the name of a valid CQL expression defined within " - "a referenced library or a valid FHIR Resource Path." - ), - # if property is element of this resource. - element_property=True, - ) - - criteria: fhirtypes.ExpressionType = Field( - None, - alias="criteria", - title="How the measure should be stratified", - description=( - "An expression that specifies the criteria for the stratifier. This is " - "typically the name of an expression defined within a referenced " - "library, but it may also be a path to a stratifier element." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="The human readable description of this stratifier", - description="The human readable description of this stratifier criteria.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureGroupStratifier`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "description", - "criteria", - "component", - ] - - -class MeasureGroupStratifierComponent(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Stratifier criteria component for the measure. - A component of the stratifier criteria for the measure report, specified as - either the name of a valid CQL expression defined within a referenced - library or a valid FHIR Resource Path. - """ - - resource_type = Field("MeasureGroupStratifierComponent", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Meaning of the stratifier component", - description=( - "Indicates a meaning for the stratifier component. This can be as " - "simple as a unique identifier, or it can establish meaning in a " - "broader context by drawing from a terminology, allowing stratifiers to" - " be correlated across measures." - ), - # if property is element of this resource. - element_property=True, - ) - - criteria: fhirtypes.ExpressionType = Field( - ..., - alias="criteria", - title="Component of how the measure should be stratified", - description=( - "An expression that specifies the criteria for this component of the " - "stratifier. This is typically the name of an expression defined within" - " a referenced library, but it may also be a path to a stratifier " - "element." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="The human readable description of this stratifier component", - description="The human readable description of this stratifier criteria component.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureGroupStratifierComponent`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "description", - "criteria", - ] - - -class MeasureSupplementalData(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What other data should be reported with the measure. - The supplemental data criteria for the measure report, specified as either - the name of a valid CQL expression within a referenced library, or a valid - FHIR Resource Path. - """ - - resource_type = Field("MeasureSupplementalData", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Meaning of the supplemental data", - description=( - "Indicates a meaning for the supplemental data. This can be as simple " - "as a unique identifier, or it can establish meaning in a broader " - "context by drawing from a terminology, allowing supplemental data to " - "be correlated across measures." - ), - # if property is element of this resource. - element_property=True, - ) - - criteria: fhirtypes.ExpressionType = Field( - ..., - alias="criteria", - title="Expression describing additional data to be reported", - description=( - "The criteria for the supplemental data. This is typically the name of " - "a valid expression defined within a referenced library, but it may " - "also be a path to a specific data element. The criteria defines the " - "data to be returned for this element." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="The human readable description of this supplemental data", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - usage: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="usage", - title="supplemental-data | risk-adjustment-factor", - description=( - "An indicator of the intended usage for the supplemental data element. " - "Supplemental data indicates the data is additional information " - "requested to augment the measure information. Risk adjustment factor " - "indicates the data is additional information used to calculate risk " - "adjustment factors when applying a risk model to the measure " - "calculation." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureSupplementalData`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "usage", - "description", - "criteria", - ] diff --git a/fhir/resources/measurereport.py b/fhir/resources/measurereport.py deleted file mode 100644 index 056ce3ea..00000000 --- a/fhir/resources/measurereport.py +++ /dev/null @@ -1,666 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MeasureReport -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class MeasureReport(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Results of a measure evaluation. - The MeasureReport resource contains the results of the calculation of a - measure; and optionally a reference to the resources involved in that - calculation. - """ - - resource_type = Field("MeasureReport", const=True) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="When the report was generated", - description="The date this measure report was generated.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - evaluatedResource: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="evaluatedResource", - title="What data was used to calculate the measure score", - description=( - "A reference to a Bundle containing the Resources that were used in the" - " calculation of this measure." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - group: typing.List[fhirtypes.MeasureReportGroupType] = Field( - None, - alias="group", - title="Measure results for each group", - description=( - "The results of the calculation, one for each population group in the " - "measure." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the MeasureReport", - description=( - "A formal identifier that is used to identify this MeasureReport when " - "it is represented in other formats or referenced in a specification, " - "model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - improvementNotation: fhirtypes.CodeableConceptType = Field( - None, - alias="improvementNotation", - title="increase | decrease", - description=( - "Whether improvement in the measure is noted by an increase or decrease" - " in the measure score." - ), - # if property is element of this resource. - element_property=True, - ) - - measure: fhirtypes.Canonical = Field( - None, - alias="measure", - title="What measure was calculated", - description="A reference to the Measure that was calculated to produce this report.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Measure"], - ) - measure__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_measure", title="Extension field for ``measure``." - ) - - period: fhirtypes.PeriodType = Field( - ..., - alias="period", - title="What period the report covers", - description="The reporting period for which the report was calculated.", - # if property is element of this resource. - element_property=True, - ) - - reporter: fhirtypes.ReferenceType = Field( - None, - alias="reporter", - title="Who is reporting the data", - description="The individual, location, or organization that is reporting the data.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Location", - "Organization", - ], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="complete | pending | error", - description=( - "The MeasureReport status. No data will be available until the " - "MeasureReport status is complete." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["complete", "pending", "error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="What individual(s) the report is for", - description=( - "Optional subject identifying the individual or individuals the report " - "is for." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "Location", - "Device", - "RelatedPerson", - "Group", - ], - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="individual | subject-list | summary | data-collection", - description=( - "The type of measure report. This may be an individual report, which " - "provides the score for the measure for an individual member of the " - "population; a subject-listing, which returns the list of members that " - "meet the various criteria in the measure; a summary report, which " - "returns a population count for each of the criteria in the measure; or" - " a data-collection, which enables the MeasureReport to be used to " - "exchange the data-of-interest for a quality measure." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["individual", "subject-list", "summary", "data-collection"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureReport`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "type", - "measure", - "subject", - "date", - "reporter", - "period", - "improvementNotation", - "group", - "evaluatedResource", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1551( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("measure", "measure__ext"), - ("status", "status__ext"), - ("type", "type__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class MeasureReportGroup(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Measure results for each group. - The results of the calculation, one for each population group in the - measure. - """ - - resource_type = Field("MeasureReportGroup", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Meaning of the group", - description=( - "The meaning of the population group as defined in the measure " - "definition." - ), - # if property is element of this resource. - element_property=True, - ) - - measureScore: fhirtypes.QuantityType = Field( - None, - alias="measureScore", - title="What score this group achieved", - description=( - "The measure score for this population group, calculated as appropriate" - " for the measure type and scoring method, and based on the contents of" - " the populations defined in the group." - ), - # if property is element of this resource. - element_property=True, - ) - - population: typing.List[fhirtypes.MeasureReportGroupPopulationType] = Field( - None, - alias="population", - title="The populations in the group", - description=( - "The populations that make up the population group, one for each type " - "of population appropriate for the measure." - ), - # if property is element of this resource. - element_property=True, - ) - - stratifier: typing.List[fhirtypes.MeasureReportGroupStratifierType] = Field( - None, - alias="stratifier", - title="Stratification results", - description=( - "When a measure includes multiple stratifiers, there will be a " - "stratifier group for each stratifier defined by the measure." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureReportGroup`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "population", - "measureScore", - "stratifier", - ] - - -class MeasureReportGroupPopulation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The populations in the group. - The populations that make up the population group, one for each type of - population appropriate for the measure. - """ - - resource_type = Field("MeasureReportGroupPopulation", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title=( - "initial-population | numerator | numerator-exclusion | denominator | " - "denominator-exclusion | denominator-exception | measure-population | " - "measure-population-exclusion | measure-observation" - ), - description="The type of the population.", - # if property is element of this resource. - element_property=True, - ) - - count: fhirtypes.Integer = Field( - None, - alias="count", - title="Size of the population", - description="The number of members of the population.", - # if property is element of this resource. - element_property=True, - ) - count__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_count", title="Extension field for ``count``." - ) - - subjectResults: fhirtypes.ReferenceType = Field( - None, - alias="subjectResults", - title="For subject-list reports, the subject results in this population", - description=( - "This element refers to a List of subject level MeasureReport " - "resources, one for each subject in this population." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["List"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureReportGroupPopulation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "count", - "subjectResults", - ] - - -class MeasureReportGroupStratifier(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Stratification results. - When a measure includes multiple stratifiers, there will be a stratifier - group for each stratifier defined by the measure. - """ - - resource_type = Field("MeasureReportGroupStratifier", const=True) - - code: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="code", - title="What stratifier of the group", - description="The meaning of this stratifier, as defined in the measure definition.", - # if property is element of this resource. - element_property=True, - ) - - stratum: typing.List[fhirtypes.MeasureReportGroupStratifierStratumType] = Field( - None, - alias="stratum", - title=( - "Stratum results, one for each unique value, or set of values, in the " - "stratifier, or stratifier components" - ), - description=( - "This element contains the results for a single stratum within the " - "stratifier. For example, when stratifying on administrative gender, " - "there will be four strata, one for each possible gender value." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureReportGroupStratifier`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "stratum"] - - -class MeasureReportGroupStratifierStratum(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Stratum results, one for each unique value, or set of values, in the - stratifier, or stratifier components. - This element contains the results for a single stratum within the - stratifier. For example, when stratifying on administrative gender, there - will be four strata, one for each possible gender value. - """ - - resource_type = Field("MeasureReportGroupStratifierStratum", const=True) - - component: typing.List[ - fhirtypes.MeasureReportGroupStratifierStratumComponentType - ] = Field( - None, - alias="component", - title="Stratifier component values", - description="A stratifier component value.", - # if property is element of this resource. - element_property=True, - ) - - measureScore: fhirtypes.QuantityType = Field( - None, - alias="measureScore", - title="What score this stratum achieved", - description=( - "The measure score for this stratum, calculated as appropriate for the " - "measure type and scoring method, and based on only the members of this" - " stratum." - ), - # if property is element of this resource. - element_property=True, - ) - - population: typing.List[ - fhirtypes.MeasureReportGroupStratifierStratumPopulationType - ] = Field( - None, - alias="population", - title="Population results in this stratum", - description=( - "The populations that make up the stratum, one for each type of " - "population appropriate to the measure." - ), - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.CodeableConceptType = Field( - None, - alias="value", - title="The stratum value, e.g. male", - description=( - "The value for this stratum, expressed as a CodeableConcept. When " - "defining stratifiers on complex values, the value must be rendered " - "such that the value for each stratum within the stratifier is unique." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureReportGroupStratifierStratum`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "value", - "component", - "population", - "measureScore", - ] - - -class MeasureReportGroupStratifierStratumComponent(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Stratifier component values. - A stratifier component value. - """ - - resource_type = Field("MeasureReportGroupStratifierStratumComponent", const=True) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="What stratifier component of the group", - description="The code for the stratum component value.", - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.CodeableConceptType = Field( - ..., - alias="value", - title="The stratum component value, e.g. male", - description="The stratum component value.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureReportGroupStratifierStratumComponent`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "value"] - - -class MeasureReportGroupStratifierStratumPopulation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Population results in this stratum. - The populations that make up the stratum, one for each type of population - appropriate to the measure. - """ - - resource_type = Field("MeasureReportGroupStratifierStratumPopulation", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title=( - "initial-population | numerator | numerator-exclusion | denominator | " - "denominator-exclusion | denominator-exception | measure-population | " - "measure-population-exclusion | measure-observation" - ), - description="The type of the population.", - # if property is element of this resource. - element_property=True, - ) - - count: fhirtypes.Integer = Field( - None, - alias="count", - title="Size of the population", - description="The number of members of the population in this stratum.", - # if property is element of this resource. - element_property=True, - ) - count__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_count", title="Extension field for ``count``." - ) - - subjectResults: fhirtypes.ReferenceType = Field( - None, - alias="subjectResults", - title="For subject-list reports, the subject results in this population", - description=( - "This element refers to a List of subject level MeasureReport " - "resources, one for each subject in this population in this stratum." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["List"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MeasureReportGroupStratifierStratumPopulation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "count", - "subjectResults", - ] diff --git a/fhir/resources/media.py b/fhir/resources/media.py deleted file mode 100644 index 2d8a39cd..00000000 --- a/fhir/resources/media.py +++ /dev/null @@ -1,481 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Media -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class Media(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A photo, video, or audio recording acquired or used in healthcare. The - actual content may be inline or provided by direct reference. - """ - - resource_type = Field("Media", const=True) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Procedure that caused this media to be created", - description=( - "A procedure that is fulfilled in whole or in part by the creation of " - "this media." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ServiceRequest", "CarePlan"], - ) - - bodySite: fhirtypes.CodeableConceptType = Field( - None, - alias="bodySite", - title="Observed body part", - description=( - "Indicates the site on the subject's body where the observation was " - "made (i.e. the target site)." - ), - # if property is element of this resource. - element_property=True, - ) - - content: fhirtypes.AttachmentType = Field( - ..., - alias="content", - title="Actual Media - reference or data", - description=( - "The actual content of the media - inline or by direct reference to the" - " media source file." - ), - # if property is element of this resource. - element_property=True, - ) - - createdDateTime: fhirtypes.DateTime = Field( - None, - alias="createdDateTime", - title="When Media was collected", - description="The date and time(s) at which the media was collected.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e created[x] - one_of_many="created", - one_of_many_required=False, - ) - createdDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_createdDateTime", title="Extension field for ``createdDateTime``." - ) - - createdPeriod: fhirtypes.PeriodType = Field( - None, - alias="createdPeriod", - title="When Media was collected", - description="The date and time(s) at which the media was collected.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e created[x] - one_of_many="created", - one_of_many_required=False, - ) - - device: fhirtypes.ReferenceType = Field( - None, - alias="device", - title="Observing Device", - description="The device used to collect the media.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device", "DeviceMetric", "Device"], - ) - - deviceName: fhirtypes.String = Field( - None, - alias="deviceName", - title="Name of the device/manufacturer", - description=( - "The name of the device / manufacturer of the device that was used to " - "make the recording." - ), - # if property is element of this resource. - element_property=True, - ) - deviceName__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_deviceName", title="Extension field for ``deviceName``." - ) - - duration: fhirtypes.Decimal = Field( - None, - alias="duration", - title="Length in seconds (audio / video)", - description="The duration of the recording in seconds - for audio and video.", - # if property is element of this resource. - element_property=True, - ) - duration__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_duration", title="Extension field for ``duration``." - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter associated with media", - description="The encounter that establishes the context for this media.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - frames: fhirtypes.PositiveInt = Field( - None, - alias="frames", - title="Number of frames if > 1 (photo)", - description=( - "The number of frames in a photo. This is used with a multi-page fax, " - "or an imaging acquisition context that takes multiple slices in a " - "single image, or an animated gif. If there is more than one frame, " - "this SHALL have a value in order to alert interface software that a " - "multi-frame capable rendering widget is required." - ), - # if property is element of this resource. - element_property=True, - ) - frames__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_frames", title="Extension field for ``frames``." - ) - - height: fhirtypes.PositiveInt = Field( - None, - alias="height", - title="Height of the image in pixels (photo/video)", - description=None, - # if property is element of this resource. - element_property=True, - ) - height__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_height", title="Extension field for ``height``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Identifier(s) for the image", - description=( - "Identifiers associated with the image - these may include identifiers " - "for the image itself, identifiers for the context of its collection " - "(e.g. series ids) and context ids such as accession numbers or other " - "workflow identifiers." - ), - # if property is element of this resource. - element_property=True, - ) - - issued: fhirtypes.Instant = Field( - None, - alias="issued", - title="Date/Time this version was made available", - description=( - "The date and time this version of the media was made available to " - "providers, typically after having been reviewed." - ), - # if property is element of this resource. - element_property=True, - ) - issued__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_issued", title="Extension field for ``issued``." - ) - - modality: fhirtypes.CodeableConceptType = Field( - None, - alias="modality", - title="The type of acquisition equipment/process", - description=( - "Details of the type of the media - usually, how it was acquired (what " - "type of device). If images sourced from a DICOM system, are wrapped in" - " a Media resource, then this is the modality." - ), - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments made about the media", - description=( - "Comments made about the media by the performer, subject or other " - "participants." - ), - # if property is element of this resource. - element_property=True, - ) - - operator: fhirtypes.ReferenceType = Field( - None, - alias="operator", - title="The person who generated the image", - description="The person who administered the collection of the image.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "CareTeam", - "Patient", - "Device", - "RelatedPerson", - ], - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Part of referenced event", - description="A larger event of which this particular event is a component or step.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why was event performed?", - description="Describes why the event occurred in coded or textual form.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "preparation | in-progress | not-done | on-hold | stopped | completed |" - " entered-in-error | unknown" - ), - description="The current state of the {{title}}.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "preparation", - "in-progress", - "not-done", - "on-hold", - "stopped", - "completed", - "entered-in-error", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Who/What this Media is a record of", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "Group", - "Device", - "Specimen", - "Location", - ], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Classification of media as image, video, or audio", - description=( - "A code that classifies whether the media is an image, video or audio " - "recording or some other media category." - ), - # if property is element of this resource. - element_property=True, - ) - - view: fhirtypes.CodeableConceptType = Field( - None, - alias="view", - title="Imaging view, e.g. Lateral or Antero-posterior", - description="The name of the imaging view e.g. Lateral or Antero-posterior (AP).", - # if property is element of this resource. - element_property=True, - ) - - width: fhirtypes.PositiveInt = Field( - None, - alias="width", - title="Width of the image in pixels (photo/video)", - description=None, - # if property is element of this resource. - element_property=True, - ) - width__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_width", title="Extension field for ``width``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Media`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "basedOn", - "partOf", - "status", - "type", - "modality", - "view", - "subject", - "encounter", - "createdDateTime", - "createdPeriod", - "issued", - "operator", - "reasonCode", - "bodySite", - "deviceName", - "device", - "height", - "width", - "frames", - "duration", - "content", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_654( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_654( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"created": ["createdDateTime", "createdPeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/medication.py b/fhir/resources/medication.py deleted file mode 100644 index dec45d83..00000000 --- a/fhir/resources/medication.py +++ /dev/null @@ -1,318 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Medication -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class Medication(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Definition of a Medication. - This resource is primarily used for the identification and definition of a - medication for the purposes of prescribing, dispensing, and administering a - medication as well as for making statements about medication use. - """ - - resource_type = Field("Medication", const=True) - - amount: fhirtypes.RatioType = Field( - None, - alias="amount", - title="Amount of drug in package", - description=( - "Specific amount of the drug in the packaged product. For example, " - "when specifying a product that has the same strength (For example, " - "Insulin glargine 100 unit per mL solution for injection), this " - "attribute provides additional clarification of the package amount (For" - " example, 3 mL, 10mL, etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - - batch: fhirtypes.MedicationBatchType = Field( - None, - alias="batch", - title="Details about packaged medications", - description="Information that only applies to packages (not products).", - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Codes that identify this medication", - description=( - "A code (or set of codes) that specify this medication, or a textual " - "description if no code is available. Usage note: This could be a " - "standard medication code such as a code from RxNorm, SNOMED CT, IDMP " - "etc. It could also be a national or local formulary code, optionally " - "with translations to other code systems." - ), - # if property is element of this resource. - element_property=True, - ) - - form: fhirtypes.CodeableConceptType = Field( - None, - alias="form", - title="powder | tablets | capsule +", - description="Describes the form of the item. Powder; tablets; capsule.", - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier for this medication", - description=None, - # if property is element of this resource. - element_property=True, - ) - - ingredient: typing.List[fhirtypes.MedicationIngredientType] = Field( - None, - alias="ingredient", - title="Active or inactive ingredient", - description="Identifies a particular constituent of interest in the product.", - # if property is element of this resource. - element_property=True, - ) - - manufacturer: fhirtypes.ReferenceType = Field( - None, - alias="manufacturer", - title="Manufacturer of the item", - description=( - "Describes the details of the manufacturer of the medication product. " - "This is not intended to represent the distributor of a medication " - "product." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | inactive | entered-in-error", - description="A code to indicate if the medication is in active use.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "inactive", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Medication`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "code", - "status", - "manufacturer", - "form", - "amount", - "ingredient", - "batch", - ] - - -class MedicationBatch(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Details about packaged medications. - Information that only applies to packages (not products). - """ - - resource_type = Field("MedicationBatch", const=True) - - expirationDate: fhirtypes.DateTime = Field( - None, - alias="expirationDate", - title="When batch will expire", - description="When this specific batch of product will expire.", - # if property is element of this resource. - element_property=True, - ) - expirationDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expirationDate", title="Extension field for ``expirationDate``." - ) - - lotNumber: fhirtypes.String = Field( - None, - alias="lotNumber", - title="Identifier assigned to batch", - description="The assigned lot number of a batch of the specified product.", - # if property is element of this resource. - element_property=True, - ) - lotNumber__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lotNumber", title="Extension field for ``lotNumber``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationBatch`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "lotNumber", "expirationDate"] - - -class MedicationIngredient(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Active or inactive ingredient. - Identifies a particular constituent of interest in the product. - """ - - resource_type = Field("MedicationIngredient", const=True) - - isActive: bool = Field( - None, - alias="isActive", - title="Active ingredient indicator", - description=( - "Indication of whether this ingredient affects the therapeutic action " - "of the drug." - ), - # if property is element of this resource. - element_property=True, - ) - isActive__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_isActive", title="Extension field for ``isActive``." - ) - - itemCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="itemCodeableConcept", - title="The actual ingredient or content", - description=( - "The actual ingredient - either a substance (simple ingredient) or " - "another medication of a medication." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e item[x] - one_of_many="item", - one_of_many_required=True, - ) - - itemReference: fhirtypes.ReferenceType = Field( - None, - alias="itemReference", - title="The actual ingredient or content", - description=( - "The actual ingredient - either a substance (simple ingredient) or " - "another medication of a medication." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e item[x] - one_of_many="item", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Substance", "Medication"], - ) - - strength: fhirtypes.RatioType = Field( - None, - alias="strength", - title="Quantity of ingredient present", - description=( - "Specifies how many (or how much) of the items there are in this " - "Medication. For example, 250 mg per tablet. This is expressed as a " - "ratio where the numerator is 250mg and the denominator is 1 tablet." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationIngredient`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "itemCodeableConcept", - "itemReference", - "isActive", - "strength", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2247( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"item": ["itemCodeableConcept", "itemReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/medicationadministration.py b/fhir/resources/medicationadministration.py deleted file mode 100644 index 88c87c21..00000000 --- a/fhir/resources/medicationadministration.py +++ /dev/null @@ -1,707 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicationAdministration -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class MedicationAdministration(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Administration of medication to a patient. - Describes the event of a patient consuming or otherwise being administered - a medication. This may be as simple as swallowing a tablet or it may be a - long running infusion. Related resources tie this event to the authorizing - prescription, and the specific encounter between patient and health care - practitioner. - """ - - resource_type = Field("MedicationAdministration", const=True) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Type of medication usage", - description=( - "Indicates where the medication is expected to be consumed or " - "administered." - ), - # if property is element of this resource. - element_property=True, - ) - - context: fhirtypes.ReferenceType = Field( - None, - alias="context", - title="Encounter or Episode of Care administered as part of", - description=( - "The visit, admission, or other contact between patient and health care" - " provider during which the medication administration was performed." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter", "EpisodeOfCare"], - ) - - device: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="device", - title="Device used to administer", - description=( - "The device used in administering the medication to the patient. For " - "example, a particular infusion pump." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - dosage: fhirtypes.MedicationAdministrationDosageType = Field( - None, - alias="dosage", - title="Details of how medication was taken", - description=( - "Describes the medication dosage information details e.g. dose, rate, " - "site, route, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - effectiveDateTime: fhirtypes.DateTime = Field( - None, - alias="effectiveDateTime", - title="Start and end time of administration", - description=( - "A specific date/time or interval of time during which the " - "administration took place (or did not take place, when the 'notGiven' " - "attribute is true). For many administrations, such as swallowing a " - "tablet the use of dateTime is more appropriate." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=True, - ) - effectiveDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_effectiveDateTime", - title="Extension field for ``effectiveDateTime``.", - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="Start and end time of administration", - description=( - "A specific date/time or interval of time during which the " - "administration took place (or did not take place, when the 'notGiven' " - "attribute is true). For many administrations, such as swallowing a " - "tablet the use of dateTime is more appropriate." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=True, - ) - - eventHistory: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="eventHistory", - title="A list of events of interest in the lifecycle", - description=( - "A summary of the events of interest that have occurred, such as when " - "the administration was verified." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Provenance"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External identifier", - description=( - "Identifiers associated with this Medication Administration that are " - "defined by business processes and/or used to refer to it when a direct" - " URL reference to the resource itself is not appropriate. They are " - "business identifiers assigned to this resource by the performer or " - "other systems and remain constant as the resource is updated and " - "propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - instantiates: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiates", - title="Instantiates protocol or definition", - description=( - "A protocol, guideline, orderset, or other definition that was adhered " - "to in whole or in part by this event." - ), - # if property is element of this resource. - element_property=True, - ) - instantiates__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiates", title="Extension field for ``instantiates``." - ) - - medicationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="medicationCodeableConcept", - title="What was administered", - description=( - "Identifies the medication that was administered. This is either a link" - " to a resource representing the details of the medication or a simple " - "attribute carrying a code that identifies the medication from a known " - "list of medications." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - ) - - medicationReference: fhirtypes.ReferenceType = Field( - None, - alias="medicationReference", - title="What was administered", - description=( - "Identifies the medication that was administered. This is either a link" - " to a resource representing the details of the medication or a simple " - "attribute carrying a code that identifies the medication from a known " - "list of medications." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Medication"], - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Information about the administration", - description=( - "Extra information about the medication administration that is not " - "conveyed by the other attributes." - ), - # if property is element of this resource. - element_property=True, - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Part of referenced event", - description="A larger event of which this particular event is a component or step.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicationAdministration", "Procedure"], - ) - - performer: typing.List[fhirtypes.MedicationAdministrationPerformerType] = Field( - None, - alias="performer", - title="Who performed the medication administration and what they did", - description=( - "Indicates who or what performed the medication administration and how " - "they were involved." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Reason administration performed", - description="A code indicating why the medication was given.", - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title=( - "Condition or observation that supports why the medication was " - "administered" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition", "Observation", "DiagnosticReport"], - ) - - request: fhirtypes.ReferenceType = Field( - None, - alias="request", - title="Request administration performed against", - description=( - "The original request, instruction or authority to perform the " - "administration." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicationRequest"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "in-progress | not-done | on-hold | completed | entered-in-error | " - "stopped | unknown" - ), - description=( - "Will generally be set to show that the administration has been " - "completed. For some long running administrations such as infusions, " - "it is possible for an administration to be started but not completed " - "or it may be paused while some other process is under way." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "in-progress", - "not-done", - "on-hold", - "completed", - "entered-in-error", - "stopped", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReason: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="statusReason", - title="Reason administration not performed", - description="A code indicating why the administration was not performed.", - # if property is element of this resource. - element_property=True, - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Who received medication", - description="The person or animal or group receiving the medication.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - supportingInformation: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingInformation", - title="Additional information to support administration", - description=( - "Additional information (for example, patient height and weight) that " - "supports the administration of the medication." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationAdministration`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "instantiates", - "partOf", - "status", - "statusReason", - "category", - "medicationCodeableConcept", - "medicationReference", - "subject", - "context", - "supportingInformation", - "effectiveDateTime", - "effectivePeriod", - "performer", - "reasonCode", - "reasonReference", - "request", - "device", - "note", - "dosage", - "eventHistory", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2686( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2686( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "effective": ["effectiveDateTime", "effectivePeriod"], - "medication": ["medicationCodeableConcept", "medicationReference"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class MedicationAdministrationDosage(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Details of how medication was taken. - Describes the medication dosage information details e.g. dose, rate, site, - route, etc. - """ - - resource_type = Field("MedicationAdministrationDosage", const=True) - - dose: fhirtypes.QuantityType = Field( - None, - alias="dose", - title="Amount of medication per dose", - description=( - "The amount of the medication given at one administration event. Use " - "this value when the administration is essentially an instantaneous " - "event such as a swallowing a tablet or giving an injection." - ), - # if property is element of this resource. - element_property=True, - ) - - method: fhirtypes.CodeableConceptType = Field( - None, - alias="method", - title="How drug was administered", - description=( - "A coded value indicating the method by which the medication is " - "intended to be or was introduced into or on the body. This attribute " - "will most often NOT be populated. It is most commonly used for " - "injections. For example, Slow Push, Deep IV." - ), - # if property is element of this resource. - element_property=True, - ) - - rateQuantity: fhirtypes.QuantityType = Field( - None, - alias="rateQuantity", - title="Dose quantity per unit of time", - description=( - "Identifies the speed with which the medication was or will be " - "introduced into the patient. Typically, the rate for an infusion e.g." - " 100 ml per 1 hour or 100 ml/hr. May also be expressed as a rate per " - "unit of time, e.g. 500 ml per 2 hours. Other examples: 200 mcg/min " - "or 200 mcg/1 minute; 1 liter/8 hours." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e rate[x] - one_of_many="rate", - one_of_many_required=False, - ) - - rateRatio: fhirtypes.RatioType = Field( - None, - alias="rateRatio", - title="Dose quantity per unit of time", - description=( - "Identifies the speed with which the medication was or will be " - "introduced into the patient. Typically, the rate for an infusion e.g." - " 100 ml per 1 hour or 100 ml/hr. May also be expressed as a rate per " - "unit of time, e.g. 500 ml per 2 hours. Other examples: 200 mcg/min " - "or 200 mcg/1 minute; 1 liter/8 hours." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e rate[x] - one_of_many="rate", - one_of_many_required=False, - ) - - route: fhirtypes.CodeableConceptType = Field( - None, - alias="route", - title="Path of substance into body", - description=( - "A code specifying the route or physiological path of administration of" - " a therapeutic agent into or onto the patient. For example, topical, " - "intravenous, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - site: fhirtypes.CodeableConceptType = Field( - None, - alias="site", - title="Body site administered to", - description=( - "A coded specification of the anatomic site where the medication first " - 'entered the body. For example, "left arm".' - ), - # if property is element of this resource. - element_property=True, - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Free text dosage instructions e.g. SIG", - description=( - "Free text dosage can be used for cases where the dosage administered " - "is too complex to code. When coded dosage is present, the free text " - "dosage may still be present for display to humans. The dosage " - "instructions should reflect the dosage of the medication that was " - "administered." - ), - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationAdministrationDosage`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "text", - "site", - "route", - "method", - "dose", - "rateRatio", - "rateQuantity", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3272( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"rate": ["rateQuantity", "rateRatio"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class MedicationAdministrationPerformer(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Who performed the medication administration and what they did. - Indicates who or what performed the medication administration and how they - were involved. - """ - - resource_type = Field("MedicationAdministrationPerformer", const=True) - - actor: fhirtypes.ReferenceType = Field( - ..., - alias="actor", - title="Who performed the medication administration", - description="Indicates who or what performed the medication administration.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Patient", - "RelatedPerson", - "Device", - ], - ) - - function: fhirtypes.CodeableConceptType = Field( - None, - alias="function", - title="Type of performance", - description=( - "Distinguishes the type of involvement of the performer in the " - "medication administration." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationAdministrationPerformer`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "function", "actor"] diff --git a/fhir/resources/medicationdispense.py b/fhir/resources/medicationdispense.py deleted file mode 100644 index 26506d54..00000000 --- a/fhir/resources/medicationdispense.py +++ /dev/null @@ -1,734 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicationDispense -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class MedicationDispense(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Dispensing a medication to a named patient. - Indicates that a medication product is to be or has been dispensed for a - named person/patient. This includes a description of the medication - product (supply) provided and the instructions for administering the - medication. The medication dispense is the result of a pharmacy system - responding to a medication order. - """ - - resource_type = Field("MedicationDispense", const=True) - - authorizingPrescription: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="authorizingPrescription", - title="Medication order that authorizes the dispense", - description="Indicates the medication order that is being dispensed against.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicationRequest"], - ) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Type of medication dispense", - description=( - "Indicates the type of medication dispense (for example, where the " - "medication is expected to be consumed or administered (i.e. inpatient " - "or outpatient))." - ), - # if property is element of this resource. - element_property=True, - ) - - context: fhirtypes.ReferenceType = Field( - None, - alias="context", - title="Encounter / Episode associated with event", - description=( - "The encounter or episode of care that establishes the context for this" - " event." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter", "EpisodeOfCare"], - ) - - daysSupply: fhirtypes.QuantityType = Field( - None, - alias="daysSupply", - title="Amount of medication expressed as a timing amount", - description="The amount of medication expressed as a timing amount.", - # if property is element of this resource. - element_property=True, - ) - - destination: fhirtypes.ReferenceType = Field( - None, - alias="destination", - title="Where the medication was sent", - description=( - "Identification of the facility/location where the medication was " - "shipped to, as part of the dispense event." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - detectedIssue: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="detectedIssue", - title="Clinical issue with action", - description=( - "Indicates an actual or potential clinical issue with or between one or" - " more active or proposed clinical actions for a patient; e.g. drug-" - "drug interaction, duplicate therapy, dosage alert etc." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DetectedIssue"], - ) - - dosageInstruction: typing.List[fhirtypes.DosageType] = Field( - None, - alias="dosageInstruction", - title=( - "How the medication is to be used by the patient or administered by the" - " caregiver" - ), - description="Indicates how the medication is to be used by the patient.", - # if property is element of this resource. - element_property=True, - ) - - eventHistory: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="eventHistory", - title="A list of relevant lifecycle events", - description=( - "A summary of the events of interest that have occurred, such as when " - "the dispense was verified." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Provenance"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External identifier", - description=( - "Identifiers associated with this Medication Dispense that are defined " - "by business processes and/or used to refer to it when a direct URL " - "reference to the resource itself is not appropriate. They are business" - " identifiers assigned to this resource by the performer or other " - "systems and remain constant as the resource is updated and propagates " - "from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - location: fhirtypes.ReferenceType = Field( - None, - alias="location", - title="Where the dispense occurred", - description="The principal physical location where the dispense was performed.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - medicationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="medicationCodeableConcept", - title="What medication was supplied", - description=( - "Identifies the medication being administered. This is either a link to" - " a resource representing the details of the medication or a simple " - "attribute carrying a code that identifies the medication from a known " - "list of medications." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - ) - - medicationReference: fhirtypes.ReferenceType = Field( - None, - alias="medicationReference", - title="What medication was supplied", - description=( - "Identifies the medication being administered. This is either a link to" - " a resource representing the details of the medication or a simple " - "attribute carrying a code that identifies the medication from a known " - "list of medications." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Medication"], - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Information about the dispense", - description=( - "Extra information about the dispense that could not be conveyed in the" - " other attributes." - ), - # if property is element of this resource. - element_property=True, - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Event that dispense is part of", - description="The procedure that trigger the dispense.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Procedure"], - ) - - performer: typing.List[fhirtypes.MedicationDispensePerformerType] = Field( - None, - alias="performer", - title="Who performed event", - description="Indicates who or what performed the event.", - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Amount dispensed", - description=( - "The amount of medication that has been dispensed. Includes unit of " - "measure." - ), - # if property is element of this resource. - element_property=True, - ) - - receiver: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="receiver", - title="Who collected the medication", - description=( - "Identifies the person who picked up the medication. This will usually" - " be a patient or their caregiver, but some cases exist where it can be" - " a healthcare professional." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Practitioner"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "preparation | in-progress | cancelled | on-hold | completed | entered-" - "in-error | stopped | declined | unknown" - ), - description="A code specifying the state of the set of dispense events.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "preparation", - "in-progress", - "cancelled", - "on-hold", - "completed", - "entered-in-error", - "stopped", - "declined", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReasonCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="statusReasonCodeableConcept", - title="Why a dispense was not performed", - description="Indicates the reason why a dispense was not performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e statusReason[x] - one_of_many="statusReason", - one_of_many_required=False, - ) - - statusReasonReference: fhirtypes.ReferenceType = Field( - None, - alias="statusReasonReference", - title="Why a dispense was not performed", - description="Indicates the reason why a dispense was not performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e statusReason[x] - one_of_many="statusReason", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DetectedIssue"], - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Who the dispense is for", - description=( - "A link to a resource representing the person or the group to whom the " - "medication will be given." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - substitution: fhirtypes.MedicationDispenseSubstitutionType = Field( - None, - alias="substitution", - title="Whether a substitution was performed on the dispense", - description=( - "Indicates whether or not substitution was made as part of the " - "dispense. In some cases, substitution will be expected but does not " - "happen, in other cases substitution is not expected but does happen. " - "This block explains what substitution did or did not happen and why. " - "If nothing is specified, substitution was not done." - ), - # if property is element of this resource. - element_property=True, - ) - - supportingInformation: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingInformation", - title="Information that supports the dispensing of the medication", - description="Additional information that supports the medication being dispensed.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Trial fill, partial fill, emergency fill, etc.", - description=( - "Indicates the type of dispensing event that is performed. For example," - " Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, " - "Samples, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - whenHandedOver: fhirtypes.DateTime = Field( - None, - alias="whenHandedOver", - title="When product was given out", - description=( - "The time the dispensed product was provided to the patient or their " - "representative." - ), - # if property is element of this resource. - element_property=True, - ) - whenHandedOver__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_whenHandedOver", title="Extension field for ``whenHandedOver``." - ) - - whenPrepared: fhirtypes.DateTime = Field( - None, - alias="whenPrepared", - title="When product was packaged and reviewed", - description="The time when the dispensed product was packaged and reviewed.", - # if property is element of this resource. - element_property=True, - ) - whenPrepared__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_whenPrepared", title="Extension field for ``whenPrepared``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationDispense`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "partOf", - "status", - "statusReasonCodeableConcept", - "statusReasonReference", - "category", - "medicationCodeableConcept", - "medicationReference", - "subject", - "context", - "supportingInformation", - "performer", - "location", - "authorizingPrescription", - "type", - "quantity", - "daysSupply", - "whenPrepared", - "whenHandedOver", - "destination", - "receiver", - "note", - "dosageInstruction", - "substitution", - "detectedIssue", - "eventHistory", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2026( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2026( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "medication": ["medicationCodeableConcept", "medicationReference"], - "statusReason": ["statusReasonCodeableConcept", "statusReasonReference"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class MedicationDispensePerformer(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Who performed event. - Indicates who or what performed the event. - """ - - resource_type = Field("MedicationDispensePerformer", const=True) - - actor: fhirtypes.ReferenceType = Field( - ..., - alias="actor", - title="Individual who was performing", - description=( - "The device, practitioner, etc. who performed the action. It should be" - " assumed that the actor is the dispenser of the medication." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Patient", - "Device", - "RelatedPerson", - ], - ) - - function: fhirtypes.CodeableConceptType = Field( - None, - alias="function", - title="Who performed the dispense and what they did", - description=( - "Distinguishes the type of performer in the dispense. For example, " - "date enterer, packager, final checker." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationDispensePerformer`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "function", "actor"] - - -class MedicationDispenseSubstitution(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Whether a substitution was performed on the dispense. - Indicates whether or not substitution was made as part of the dispense. In - some cases, substitution will be expected but does not happen, in other - cases substitution is not expected but does happen. This block explains - what substitution did or did not happen and why. If nothing is specified, - substitution was not done. - """ - - resource_type = Field("MedicationDispenseSubstitution", const=True) - - reason: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reason", - title="Why was substitution made", - description=( - "Indicates the reason for the substitution (or lack of substitution) " - "from what was prescribed." - ), - # if property is element of this resource. - element_property=True, - ) - - responsibleParty: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="responsibleParty", - title="Who is responsible for the substitution", - description=( - "The person or organization that has primary responsibility for the " - "substitution." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title=( - "Code signifying whether a different drug was dispensed from what was " - "prescribed" - ), - description=( - "A code signifying whether a different drug was dispensed from what was" - " prescribed." - ), - # if property is element of this resource. - element_property=True, - ) - - wasSubstituted: bool = Field( - None, - alias="wasSubstituted", - title="Whether a substitution was or was not performed on the dispense", - description=( - "True if the dispenser dispensed a different drug or product from what " - "was prescribed." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - wasSubstituted__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_wasSubstituted", title="Extension field for ``wasSubstituted``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationDispenseSubstitution`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "wasSubstituted", - "type", - "reason", - "responsibleParty", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3344( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("wasSubstituted", "wasSubstituted__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/medicationknowledge.py b/fhir/resources/medicationknowledge.py deleted file mode 100644 index f1e21fd9..00000000 --- a/fhir/resources/medicationknowledge.py +++ /dev/null @@ -1,1466 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicationKnowledge -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class MedicationKnowledge(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Definition of Medication Knowledge. - Information about a medication that is used to support knowledge. - """ - - resource_type = Field("MedicationKnowledge", const=True) - - administrationGuidelines: typing.List[ - fhirtypes.MedicationKnowledgeAdministrationGuidelinesType - ] = Field( - None, - alias="administrationGuidelines", - title="Guidelines for administration of the medication", - description="Guidelines for the administration of the medication.", - # if property is element of this resource. - element_property=True, - ) - - amount: fhirtypes.QuantityType = Field( - None, - alias="amount", - title="Amount of drug in package", - description=( - "Specific amount of the drug in the packaged product. For example, " - "when specifying a product that has the same strength (For example, " - "Insulin glargine 100 unit per mL solution for injection), this " - "attribute provides additional clarification of the package amount (For" - " example, 3 mL, 10mL, etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - - associatedMedication: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="associatedMedication", - title="A medication resource that is associated with this medication", - description=( - "Associated or related medications. For example, if the medication is " - "a branded product (e.g. Crestor), this is the Therapeutic Moeity (e.g." - " Rosuvastatin) or if this is a generic medication (e.g. Rosuvastatin)," - " this would link to a branded product (e.g. Crestor)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Medication"], - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Code that identifies this medication", - description=( - "A code that specifies this medication, or a textual description if no " - "code is available. Usage note: This could be a standard medication " - "code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be" - " a national or local formulary code, optionally with translations to " - "other code systems." - ), - # if property is element of this resource. - element_property=True, - ) - - contraindication: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="contraindication", - title="Potential clinical issue with or between medication(s)", - description=( - "Potential clinical issue with or between medication(s) (for example, " - "drug-drug interaction, drug-disease contraindication, drug-allergy " - "interaction, etc.)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DetectedIssue"], - ) - - cost: typing.List[fhirtypes.MedicationKnowledgeCostType] = Field( - None, - alias="cost", - title="The pricing of the medication", - description="The price of the medication.", - # if property is element of this resource. - element_property=True, - ) - - doseForm: fhirtypes.CodeableConceptType = Field( - None, - alias="doseForm", - title="powder | tablets | capsule +", - description="Describes the form of the item. Powder; tablets; capsule.", - # if property is element of this resource. - element_property=True, - ) - - drugCharacteristic: typing.List[ - fhirtypes.MedicationKnowledgeDrugCharacteristicType - ] = Field( - None, - alias="drugCharacteristic", - title="Specifies descriptive properties of the medicine", - description=( - "Specifies descriptive properties of the medicine, such as color, " - "shape, imprints, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - ingredient: typing.List[fhirtypes.MedicationKnowledgeIngredientType] = Field( - None, - alias="ingredient", - title="Active or inactive ingredient", - description="Identifies a particular constituent of interest in the product.", - # if property is element of this resource. - element_property=True, - ) - - intendedRoute: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="intendedRoute", - title="The intended or approved route of administration", - description=None, - # if property is element of this resource. - element_property=True, - ) - - kinetics: typing.List[fhirtypes.MedicationKnowledgeKineticsType] = Field( - None, - alias="kinetics", - title=( - "The time course of drug absorption, distribution, metabolism and " - "excretion of a medication from the body" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - manufacturer: fhirtypes.ReferenceType = Field( - None, - alias="manufacturer", - title="Manufacturer of the item", - description=( - "Describes the details of the manufacturer of the medication product. " - "This is not intended to represent the distributor of a medication " - "product." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - medicineClassification: typing.List[ - fhirtypes.MedicationKnowledgeMedicineClassificationType - ] = Field( - None, - alias="medicineClassification", - title=( - "Categorization of the medication within a formulary or classification " - "system" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - monitoringProgram: typing.List[ - fhirtypes.MedicationKnowledgeMonitoringProgramType - ] = Field( - None, - alias="monitoringProgram", - title="Program under which a medication is reviewed", - description="The program under which the medication is reviewed.", - # if property is element of this resource. - element_property=True, - ) - - monograph: typing.List[fhirtypes.MedicationKnowledgeMonographType] = Field( - None, - alias="monograph", - title="Associated documentation about the medication", - description=None, - # if property is element of this resource. - element_property=True, - ) - - packaging: fhirtypes.MedicationKnowledgePackagingType = Field( - None, - alias="packaging", - title="Details about packaged medications", - description="Information that only applies to packages (not products).", - # if property is element of this resource. - element_property=True, - ) - - preparationInstruction: fhirtypes.Markdown = Field( - None, - alias="preparationInstruction", - title="The instructions for preparing the medication", - description=None, - # if property is element of this resource. - element_property=True, - ) - preparationInstruction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_preparationInstruction", - title="Extension field for ``preparationInstruction``.", - ) - - productType: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="productType", - title="Category of the medication or product", - description=( - "Category of the medication or product (e.g. branded product, " - "therapeutic moeity, generic product, innovator product, etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - - regulatory: typing.List[fhirtypes.MedicationKnowledgeRegulatoryType] = Field( - None, - alias="regulatory", - title="Regulatory information about a medication", - description=None, - # if property is element of this resource. - element_property=True, - ) - - relatedMedicationKnowledge: typing.List[ - fhirtypes.MedicationKnowledgeRelatedMedicationKnowledgeType - ] = Field( - None, - alias="relatedMedicationKnowledge", - title="Associated or related medication information", - description="Associated or related knowledge about a medication.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | inactive | entered-in-error", - description=( - "A code to indicate if the medication is in active use. The status " - "refers to the validity about the information of the medication and not" - " to its medicinal properties." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "inactive", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - synonym: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="synonym", - title="Additional names for a medication", - description=( - "Additional names for a medication, for example, the name(s) given to a" - " medication in different countries. For example, acetaminophen and " - "paracetamol or salbutamol and albuterol." - ), - # if property is element of this resource. - element_property=True, - ) - synonym__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_synonym", title="Extension field for ``synonym``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledge`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "code", - "status", - "manufacturer", - "doseForm", - "amount", - "synonym", - "relatedMedicationKnowledge", - "associatedMedication", - "productType", - "monograph", - "ingredient", - "preparationInstruction", - "intendedRoute", - "cost", - "monitoringProgram", - "administrationGuidelines", - "medicineClassification", - "packaging", - "drugCharacteristic", - "contraindication", - "regulatory", - "kinetics", - ] - - -class MedicationKnowledgeAdministrationGuidelines(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Guidelines for administration of the medication. - Guidelines for the administration of the medication. - """ - - resource_type = Field("MedicationKnowledgeAdministrationGuidelines", const=True) - - dosage: typing.List[ - fhirtypes.MedicationKnowledgeAdministrationGuidelinesDosageType - ] = Field( - None, - alias="dosage", - title="Dosage for the medication for the specific guidelines", - description=None, - # if property is element of this resource. - element_property=True, - ) - - indicationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="indicationCodeableConcept", - title=( - "Indication for use that apply to the specific administration " "guidelines" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e indication[x] - one_of_many="indication", - one_of_many_required=False, - ) - - indicationReference: fhirtypes.ReferenceType = Field( - None, - alias="indicationReference", - title=( - "Indication for use that apply to the specific administration " "guidelines" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e indication[x] - one_of_many="indication", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ObservationDefinition"], - ) - - patientCharacteristics: typing.List[ - fhirtypes.MedicationKnowledgeAdministrationGuidelinesPatientCharacteristicsType - ] = Field( - None, - alias="patientCharacteristics", - title=( - "Characteristics of the patient that are relevant to the administration" - " guidelines" - ), - description=( - "Characteristics of the patient that are relevant to the administration" - " guidelines (for example, height, weight, gender, etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeAdministrationGuidelines`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "dosage", - "indicationCodeableConcept", - "indicationReference", - "patientCharacteristics", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4652( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "indication": ["indicationCodeableConcept", "indicationReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class MedicationKnowledgeAdministrationGuidelinesDosage( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Dosage for the medication for the specific guidelines. - """ - - resource_type = Field( - "MedicationKnowledgeAdministrationGuidelinesDosage", const=True - ) - - dosage: typing.List[fhirtypes.DosageType] = Field( - ..., - alias="dosage", - title="Dosage for the medication for the specific guidelines", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Type of dosage", - description=( - "The type of dosage (for example, prophylaxis, maintenance, " - "therapeutic, etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeAdministrationGuidelinesDosage`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "dosage"] - - -class MedicationKnowledgeAdministrationGuidelinesPatientCharacteristics( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Characteristics of the patient that are relevant to the administration - guidelines. - Characteristics of the patient that are relevant to the administration - guidelines (for example, height, weight, gender, etc.). - """ - - resource_type = Field( - "MedicationKnowledgeAdministrationGuidelinesPatientCharacteristics", const=True - ) - - characteristicCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="characteristicCodeableConcept", - title=( - "Specific characteristic that is relevant to the administration " - "guideline" - ), - description=( - "Specific characteristic that is relevant to the administration " - "guideline (e.g. height, weight, gender)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e characteristic[x] - one_of_many="characteristic", - one_of_many_required=True, - ) - - characteristicQuantity: fhirtypes.QuantityType = Field( - None, - alias="characteristicQuantity", - title=( - "Specific characteristic that is relevant to the administration " - "guideline" - ), - description=( - "Specific characteristic that is relevant to the administration " - "guideline (e.g. height, weight, gender)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e characteristic[x] - one_of_many="characteristic", - one_of_many_required=True, - ) - - value: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="value", - title="The specific characteristic", - description="The specific characteristic (e.g. height, weight, gender, etc.).", - # if property is element of this resource. - element_property=True, - ) - value__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_value", title="Extension field for ``value``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeAdministrationGuidelinesPatientCharacteristics`` - according specification, with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "characteristicCodeableConcept", - "characteristicQuantity", - "value", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_6941( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "characteristic": [ - "characteristicCodeableConcept", - "characteristicQuantity", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class MedicationKnowledgeCost(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The pricing of the medication. - The price of the medication. - """ - - resource_type = Field("MedicationKnowledgeCost", const=True) - - cost: fhirtypes.MoneyType = Field( - ..., - alias="cost", - title="The price of the medication", - description=None, - # if property is element of this resource. - element_property=True, - ) - - source: fhirtypes.String = Field( - None, - alias="source", - title="The source or owner for the price information", - description="The source or owner that assigns the price to the medication.", - # if property is element of this resource. - element_property=True, - ) - source__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_source", title="Extension field for ``source``." - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="The category of the cost information", - description=( - "The category of the cost information. For example, manufacturers' " - "cost, patient cost, claim reimbursement cost, actual acquisition cost." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeCost`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "source", "cost"] - - -class MedicationKnowledgeDrugCharacteristic(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Specifies descriptive properties of the medicine. - Specifies descriptive properties of the medicine, such as color, shape, - imprints, etc. - """ - - resource_type = Field("MedicationKnowledgeDrugCharacteristic", const=True) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Code specifying the type of characteristic of medication", - description=( - "A code specifying which characteristic of the medicine is being " - "described (for example, colour, shape, imprint)." - ), - # if property is element of this resource. - element_property=True, - ) - - valueBase64Binary: fhirtypes.Base64Binary = Field( - None, - alias="valueBase64Binary", - title="Description of the characteristic", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueBase64Binary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valueBase64Binary", - title="Extension field for ``valueBase64Binary``.", - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="Description of the characteristic", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Description of the characteristic", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Description of the characteristic", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeDrugCharacteristic`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "valueCodeableConcept", - "valueString", - "valueQuantity", - "valueBase64Binary", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3976( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueBase64Binary", - "valueCodeableConcept", - "valueQuantity", - "valueString", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class MedicationKnowledgeIngredient(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Active or inactive ingredient. - Identifies a particular constituent of interest in the product. - """ - - resource_type = Field("MedicationKnowledgeIngredient", const=True) - - isActive: bool = Field( - None, - alias="isActive", - title="Active ingredient indicator", - description=( - "Indication of whether this ingredient affects the therapeutic action " - "of the drug." - ), - # if property is element of this resource. - element_property=True, - ) - isActive__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_isActive", title="Extension field for ``isActive``." - ) - - itemCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="itemCodeableConcept", - title="Medication(s) or substance(s) contained in the medication", - description=( - "The actual ingredient - either a substance (simple ingredient) or " - "another medication." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e item[x] - one_of_many="item", - one_of_many_required=True, - ) - - itemReference: fhirtypes.ReferenceType = Field( - None, - alias="itemReference", - title="Medication(s) or substance(s) contained in the medication", - description=( - "The actual ingredient - either a substance (simple ingredient) or " - "another medication." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e item[x] - one_of_many="item", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Substance"], - ) - - strength: fhirtypes.RatioType = Field( - None, - alias="strength", - title="Quantity of ingredient present", - description=( - "Specifies how many (or how much) of the items there are in this " - "Medication. For example, 250 mg per tablet. This is expressed as a " - "ratio where the numerator is 250mg and the denominator is 1 tablet." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeIngredient`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "itemCodeableConcept", - "itemReference", - "isActive", - "strength", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3175( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"item": ["itemCodeableConcept", "itemReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class MedicationKnowledgeKinetics(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The time course of drug absorption, distribution, metabolism and excretion - of a medication from the body. - """ - - resource_type = Field("MedicationKnowledgeKinetics", const=True) - - areaUnderCurve: typing.List[fhirtypes.QuantityType] = Field( - None, - alias="areaUnderCurve", - title="The drug concentration measured at certain discrete points in time", - description=None, - # if property is element of this resource. - element_property=True, - ) - - halfLifePeriod: fhirtypes.DurationType = Field( - None, - alias="halfLifePeriod", - title="Time required for concentration in the body to decrease by half", - description=( - "The time required for any specified property (e.g., the concentration " - "of a substance in the body) to decrease by half." - ), - # if property is element of this resource. - element_property=True, - ) - - lethalDose50: typing.List[fhirtypes.QuantityType] = Field( - None, - alias="lethalDose50", - title="The median lethal dose of a drug", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeKinetics`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "areaUnderCurve", - "lethalDose50", - "halfLifePeriod", - ] - - -class MedicationKnowledgeMedicineClassification(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Categorization of the medication within a formulary or classification - system. - """ - - resource_type = Field("MedicationKnowledgeMedicineClassification", const=True) - - classification: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="classification", - title="Specific category assigned to the medication", - description=( - "Specific category assigned to the medication (e.g. anti-infective, " - "anti-hypertensive, antibiotic, etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title=( - "The type of category for the medication (for example, therapeutic " - "classification, therapeutic sub-classification)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeMedicineClassification`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "classification"] - - -class MedicationKnowledgeMonitoringProgram(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Program under which a medication is reviewed. - The program under which the medication is reviewed. - """ - - resource_type = Field("MedicationKnowledgeMonitoringProgram", const=True) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name of the reviewing program", - description=None, - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of program under which the medication is monitored", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeMonitoringProgram`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "name"] - - -class MedicationKnowledgeMonograph(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Associated documentation about the medication. - """ - - resource_type = Field("MedicationKnowledgeMonograph", const=True) - - source: fhirtypes.ReferenceType = Field( - None, - alias="source", - title="Associated documentation about the medication", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference", "Media"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="The category of medication document", - description=( - "The category of documentation about the medication. (e.g. professional" - " monograph, patient education monograph)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeMonograph`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "source"] - - -class MedicationKnowledgePackaging(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Details about packaged medications. - Information that only applies to packages (not products). - """ - - resource_type = Field("MedicationKnowledgePackaging", const=True) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="The number of product units the package would contain if fully loaded", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title=( - "A code that defines the specific type of packaging that the medication" - " can be found in" - ), - description=( - "A code that defines the specific type of packaging that the medication" - " can be found in (e.g. blister sleeve, tube, bottle)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgePackaging`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "quantity"] - - -class MedicationKnowledgeRegulatory(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Regulatory information about a medication. - """ - - resource_type = Field("MedicationKnowledgeRegulatory", const=True) - - maxDispense: fhirtypes.MedicationKnowledgeRegulatoryMaxDispenseType = Field( - None, - alias="maxDispense", - title=( - "The maximum number of units of the medication that can be dispensed in" - " a period" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - regulatoryAuthority: fhirtypes.ReferenceType = Field( - ..., - alias="regulatoryAuthority", - title="Specifies the authority of the regulation", - description="The authority that is specifying the regulations.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - schedule: typing.List[fhirtypes.MedicationKnowledgeRegulatoryScheduleType] = Field( - None, - alias="schedule", - title="Specifies the schedule of a medication in jurisdiction", - description=None, - # if property is element of this resource. - element_property=True, - ) - - substitution: typing.List[ - fhirtypes.MedicationKnowledgeRegulatorySubstitutionType - ] = Field( - None, - alias="substitution", - title=( - "Specifies if changes are allowed when dispensing a medication from a " - "regulatory perspective" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeRegulatory`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "regulatoryAuthority", - "substitution", - "schedule", - "maxDispense", - ] - - -class MedicationKnowledgeRegulatoryMaxDispense(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The maximum number of units of the medication that can be dispensed in a - period. - """ - - resource_type = Field("MedicationKnowledgeRegulatoryMaxDispense", const=True) - - period: fhirtypes.DurationType = Field( - None, - alias="period", - title="The period that applies to the maximum number of units", - description=None, - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - ..., - alias="quantity", - title="The maximum number of units of the medication that can be dispensed", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeRegulatoryMaxDispense`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "quantity", "period"] - - -class MedicationKnowledgeRegulatorySchedule(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Specifies the schedule of a medication in jurisdiction. - """ - - resource_type = Field("MedicationKnowledgeRegulatorySchedule", const=True) - - schedule: fhirtypes.CodeableConceptType = Field( - ..., - alias="schedule", - title="Specifies the specific drug schedule", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeRegulatorySchedule`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "schedule"] - - -class MedicationKnowledgeRegulatorySubstitution(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Specifies if changes are allowed when dispensing a medication from a - regulatory perspective. - """ - - resource_type = Field("MedicationKnowledgeRegulatorySubstitution", const=True) - - allowed: bool = Field( - None, - alias="allowed", - title=( - "Specifies if regulation allows for changes in the medication when " - "dispensing" - ), - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - allowed__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_allowed", title="Extension field for ``allowed``." - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Specifies the type of substitution allowed", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeRegulatorySubstitution`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "allowed"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4515( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("allowed", "allowed__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class MedicationKnowledgeRelatedMedicationKnowledge(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Associated or related medication information. - Associated or related knowledge about a medication. - """ - - resource_type = Field("MedicationKnowledgeRelatedMedicationKnowledge", const=True) - - reference: typing.List[fhirtypes.ReferenceType] = Field( - ..., - alias="reference", - title="Associated documentation about the associated medication knowledge", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicationKnowledge"], - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Category of medicationKnowledge", - description="The category of the associated medication knowledge reference.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationKnowledgeRelatedMedicationKnowledge`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "reference"] diff --git a/fhir/resources/medicationrequest.py b/fhir/resources/medicationrequest.py deleted file mode 100644 index 829ae97f..00000000 --- a/fhir/resources/medicationrequest.py +++ /dev/null @@ -1,1019 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicationRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class MedicationRequest(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Ordering of medication for patient or group. - An order or request for both supply of the medication and the instructions - for administration of the medication to a patient. The resource is called - "MedicationRequest" rather than "MedicationPrescription" or - "MedicationOrder" to generalize the use across inpatient and outpatient - settings, including care plans, etc., and to harmonize with workflow - patterns. - """ - - resource_type = Field("MedicationRequest", const=True) - - authoredOn: fhirtypes.DateTime = Field( - None, - alias="authoredOn", - title="When request was initially authored", - description=( - "The date (and perhaps time) when the prescription was initially " - "written or authored on." - ), - # if property is element of this resource. - element_property=True, - ) - authoredOn__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_authoredOn", title="Extension field for ``authoredOn``." - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="What request fulfills", - description=( - "A plan or request that is fulfilled in whole or in part by this " - "medication request." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "CarePlan", - "MedicationRequest", - "ServiceRequest", - "ImmunizationRecommendation", - ], - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Type of medication usage", - description=( - "Indicates the type of medication request (for example, where the " - "medication is expected to be consumed or administered (i.e. inpatient " - "or outpatient))." - ), - # if property is element of this resource. - element_property=True, - ) - - courseOfTherapyType: fhirtypes.CodeableConceptType = Field( - None, - alias="courseOfTherapyType", - title="Overall pattern of medication administration", - description=( - "The description of the overall patte3rn of the administration of the " - "medication to the patient." - ), - # if property is element of this resource. - element_property=True, - ) - - detectedIssue: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="detectedIssue", - title="Clinical Issue with action", - description=( - "Indicates an actual or potential clinical issue with or between one or" - " more active or proposed clinical actions for a patient; e.g. Drug-" - "drug interaction, duplicate therapy, dosage alert etc." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DetectedIssue"], - ) - - dispenseRequest: fhirtypes.MedicationRequestDispenseRequestType = Field( - None, - alias="dispenseRequest", - title="Medication supply authorization", - description=( - "Indicates the specific details for the dispense or medication supply " - "part of a medication request (also known as a Medication Prescription " - "or Medication Order). Note that this information is not always sent " - "with the order. There may be in some settings (e.g. hospitals) " - "institutional or system support for completing the dispense details in" - " the pharmacy department." - ), - # if property is element of this resource. - element_property=True, - ) - - doNotPerform: bool = Field( - None, - alias="doNotPerform", - title="True if request is prohibiting action", - description=( - "If true indicates that the provider is asking for the medication " - "request not to occur." - ), - # if property is element of this resource. - element_property=True, - ) - doNotPerform__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_doNotPerform", title="Extension field for ``doNotPerform``." - ) - - dosageInstruction: typing.List[fhirtypes.DosageType] = Field( - None, - alias="dosageInstruction", - title="How the medication should be taken", - description="Indicates how the medication is to be used by the patient.", - # if property is element of this resource. - element_property=True, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter created as part of encounter/admission/stay", - description=( - "The Encounter during which this [x] was created or to which the " - "creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - eventHistory: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="eventHistory", - title="A list of events of interest in the lifecycle", - description=( - "Links to Provenance records for past versions of this resource or " - "fulfilling request or event resources that identify key state " - "transitions or updates that are likely to be relevant to a user " - "looking at the current version of the resource." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Provenance"], - ) - - groupIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="groupIdentifier", - title="Composite request this is part of", - description=( - "A shared identifier common to all requests that were authorized more " - "or less simultaneously by a single author, representing the identifier" - " of the requisition or prescription." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External ids for this request", - description=( - "Identifiers associated with this medication request that are defined " - "by business processes and/or used to refer to it when a direct URL " - "reference to the resource itself is not appropriate. They are business" - " identifiers assigned to this resource by the performer or other " - "systems and remain constant as the resource is updated and propagates " - "from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - instantiatesCanonical: typing.List[fhirtypes.Canonical] = Field( - None, - alias="instantiatesCanonical", - title="Instantiates FHIR protocol or definition", - description=( - "The URL pointing to a protocol, guideline, orderset, or other " - "definition that is adhered to in whole or in part by this " - "MedicationRequest." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesCanonical__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_instantiatesCanonical", - title="Extension field for ``instantiatesCanonical``.", - ) - - instantiatesUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiatesUri", - title="Instantiates external protocol or definition", - description=( - "The URL pointing to an externally maintained protocol, guideline, " - "orderset or other definition that is adhered to in whole or in part by" - " this MedicationRequest." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - insurance: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="insurance", - title="Associated insurance coverage", - description=( - "Insurance plans, coverage extensions, pre-authorizations and/or pre-" - "determinations that may be required for delivering the requested " - "service." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Coverage", "ClaimResponse"], - ) - - intent: fhirtypes.Code = Field( - None, - alias="intent", - title=( - "proposal | plan | order | original-order | reflex-order | filler-order" - " | instance-order | option" - ), - description="Whether the request is a proposal, plan, or an original order.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "proposal", - "plan", - "order", - "original-order", - "reflex-order", - "filler-order", - "instance-order", - "option", - ], - ) - intent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_intent", title="Extension field for ``intent``." - ) - - medicationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="medicationCodeableConcept", - title="Medication to be taken", - description=( - "Identifies the medication being requested. This is a link to a " - "resource that represents the medication which may be the details of " - "the medication or simply an attribute carrying a code that identifies " - "the medication from a known list of medications." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - ) - - medicationReference: fhirtypes.ReferenceType = Field( - None, - alias="medicationReference", - title="Medication to be taken", - description=( - "Identifies the medication being requested. This is a link to a " - "resource that represents the medication which may be the details of " - "the medication or simply an attribute carrying a code that identifies " - "the medication from a known list of medications." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Medication"], - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Information about the prescription", - description=( - "Extra information about the prescription that could not be conveyed by" - " the other attributes." - ), - # if property is element of this resource. - element_property=True, - ) - - performer: fhirtypes.ReferenceType = Field( - None, - alias="performer", - title="Intended performer of administration", - description=( - "The specified desired performer of the medication treatment (e.g. the " - "performer of the medication administration)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Patient", - "Device", - "RelatedPerson", - "CareTeam", - ], - ) - - performerType: fhirtypes.CodeableConceptType = Field( - None, - alias="performerType", - title="Desired kind of performer of the medication administration", - description=( - "Indicates the type of performer of the administration of the " - "medication." - ), - # if property is element of this resource. - element_property=True, - ) - - priorPrescription: fhirtypes.ReferenceType = Field( - None, - alias="priorPrescription", - title="An order/prescription that is being replaced", - description=( - "A link to a resource representing an earlier order related order or " - "prescription." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicationRequest"], - ) - - priority: fhirtypes.Code = Field( - None, - alias="priority", - title="routine | urgent | asap | stat", - description=( - "Indicates how quickly the Medication Request should be addressed with " - "respect to other requests." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["routine", "urgent", "asap", "stat"], - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Reason or indication for ordering or not ordering the medication", - description=( - "The reason or the indication for ordering or not ordering the " - "medication." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title=( - "Condition or observation that supports why the prescription is being " - "written" - ), - description="Condition or observation that supports why the medication was ordered.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition", "Observation"], - ) - - recorder: fhirtypes.ReferenceType = Field( - None, - alias="recorder", - title="Person who entered the request", - description=( - "The person who entered the order on behalf of another individual for " - "example in the case of a verbal or a telephone order." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - reportedBoolean: bool = Field( - None, - alias="reportedBoolean", - title="Reported rather than primary record", - description=( - "Indicates if this record was captured as a secondary 'reported' record" - " rather than as an original primary source-of-truth record. It may " - "also indicate the source of the report." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e reported[x] - one_of_many="reported", - one_of_many_required=False, - ) - reportedBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_reportedBoolean", title="Extension field for ``reportedBoolean``." - ) - - reportedReference: fhirtypes.ReferenceType = Field( - None, - alias="reportedReference", - title="Reported rather than primary record", - description=( - "Indicates if this record was captured as a secondary 'reported' record" - " rather than as an original primary source-of-truth record. It may " - "also indicate the source of the report." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e reported[x] - one_of_many="reported", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Organization", - ], - ) - - requester: fhirtypes.ReferenceType = Field( - None, - alias="requester", - title="Who/What requested the Request", - description=( - "The individual, organization, or device that initiated the request and" - " has responsibility for its activation." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Patient", - "RelatedPerson", - "Device", - ], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "active | on-hold | cancelled | completed | entered-in-error | stopped " - "| draft | unknown" - ), - description=( - "A code specifying the current state of the order. Generally, this " - "will be active or completed state." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "active", - "on-hold", - "cancelled", - "completed", - "entered-in-error", - "stopped", - "draft", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReason: fhirtypes.CodeableConceptType = Field( - None, - alias="statusReason", - title="Reason for current status", - description="Captures the reason for the current state of the MedicationRequest.", - # if property is element of this resource. - element_property=True, - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Who or group medication request is for", - description=( - "A link to a resource representing the person or set of individuals to " - "whom the medication will be given." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - substitution: fhirtypes.MedicationRequestSubstitutionType = Field( - None, - alias="substitution", - title="Any restrictions on medication substitution", - description=( - "Indicates whether or not substitution can or should be part of the " - "dispense. In some cases, substitution must happen, in other cases " - "substitution must not happen. This block explains the prescriber's " - "intent. If nothing is specified substitution may be done." - ), - # if property is element of this resource. - element_property=True, - ) - - supportingInformation: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingInformation", - title="Information to support ordering of the medication", - description=( - "Include additional information (for example, patient height and " - "weight) that supports the ordering of the medication." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationRequest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "statusReason", - "intent", - "category", - "priority", - "doNotPerform", - "reportedBoolean", - "reportedReference", - "medicationCodeableConcept", - "medicationReference", - "subject", - "encounter", - "supportingInformation", - "authoredOn", - "requester", - "performer", - "performerType", - "recorder", - "reasonCode", - "reasonReference", - "instantiatesCanonical", - "instantiatesUri", - "basedOn", - "groupIdentifier", - "courseOfTherapyType", - "insurance", - "note", - "dosageInstruction", - "dispenseRequest", - "substitution", - "priorPrescription", - "detectedIssue", - "eventHistory", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1959( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("intent", "intent__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1959( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "medication": ["medicationCodeableConcept", "medicationReference"], - "reported": ["reportedBoolean", "reportedReference"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class MedicationRequestDispenseRequest(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Medication supply authorization. - Indicates the specific details for the dispense or medication supply part - of a medication request (also known as a Medication Prescription or - Medication Order). Note that this information is not always sent with the - order. There may be in some settings (e.g. hospitals) institutional or - system support for completing the dispense details in the pharmacy - department. - """ - - resource_type = Field("MedicationRequestDispenseRequest", const=True) - - dispenseInterval: fhirtypes.DurationType = Field( - None, - alias="dispenseInterval", - title="Minimum period of time between dispenses", - description=( - "The minimum period of time that must occur between dispenses of the " - "medication." - ), - # if property is element of this resource. - element_property=True, - ) - - expectedSupplyDuration: fhirtypes.DurationType = Field( - None, - alias="expectedSupplyDuration", - title="Number of days supply per dispense", - description=( - "Identifies the period time over which the supplied product is expected" - " to be used, or the length of time the dispense is expected to last." - ), - # if property is element of this resource. - element_property=True, - ) - - initialFill: fhirtypes.MedicationRequestDispenseRequestInitialFillType = Field( - None, - alias="initialFill", - title="First fill details", - description=( - "Indicates the quantity or duration for the first dispense of the " - "medication." - ), - # if property is element of this resource. - element_property=True, - ) - - numberOfRepeatsAllowed: fhirtypes.UnsignedInt = Field( - None, - alias="numberOfRepeatsAllowed", - title="Number of refills authorized", - description=( - "An integer indicating the number of times, in addition to the original" - " dispense, (aka refills or repeats) that the patient can receive the " - "prescribed medication. Usage Notes: This integer does not include the " - "original order dispense. This means that if an order indicates " - 'dispense 30 tablets plus "3 repeats", then the order can be dispensed ' - "a total of 4 times and the patient can receive a total of 120 tablets." - " A prescriber may explicitly say that zero refills are permitted " - "after the initial dispense." - ), - # if property is element of this resource. - element_property=True, - ) - numberOfRepeatsAllowed__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_numberOfRepeatsAllowed", - title="Extension field for ``numberOfRepeatsAllowed``.", - ) - - performer: fhirtypes.ReferenceType = Field( - None, - alias="performer", - title="Intended dispenser", - description=( - "Indicates the intended dispensing Organization specified by the " - "prescriber." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Amount of medication to supply per dispense", - description="The amount that is to be dispensed for one fill.", - # if property is element of this resource. - element_property=True, - ) - - validityPeriod: fhirtypes.PeriodType = Field( - None, - alias="validityPeriod", - title="Time period supply is authorized for", - description=( - "This indicates the validity period of a prescription (stale dating the" - " Prescription)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationRequestDispenseRequest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "initialFill", - "dispenseInterval", - "validityPeriod", - "numberOfRepeatsAllowed", - "quantity", - "expectedSupplyDuration", - "performer", - ] - - -class MedicationRequestDispenseRequestInitialFill(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - First fill details. - Indicates the quantity or duration for the first dispense of the - medication. - """ - - resource_type = Field("MedicationRequestDispenseRequestInitialFill", const=True) - - duration: fhirtypes.DurationType = Field( - None, - alias="duration", - title="First fill duration", - description="The length of time that the first dispense is expected to last.", - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="First fill quantity", - description="The amount or quantity to provide as part of the first dispense.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationRequestDispenseRequestInitialFill`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "quantity", "duration"] - - -class MedicationRequestSubstitution(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Any restrictions on medication substitution. - Indicates whether or not substitution can or should be part of the - dispense. In some cases, substitution must happen, in other cases - substitution must not happen. This block explains the prescriber's intent. - If nothing is specified substitution may be done. - """ - - resource_type = Field("MedicationRequestSubstitution", const=True) - - allowedBoolean: bool = Field( - None, - alias="allowedBoolean", - title="Whether substitution is allowed or not", - description=( - "True if the prescriber allows a different drug to be dispensed from " - "what was prescribed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e allowed[x] - one_of_many="allowed", - one_of_many_required=True, - ) - allowedBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_allowedBoolean", title="Extension field for ``allowedBoolean``." - ) - - allowedCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="allowedCodeableConcept", - title="Whether substitution is allowed or not", - description=( - "True if the prescriber allows a different drug to be dispensed from " - "what was prescribed." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e allowed[x] - one_of_many="allowed", - one_of_many_required=True, - ) - - reason: fhirtypes.CodeableConceptType = Field( - None, - alias="reason", - title="Why should (not) substitution be made", - description=( - "Indicates the reason for the substitution, or why substitution must or" - " must not be performed." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationRequestSubstitution`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "allowedBoolean", - "allowedCodeableConcept", - "reason", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3262( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"allowed": ["allowedBoolean", "allowedCodeableConcept"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/medicationstatement.py b/fhir/resources/medicationstatement.py deleted file mode 100644 index 75eba7c4..00000000 --- a/fhir/resources/medicationstatement.py +++ /dev/null @@ -1,483 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicationStatement -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class MedicationStatement(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Record of medication being taken by a patient. - A record of a medication that is being consumed by a patient. A - MedicationStatement may indicate that the patient may be taking the - medication now or has taken the medication in the past or will be taking - the medication in the future. The source of this information can be the - patient, significant other (such as a family member or spouse), or a - clinician. A common scenario where this information is captured is during - the history taking process during a patient visit or stay. The medication - information may come from sources such as the patient's memory, from a - prescription bottle, or from a list of medications the patient, clinician - or other party maintains. - - The primary difference between a medication statement and a medication - administration is that the medication administration has complete - administration information and is based on actual administration - information from the person who administered the medication. A medication - statement is often, if not always, less specific. There is no required - date/time when the medication was administered, in fact we only know that a - source has reported the patient is taking this medication, where details - such as time, quantity, or rate or even medication product may be - incomplete or missing or less precise. As stated earlier, the medication - statement information may come from the patient's memory, from a - prescription bottle or from a list of medications the patient, clinician or - other party maintains. Medication administration is more formal and is not - missing detailed information. - """ - - resource_type = Field("MedicationStatement", const=True) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Fulfils plan, proposal or order", - description=( - "A plan, proposal or order that is fulfilled in whole or in part by " - "this event." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicationRequest", "CarePlan", "ServiceRequest"], - ) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Type of medication usage", - description=( - "Indicates where the medication is expected to be consumed or " - "administered." - ), - # if property is element of this resource. - element_property=True, - ) - - context: fhirtypes.ReferenceType = Field( - None, - alias="context", - title="Encounter / Episode associated with MedicationStatement", - description=( - "The encounter or episode of care that establishes the context for this" - " MedicationStatement." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter", "EpisodeOfCare"], - ) - - dateAsserted: fhirtypes.DateTime = Field( - None, - alias="dateAsserted", - title="When the statement was asserted?", - description=( - "The date when the medication statement was asserted by the information" - " source." - ), - # if property is element of this resource. - element_property=True, - ) - dateAsserted__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_dateAsserted", title="Extension field for ``dateAsserted``." - ) - - derivedFrom: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="derivedFrom", - title="Additional supporting information", - description=( - "Allows linking the MedicationStatement to the underlying " - "MedicationRequest, or to other information that supports or is used to" - " derive the MedicationStatement." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - dosage: typing.List[fhirtypes.DosageType] = Field( - None, - alias="dosage", - title="Details of how medication is/was taken or should be taken", - description="Indicates how the medication is/was or should be taken by the patient.", - # if property is element of this resource. - element_property=True, - ) - - effectiveDateTime: fhirtypes.DateTime = Field( - None, - alias="effectiveDateTime", - title="The date/time or interval when the medication is/was/will be taken", - description=( - "The interval of time during which it is being asserted that the " - "patient is/was/will be taking the medication (or was not taking, when " - "the MedicationStatement.taken element is No)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=False, - ) - effectiveDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_effectiveDateTime", - title="Extension field for ``effectiveDateTime``.", - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="The date/time or interval when the medication is/was/will be taken", - description=( - "The interval of time during which it is being asserted that the " - "patient is/was/will be taking the medication (or was not taking, when " - "the MedicationStatement.taken element is No)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=False, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External identifier", - description=( - "Identifiers associated with this Medication Statement that are defined" - " by business processes and/or used to refer to it when a direct URL " - "reference to the resource itself is not appropriate. They are business" - " identifiers assigned to this resource by the performer or other " - "systems and remain constant as the resource is updated and propagates " - "from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - informationSource: fhirtypes.ReferenceType = Field( - None, - alias="informationSource", - title=( - "Person or organization that provided the information about the taking " - "of this medication" - ), - description=( - "The person or organization that provided the information about the " - "taking of this medication. Note: Use derivedFrom when a " - "MedicationStatement is derived from other resources, e.g. Claim or " - "MedicationRequest." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Organization", - ], - ) - - medicationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="medicationCodeableConcept", - title="What medication was taken", - description=( - "Identifies the medication being administered. This is either a link to" - " a resource representing the details of the medication or a simple " - "attribute carrying a code that identifies the medication from a known " - "list of medications." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - ) - - medicationReference: fhirtypes.ReferenceType = Field( - None, - alias="medicationReference", - title="What medication was taken", - description=( - "Identifies the medication being administered. This is either a link to" - " a resource representing the details of the medication or a simple " - "attribute carrying a code that identifies the medication from a known " - "list of medications." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Medication"], - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Further information about the statement", - description=( - "Provides extra information about the medication statement that is not " - "conveyed by the other attributes." - ), - # if property is element of this resource. - element_property=True, - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Part of referenced event", - description="A larger event of which this particular event is a component or step.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "MedicationAdministration", - "MedicationDispense", - "MedicationStatement", - "Procedure", - "Observation", - ], - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Reason for why the medication is being/was taken", - description="A reason for why the medication is being/was taken.", - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title=( - "Condition or observation that supports why the medication is being/was" - " taken" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition", "Observation", "DiagnosticReport"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "active | completed | entered-in-error | intended | stopped | on-hold |" - " unknown | not-taken" - ), - description=( - "A code representing the patient or other source's judgment about the " - "state of the medication used that this statement is about. Generally," - " this will be active or completed." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "active", - "completed", - "entered-in-error", - "intended", - "stopped", - "on-hold", - "unknown", - "not-taken", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReason: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="statusReason", - title="Reason for current status", - description="Captures the reason for the current state of the MedicationStatement.", - # if property is element of this resource. - element_property=True, - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Who is/was taking the medication", - description="The person, animal or group who is/was taking the medication.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicationStatement`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "basedOn", - "partOf", - "status", - "statusReason", - "category", - "medicationCodeableConcept", - "medicationReference", - "subject", - "context", - "effectiveDateTime", - "effectivePeriod", - "dateAsserted", - "informationSource", - "derivedFrom", - "reasonCode", - "reasonReference", - "note", - "dosage", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2163( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2163( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "effective": ["effectiveDateTime", "effectivePeriod"], - "medication": ["medicationCodeableConcept", "medicationReference"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/medicinalproduct.py b/fhir/resources/medicinalproduct.py deleted file mode 100644 index e574ca64..00000000 --- a/fhir/resources/medicinalproduct.py +++ /dev/null @@ -1,809 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProduct -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class MedicinalProduct(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Detailed definition of a medicinal product, typically for uses other than - direct patient care (e.g. regulatory use). - """ - - resource_type = Field("MedicinalProduct", const=True) - - additionalMonitoringIndicator: fhirtypes.CodeableConceptType = Field( - None, - alias="additionalMonitoringIndicator", - title=( - "Whether the Medicinal Product is subject to additional monitoring for " - "regulatory reasons" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - attachedDocument: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="attachedDocument", - title="Supporting documentation, typically for regulatory submission", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - clinicalTrial: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="clinicalTrial", - title="Clinical trials or studies that this product is involved in", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ResearchStudy"], - ) - - combinedPharmaceuticalDoseForm: fhirtypes.CodeableConceptType = Field( - None, - alias="combinedPharmaceuticalDoseForm", - title=( - "The dose form for a single part product, or combined form of a " - "multiple part product" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="contact", - title="A product specific contact, person (in a role), or an organization", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization", "PractitionerRole"], - ) - - crossReference: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="crossReference", - title=( - "Reference to another product, e.g. for linking authorised to " - "investigational product" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - domain: fhirtypes.CodingType = Field( - None, - alias="domain", - title="If this medicine applies to human or veterinary uses", - description=None, - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier for this product. Could be an MPID", - description=None, - # if property is element of this resource. - element_property=True, - ) - - legalStatusOfSupply: fhirtypes.CodeableConceptType = Field( - None, - alias="legalStatusOfSupply", - title=( - "The legal status of supply of the medicinal product as classified by " - "the regulator" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - manufacturingBusinessOperation: typing.List[ - fhirtypes.MedicinalProductManufacturingBusinessOperationType - ] = Field( - None, - alias="manufacturingBusinessOperation", - title=( - "An operation applied to the product, for manufacturing or " - "adminsitrative purpose" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - marketingStatus: typing.List[fhirtypes.MarketingStatusType] = Field( - None, - alias="marketingStatus", - title=( - "Marketing status of the medicinal product, in contrast to marketing " - "authorizaton" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - masterFile: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="masterFile", - title=( - "A master file for to the medicinal product (e.g. Pharmacovigilance " - "System Master File)" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - name: typing.List[fhirtypes.MedicinalProductNameType] = Field( - ..., - alias="name", - title="The product's name, including full name and possibly coded parts", - description=None, - # if property is element of this resource. - element_property=True, - ) - - packagedMedicinalProduct: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="packagedMedicinalProduct", - title="Package representation for the product", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProductPackaged"], - ) - - paediatricUseIndicator: fhirtypes.CodeableConceptType = Field( - None, - alias="paediatricUseIndicator", - title="If authorised for use in children", - description=None, - # if property is element of this resource. - element_property=True, - ) - - pharmaceuticalProduct: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="pharmaceuticalProduct", - title="Pharmaceutical aspects of product", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProductPharmaceutical"], - ) - - productClassification: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="productClassification", - title="Allows the product to be classified by various systems", - description=None, - # if property is element of this resource. - element_property=True, - ) - - specialDesignation: typing.List[ - fhirtypes.MedicinalProductSpecialDesignationType - ] = Field( - None, - alias="specialDesignation", - title=( - "Indicates if the medicinal product has an orphan designation for the " - "treatment of a rare disease" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - specialMeasures: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="specialMeasures", - title=( - "Whether the Medicinal Product is subject to special measures for " - "regulatory reasons" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - specialMeasures__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_specialMeasures", title="Extension field for ``specialMeasures``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Regulatory type, e.g. Investigational or Authorized", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProduct`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "type", - "domain", - "combinedPharmaceuticalDoseForm", - "legalStatusOfSupply", - "additionalMonitoringIndicator", - "specialMeasures", - "paediatricUseIndicator", - "productClassification", - "marketingStatus", - "pharmaceuticalProduct", - "packagedMedicinalProduct", - "attachedDocument", - "masterFile", - "contact", - "clinicalTrial", - "name", - "crossReference", - "manufacturingBusinessOperation", - "specialDesignation", - ] - - -class MedicinalProductManufacturingBusinessOperation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An operation applied to the product, for manufacturing or adminsitrative - purpose. - """ - - resource_type = Field("MedicinalProductManufacturingBusinessOperation", const=True) - - authorisationReferenceNumber: fhirtypes.IdentifierType = Field( - None, - alias="authorisationReferenceNumber", - title="Regulatory authorization reference number", - description=None, - # if property is element of this resource. - element_property=True, - ) - - confidentialityIndicator: fhirtypes.CodeableConceptType = Field( - None, - alias="confidentialityIndicator", - title="To indicate if this proces is commercially confidential", - description=None, - # if property is element of this resource. - element_property=True, - ) - - effectiveDate: fhirtypes.DateTime = Field( - None, - alias="effectiveDate", - title="Regulatory authorization date", - description=None, - # if property is element of this resource. - element_property=True, - ) - effectiveDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_effectiveDate", title="Extension field for ``effectiveDate``." - ) - - manufacturer: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="manufacturer", - title="The manufacturer or establishment associated with the process", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - operationType: fhirtypes.CodeableConceptType = Field( - None, - alias="operationType", - title="The type of manufacturing operation", - description=None, - # if property is element of this resource. - element_property=True, - ) - - regulator: fhirtypes.ReferenceType = Field( - None, - alias="regulator", - title="A regulator which oversees the operation", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductManufacturingBusinessOperation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "operationType", - "authorisationReferenceNumber", - "effectiveDate", - "confidentialityIndicator", - "manufacturer", - "regulator", - ] - - -class MedicinalProductName(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The product's name, including full name and possibly coded parts. - """ - - resource_type = Field("MedicinalProductName", const=True) - - countryLanguage: typing.List[ - fhirtypes.MedicinalProductNameCountryLanguageType - ] = Field( - None, - alias="countryLanguage", - title="Country where the name applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - namePart: typing.List[fhirtypes.MedicinalProductNameNamePartType] = Field( - None, - alias="namePart", - title="Coding words or phrases of the name", - description=None, - # if property is element of this resource. - element_property=True, - ) - - productName: fhirtypes.String = Field( - None, - alias="productName", - title="The full product name", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - productName__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_productName", title="Extension field for ``productName``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductName`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "productName", - "namePart", - "countryLanguage", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2202( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("productName", "productName__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class MedicinalProductNameCountryLanguage(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Country where the name applies. - """ - - resource_type = Field("MedicinalProductNameCountryLanguage", const=True) - - country: fhirtypes.CodeableConceptType = Field( - ..., - alias="country", - title="Country code for where this name applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: fhirtypes.CodeableConceptType = Field( - None, - alias="jurisdiction", - title="Jurisdiction code for where this name applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - language: fhirtypes.CodeableConceptType = Field( - ..., - alias="language", - title="Language code for this name", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductNameCountryLanguage`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "country", - "jurisdiction", - "language", - ] - - -class MedicinalProductNameNamePart(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Coding words or phrases of the name. - """ - - resource_type = Field("MedicinalProductNameNamePart", const=True) - - part: fhirtypes.String = Field( - None, - alias="part", - title="A fragment of a product name", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - part__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_part", title="Extension field for ``part``." - ) - - type: fhirtypes.CodingType = Field( - ..., - alias="type", - title="Idenifying type for this part of the name (e.g. strength part)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductNameNamePart`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "part", "type"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3009( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("part", "part__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class MedicinalProductSpecialDesignation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Indicates if the medicinal product has an orphan designation for the - treatment of a rare disease. - """ - - resource_type = Field("MedicinalProductSpecialDesignation", const=True) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date when the designation was granted", - description=None, - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Identifier for the designation, or procedure number", - description=None, - # if property is element of this resource. - element_property=True, - ) - - indicationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="indicationCodeableConcept", - title="Condition for which the medicinal use applies", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e indication[x] - one_of_many="indication", - one_of_many_required=False, - ) - - indicationReference: fhirtypes.ReferenceType = Field( - None, - alias="indicationReference", - title="Condition for which the medicinal use applies", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e indication[x] - one_of_many="indication", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProductIndication"], - ) - - intendedUse: fhirtypes.CodeableConceptType = Field( - None, - alias="intendedUse", - title="The intended use of the product, e.g. prevention, treatment", - description=None, - # if property is element of this resource. - element_property=True, - ) - - species: fhirtypes.CodeableConceptType = Field( - None, - alias="species", - title="Animal species for which this applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.CodeableConceptType = Field( - None, - alias="status", - title="For example granted, pending, expired or withdrawn", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="The type of special designation, e.g. orphan drug, minor use", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductSpecialDesignation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "type", - "intendedUse", - "indicationCodeableConcept", - "indicationReference", - "status", - "date", - "species", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3672( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "indication": ["indicationCodeableConcept", "indicationReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/medicinalproductauthorization.py b/fhir/resources/medicinalproductauthorization.py deleted file mode 100644 index f5c7f39f..00000000 --- a/fhir/resources/medicinalproductauthorization.py +++ /dev/null @@ -1,447 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductAuthorization -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class MedicinalProductAuthorization(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The regulatory authorization of a medicinal product. - """ - - resource_type = Field("MedicinalProductAuthorization", const=True) - - country: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="country", - title="The country in which the marketing authorization has been granted", - description=None, - # if property is element of this resource. - element_property=True, - ) - - dataExclusivityPeriod: fhirtypes.PeriodType = Field( - None, - alias="dataExclusivityPeriod", - title=( - "A period of time after authorization before generic product " - "applicatiosn can be submitted" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - dateOfFirstAuthorization: fhirtypes.DateTime = Field( - None, - alias="dateOfFirstAuthorization", - title=( - "The date when the first authorization was granted by a Medicines " - "Regulatory Agency" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - dateOfFirstAuthorization__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_dateOfFirstAuthorization", - title="Extension field for ``dateOfFirstAuthorization``.", - ) - - holder: fhirtypes.ReferenceType = Field( - None, - alias="holder", - title="Marketing Authorization Holder", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title=( - "Business identifier for the marketing authorization, as assigned by a " - "regulator" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - internationalBirthDate: fhirtypes.DateTime = Field( - None, - alias="internationalBirthDate", - title=( - "Date of first marketing authorization for a company's new medicinal " - "product in any country in the World" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - internationalBirthDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_internationalBirthDate", - title="Extension field for ``internationalBirthDate``.", - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Jurisdiction within a country", - description=None, - # if property is element of this resource. - element_property=True, - ) - - jurisdictionalAuthorization: typing.List[ - fhirtypes.MedicinalProductAuthorizationJurisdictionalAuthorizationType - ] = Field( - None, - alias="jurisdictionalAuthorization", - title="Authorization in areas within a country", - description=None, - # if property is element of this resource. - element_property=True, - ) - - legalBasis: fhirtypes.CodeableConceptType = Field( - None, - alias="legalBasis", - title="The legal framework against which this authorization is granted", - description=None, - # if property is element of this resource. - element_property=True, - ) - - procedure: fhirtypes.MedicinalProductAuthorizationProcedureType = Field( - None, - alias="procedure", - title=( - "The regulatory procedure for granting or amending a marketing " - "authorization" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - regulator: fhirtypes.ReferenceType = Field( - None, - alias="regulator", - title="Medicines Regulatory Agency", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - restoreDate: fhirtypes.DateTime = Field( - None, - alias="restoreDate", - title=( - "The date when a suspended the marketing or the marketing authorization" - " of the product is anticipated to be restored" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - restoreDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_restoreDate", title="Extension field for ``restoreDate``." - ) - - status: fhirtypes.CodeableConceptType = Field( - None, - alias="status", - title="The status of the marketing authorization", - description=None, - # if property is element of this resource. - element_property=True, - ) - - statusDate: fhirtypes.DateTime = Field( - None, - alias="statusDate", - title="The date at which the given status has become applicable", - description=None, - # if property is element of this resource. - element_property=True, - ) - statusDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_statusDate", title="Extension field for ``statusDate``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="The medicinal product that is being authorized", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProduct", "MedicinalProductPackaged"], - ) - - validityPeriod: fhirtypes.PeriodType = Field( - None, - alias="validityPeriod", - title=( - "The beginning of the time period in which the marketing authorization " - "is in the specific status shall be specified A complete date " - "consisting of day, month and year shall be specified using the ISO " - "8601 date format" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductAuthorization`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "subject", - "country", - "jurisdiction", - "status", - "statusDate", - "restoreDate", - "validityPeriod", - "dataExclusivityPeriod", - "dateOfFirstAuthorization", - "internationalBirthDate", - "legalBasis", - "jurisdictionalAuthorization", - "holder", - "regulator", - "procedure", - ] - - -class MedicinalProductAuthorizationJurisdictionalAuthorization( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Authorization in areas within a country. - """ - - resource_type = Field( - "MedicinalProductAuthorizationJurisdictionalAuthorization", const=True - ) - - country: fhirtypes.CodeableConceptType = Field( - None, - alias="country", - title="Country of authorization", - description=None, - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="The assigned number for the marketing authorization", - description=None, - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Jurisdiction within a country", - description=None, - # if property is element of this resource. - element_property=True, - ) - - legalStatusOfSupply: fhirtypes.CodeableConceptType = Field( - None, - alias="legalStatusOfSupply", - title="The legal status of supply in a jurisdiction or region", - description=None, - # if property is element of this resource. - element_property=True, - ) - - validityPeriod: fhirtypes.PeriodType = Field( - None, - alias="validityPeriod", - title="The start and expected end date of the authorization", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductAuthorizationJurisdictionalAuthorization`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "country", - "jurisdiction", - "legalStatusOfSupply", - "validityPeriod", - ] - - -class MedicinalProductAuthorizationProcedure(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The regulatory procedure for granting or amending a marketing authorization. - """ - - resource_type = Field("MedicinalProductAuthorizationProcedure", const=True) - - application: typing.List[ - fhirtypes.MedicinalProductAuthorizationProcedureType - ] = Field( - None, - alias="application", - title="Applcations submitted to obtain a marketing authorization", - description=None, - # if property is element of this resource. - element_property=True, - ) - - dateDateTime: fhirtypes.DateTime = Field( - None, - alias="dateDateTime", - title="Date of procedure", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e date[x] - one_of_many="date", - one_of_many_required=False, - ) - dateDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_dateDateTime", title="Extension field for ``dateDateTime``." - ) - - datePeriod: fhirtypes.PeriodType = Field( - None, - alias="datePeriod", - title="Date of procedure", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e date[x] - one_of_many="date", - one_of_many_required=False, - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Identifier for this procedure", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Type of procedure", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductAuthorizationProcedure`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "type", - "datePeriod", - "dateDateTime", - "application", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4147( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"date": ["dateDateTime", "datePeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/medicinalproductcontraindication.py b/fhir/resources/medicinalproductcontraindication.py deleted file mode 100644 index 78f79cc6..00000000 --- a/fhir/resources/medicinalproductcontraindication.py +++ /dev/null @@ -1,243 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductContraindication -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class MedicinalProductContraindication(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - MedicinalProductContraindication. - The clinical particulars - indications, contraindications etc. of a - medicinal product, including for regulatory purposes. - """ - - resource_type = Field("MedicinalProductContraindication", const=True) - - comorbidity: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="comorbidity", - title="A comorbidity (concurrent condition) or coinfection", - description=None, - # if property is element of this resource. - element_property=True, - ) - - disease: fhirtypes.CodeableConceptType = Field( - None, - alias="disease", - title="The disease, symptom or procedure for the contraindication", - description=None, - # if property is element of this resource. - element_property=True, - ) - - diseaseStatus: fhirtypes.CodeableConceptType = Field( - None, - alias="diseaseStatus", - title="The status of the disease or symptom for the contraindication", - description=None, - # if property is element of this resource. - element_property=True, - ) - - otherTherapy: typing.List[ - fhirtypes.MedicinalProductContraindicationOtherTherapyType - ] = Field( - None, - alias="otherTherapy", - title=( - "Information about the use of the medicinal product in relation to " - "other therapies described as part of the indication" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - population: typing.List[fhirtypes.PopulationType] = Field( - None, - alias="population", - title="The population group to which this applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - subject: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="subject", - title="The medication for which this is an indication", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProduct", "Medication"], - ) - - therapeuticIndication: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="therapeuticIndication", - title=( - "Information about the use of the medicinal product in relation to " - "other therapies as part of the indication" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProductIndication"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductContraindication`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "subject", - "disease", - "diseaseStatus", - "comorbidity", - "therapeuticIndication", - "otherTherapy", - "population", - ] - - -class MedicinalProductContraindicationOtherTherapy(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about the use of the medicinal product in relation to other - therapies described as part of the indication. - """ - - resource_type = Field("MedicinalProductContraindicationOtherTherapy", const=True) - - medicationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="medicationCodeableConcept", - title=( - "Reference to a specific medication (active substance, medicinal " - "product or class of products) as part of an indication or " - "contraindication" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - ) - - medicationReference: fhirtypes.ReferenceType = Field( - None, - alias="medicationReference", - title=( - "Reference to a specific medication (active substance, medicinal " - "product or class of products) as part of an indication or " - "contraindication" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "MedicinalProduct", - "Medication", - "Substance", - "SubstanceSpecification", - ], - ) - - therapyRelationshipType: fhirtypes.CodeableConceptType = Field( - ..., - alias="therapyRelationshipType", - title=( - "The type of relationship between the medicinal product indication or " - "contraindication and another therapy" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductContraindicationOtherTherapy`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "therapyRelationshipType", - "medicationCodeableConcept", - "medicationReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4757( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "medication": ["medicationCodeableConcept", "medicationReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/medicinalproductindication.py b/fhir/resources/medicinalproductindication.py deleted file mode 100644 index 018fd112..00000000 --- a/fhir/resources/medicinalproductindication.py +++ /dev/null @@ -1,262 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductIndication -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class MedicinalProductIndication(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - MedicinalProductIndication. - Indication for the Medicinal Product. - """ - - resource_type = Field("MedicinalProductIndication", const=True) - - comorbidity: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="comorbidity", - title=( - "Comorbidity (concurrent condition) or co-infection as part of the " - "indication" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - diseaseStatus: fhirtypes.CodeableConceptType = Field( - None, - alias="diseaseStatus", - title="The status of the disease or symptom for which the indication applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - diseaseSymptomProcedure: fhirtypes.CodeableConceptType = Field( - None, - alias="diseaseSymptomProcedure", - title="The disease, symptom or procedure that is the indication for treatment", - description=None, - # if property is element of this resource. - element_property=True, - ) - - duration: fhirtypes.QuantityType = Field( - None, - alias="duration", - title="Timing or duration information as part of the indication", - description=None, - # if property is element of this resource. - element_property=True, - ) - - intendedEffect: fhirtypes.CodeableConceptType = Field( - None, - alias="intendedEffect", - title="The intended effect, aim or strategy to be achieved by the indication", - description=None, - # if property is element of this resource. - element_property=True, - ) - - otherTherapy: typing.List[ - fhirtypes.MedicinalProductIndicationOtherTherapyType - ] = Field( - None, - alias="otherTherapy", - title=( - "Information about the use of the medicinal product in relation to " - "other therapies described as part of the indication" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - population: typing.List[fhirtypes.PopulationType] = Field( - None, - alias="population", - title="The population group to which this applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - subject: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="subject", - title="The medication for which this is an indication", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProduct", "Medication"], - ) - - undesirableEffect: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="undesirableEffect", - title="Describe the undesirable effects of the medicinal product", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProductUndesirableEffect"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductIndication`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "subject", - "diseaseSymptomProcedure", - "diseaseStatus", - "comorbidity", - "intendedEffect", - "duration", - "otherTherapy", - "undesirableEffect", - "population", - ] - - -class MedicinalProductIndicationOtherTherapy(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about the use of the medicinal product in relation to other - therapies described as part of the indication. - """ - - resource_type = Field("MedicinalProductIndicationOtherTherapy", const=True) - - medicationCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="medicationCodeableConcept", - title=( - "Reference to a specific medication (active substance, medicinal " - "product or class of products) as part of an indication or " - "contraindication" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - ) - - medicationReference: fhirtypes.ReferenceType = Field( - None, - alias="medicationReference", - title=( - "Reference to a specific medication (active substance, medicinal " - "product or class of products) as part of an indication or " - "contraindication" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e medication[x] - one_of_many="medication", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "MedicinalProduct", - "Medication", - "Substance", - "SubstanceSpecification", - ], - ) - - therapyRelationshipType: fhirtypes.CodeableConceptType = Field( - ..., - alias="therapyRelationshipType", - title=( - "The type of relationship between the medicinal product indication or " - "contraindication and another therapy" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductIndicationOtherTherapy`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "therapyRelationshipType", - "medicationCodeableConcept", - "medicationReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4110( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "medication": ["medicationCodeableConcept", "medicationReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/medicinalproductingredient.py b/fhir/resources/medicinalproductingredient.py deleted file mode 100644 index be95b075..00000000 --- a/fhir/resources/medicinalproductingredient.py +++ /dev/null @@ -1,424 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductIngredient -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class MedicinalProductIngredient(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An ingredient of a manufactured item or pharmaceutical product. - """ - - resource_type = Field("MedicinalProductIngredient", const=True) - - allergenicIndicator: bool = Field( - None, - alias="allergenicIndicator", - title="If the ingredient is a known or suspected allergen", - description=None, - # if property is element of this resource. - element_property=True, - ) - allergenicIndicator__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_allergenicIndicator", - title="Extension field for ``allergenicIndicator``.", - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Identifier for the ingredient", - description=( - "The identifier(s) of this Ingredient that are assigned by business " - "processes and/or used to refer to it when a direct URL reference to " - "the resource itself is not appropriate." - ), - # if property is element of this resource. - element_property=True, - ) - - manufacturer: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="manufacturer", - title="Manufacturer of this Ingredient", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - role: fhirtypes.CodeableConceptType = Field( - ..., - alias="role", - title="Ingredient role e.g. Active ingredient, excipient", - description=None, - # if property is element of this resource. - element_property=True, - ) - - specifiedSubstance: typing.List[ - fhirtypes.MedicinalProductIngredientSpecifiedSubstanceType - ] = Field( - None, - alias="specifiedSubstance", - title="A specified substance that comprises this ingredient", - description=None, - # if property is element of this resource. - element_property=True, - ) - - substance: fhirtypes.MedicinalProductIngredientSubstanceType = Field( - None, - alias="substance", - title="The ingredient substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductIngredient`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "role", - "allergenicIndicator", - "manufacturer", - "specifiedSubstance", - "substance", - ] - - -class MedicinalProductIngredientSpecifiedSubstance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A specified substance that comprises this ingredient. - """ - - resource_type = Field("MedicinalProductIngredientSpecifiedSubstance", const=True) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="The specified substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - - confidentiality: fhirtypes.CodeableConceptType = Field( - None, - alias="confidentiality", - title="Confidentiality level of the specified substance as the ingredient", - description=None, - # if property is element of this resource. - element_property=True, - ) - - group: fhirtypes.CodeableConceptType = Field( - ..., - alias="group", - title="The group of specified substance, e.g. group 1 to 4", - description=None, - # if property is element of this resource. - element_property=True, - ) - - strength: typing.List[ - fhirtypes.MedicinalProductIngredientSpecifiedSubstanceStrengthType - ] = Field( - None, - alias="strength", - title=( - "Quantity of the substance or specified substance present in the " - "manufactured item or pharmaceutical product" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductIngredientSpecifiedSubstance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "group", - "confidentiality", - "strength", - ] - - -class MedicinalProductIngredientSpecifiedSubstanceStrength( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Quantity of the substance or specified substance present in the - manufactured item or pharmaceutical product. - """ - - resource_type = Field( - "MedicinalProductIngredientSpecifiedSubstanceStrength", const=True - ) - - concentration: fhirtypes.RatioType = Field( - None, - alias="concentration", - title="The strength per unitary volume (or mass)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - concentrationLowLimit: fhirtypes.RatioType = Field( - None, - alias="concentrationLowLimit", - title=( - "A lower limit for the strength per unitary volume (or mass), for when " - "there is a range. The concentration attribute then becomes the upper " - "limit" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - country: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="country", - title="The country or countries for which the strength range applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - measurementPoint: fhirtypes.String = Field( - None, - alias="measurementPoint", - title="For when strength is measured at a particular point or distance", - description=None, - # if property is element of this resource. - element_property=True, - ) - measurementPoint__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_measurementPoint", - title="Extension field for ``measurementPoint``.", - ) - - presentation: fhirtypes.RatioType = Field( - ..., - alias="presentation", - title=( - "The quantity of substance in the unit of presentation, or in the " - "volume (or mass) of the single pharmaceutical product or manufactured " - "item" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - presentationLowLimit: fhirtypes.RatioType = Field( - None, - alias="presentationLowLimit", - title=( - "A lower limit for the quantity of substance in the unit of " - "presentation. For use when there is a range of strengths, this is the " - "lower limit, with the presentation attribute becoming the upper limit" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - referenceStrength: typing.List[ - fhirtypes.MedicinalProductIngredientSpecifiedSubstanceStrengthReferenceStrengthType - ] = Field( - None, - alias="referenceStrength", - title="Strength expressed in terms of a reference substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductIngredientSpecifiedSubstanceStrength`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "presentation", - "presentationLowLimit", - "concentration", - "concentrationLowLimit", - "measurementPoint", - "country", - "referenceStrength", - ] - - -class MedicinalProductIngredientSpecifiedSubstanceStrengthReferenceStrength( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Strength expressed in terms of a reference substance. - """ - - resource_type = Field( - "MedicinalProductIngredientSpecifiedSubstanceStrengthReferenceStrength", - const=True, - ) - - country: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="country", - title="The country or countries for which the strength range applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - measurementPoint: fhirtypes.String = Field( - None, - alias="measurementPoint", - title="For when strength is measured at a particular point or distance", - description=None, - # if property is element of this resource. - element_property=True, - ) - measurementPoint__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_measurementPoint", - title="Extension field for ``measurementPoint``.", - ) - - strength: fhirtypes.RatioType = Field( - ..., - alias="strength", - title="Strength expressed in terms of a reference substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - - strengthLowLimit: fhirtypes.RatioType = Field( - None, - alias="strengthLowLimit", - title="Strength expressed in terms of a reference substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - - substance: fhirtypes.CodeableConceptType = Field( - None, - alias="substance", - title="Relevant reference substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductIngredientSpecifiedSubstanceStrengthReferenceStrength`` - according specification, with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "substance", - "strength", - "strengthLowLimit", - "measurementPoint", - "country", - ] - - -class MedicinalProductIngredientSubstance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The ingredient substance. - """ - - resource_type = Field("MedicinalProductIngredientSubstance", const=True) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="The ingredient substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - - strength: typing.List[ - fhirtypes.MedicinalProductIngredientSpecifiedSubstanceStrengthType - ] = Field( - None, - alias="strength", - title=( - "Quantity of the substance or specified substance present in the " - "manufactured item or pharmaceutical product" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductIngredientSubstance`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "strength"] diff --git a/fhir/resources/medicinalproductinteraction.py b/fhir/resources/medicinalproductinteraction.py deleted file mode 100644 index 2e190c3b..00000000 --- a/fhir/resources/medicinalproductinteraction.py +++ /dev/null @@ -1,220 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductInteraction -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class MedicinalProductInteraction(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - MedicinalProductInteraction. - The interactions of the medicinal product with other medicinal products, or - other forms of interactions. - """ - - resource_type = Field("MedicinalProductInteraction", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="The interaction described", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - effect: fhirtypes.CodeableConceptType = Field( - None, - alias="effect", - title=( - 'The effect of the interaction, for example "reduced gastric absorption' - ' of primary medication"' - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - incidence: fhirtypes.CodeableConceptType = Field( - None, - alias="incidence", - title="The incidence of the interaction, e.g. theoretical, observed", - description=None, - # if property is element of this resource. - element_property=True, - ) - - interactant: typing.List[ - fhirtypes.MedicinalProductInteractionInteractantType - ] = Field( - None, - alias="interactant", - title="The specific medication, food or laboratory test that interacts", - description=None, - # if property is element of this resource. - element_property=True, - ) - - management: fhirtypes.CodeableConceptType = Field( - None, - alias="management", - title="Actions for managing the interaction", - description=None, - # if property is element of this resource. - element_property=True, - ) - - subject: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="subject", - title="The medication for which this is a described interaction", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProduct", "Medication", "Substance"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title=( - "The type of the interaction e.g. drug-drug interaction, drug-food " - "interaction, drug-lab test interaction" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductInteraction`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "subject", - "description", - "interactant", - "type", - "effect", - "incidence", - "management", - ] - - -class MedicinalProductInteractionInteractant(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The specific medication, food or laboratory test that interacts. - """ - - resource_type = Field("MedicinalProductInteractionInteractant", const=True) - - itemCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="itemCodeableConcept", - title="The specific medication, food or laboratory test that interacts", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e item[x] - one_of_many="item", - one_of_many_required=True, - ) - - itemReference: fhirtypes.ReferenceType = Field( - None, - alias="itemReference", - title="The specific medication, food or laboratory test that interacts", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e item[x] - one_of_many="item", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "MedicinalProduct", - "Medication", - "Substance", - "ObservationDefinition", - ], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductInteractionInteractant`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "itemReference", - "itemCodeableConcept", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4133( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"item": ["itemCodeableConcept", "itemReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/medicinalproductmanufactured.py b/fhir/resources/medicinalproductmanufactured.py deleted file mode 100644 index 6122a17d..00000000 --- a/fhir/resources/medicinalproductmanufactured.py +++ /dev/null @@ -1,124 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductManufactured -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import domainresource, fhirtypes - - -class MedicinalProductManufactured(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The manufactured item as contained in the packaged medicinal product. - """ - - resource_type = Field("MedicinalProductManufactured", const=True) - - ingredient: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="ingredient", - title="Ingredient", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProductIngredient"], - ) - - manufacturedDoseForm: fhirtypes.CodeableConceptType = Field( - ..., - alias="manufacturedDoseForm", - title=( - "Dose form as manufactured and before any transformation into the " - "pharmaceutical product" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - manufacturer: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="manufacturer", - title=( - "Manufacturer of the item (Note that this should be named " - '"manufacturer" but it currently causes technical issues)' - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - otherCharacteristics: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="otherCharacteristics", - title="Other codeable characteristics", - description=None, - # if property is element of this resource. - element_property=True, - ) - - physicalCharacteristics: fhirtypes.ProdCharacteristicType = Field( - None, - alias="physicalCharacteristics", - title="Dimensions, color etc.", - description="Dimensions, color etc.", - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - ..., - alias="quantity", - title='The quantity or "count number" of the manufactured item', - description=None, - # if property is element of this resource. - element_property=True, - ) - - unitOfPresentation: fhirtypes.CodeableConceptType = Field( - None, - alias="unitOfPresentation", - title=( - "The \u201creal world\u201d units in which the quantity of the manufactured item " - "is described" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductManufactured`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "manufacturedDoseForm", - "unitOfPresentation", - "quantity", - "manufacturer", - "ingredient", - "physicalCharacteristics", - "otherCharacteristics", - ] diff --git a/fhir/resources/medicinalproductpackaged.py b/fhir/resources/medicinalproductpackaged.py deleted file mode 100644 index 48352f7b..00000000 --- a/fhir/resources/medicinalproductpackaged.py +++ /dev/null @@ -1,347 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductPackaged -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class MedicinalProductPackaged(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A medicinal product in a container or package. - """ - - resource_type = Field("MedicinalProductPackaged", const=True) - - batchIdentifier: typing.List[ - fhirtypes.MedicinalProductPackagedBatchIdentifierType - ] = Field( - None, - alias="batchIdentifier", - title="Batch numbering", - description=None, - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Textual description", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Unique identifier", - description=None, - # if property is element of this resource. - element_property=True, - ) - - legalStatusOfSupply: fhirtypes.CodeableConceptType = Field( - None, - alias="legalStatusOfSupply", - title=( - "The legal status of supply of the medicinal product as classified by " - "the regulator" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - manufacturer: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="manufacturer", - title="Manufacturer of this Package Item", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - marketingAuthorization: fhirtypes.ReferenceType = Field( - None, - alias="marketingAuthorization", - title="Manufacturer of this Package Item", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProductAuthorization"], - ) - - marketingStatus: typing.List[fhirtypes.MarketingStatusType] = Field( - None, - alias="marketingStatus", - title="Marketing information", - description=None, - # if property is element of this resource. - element_property=True, - ) - - packageItem: typing.List[fhirtypes.MedicinalProductPackagedPackageItemType] = Field( - ..., - alias="packageItem", - title=( - "A packaging item, as a contained for medicine, possibly with other " - "packaging items within" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - subject: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="subject", - title="The product with this is a pack for", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProduct"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductPackaged`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "subject", - "description", - "legalStatusOfSupply", - "marketingStatus", - "marketingAuthorization", - "manufacturer", - "batchIdentifier", - "packageItem", - ] - - -class MedicinalProductPackagedBatchIdentifier(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Batch numbering. - """ - - resource_type = Field("MedicinalProductPackagedBatchIdentifier", const=True) - - immediatePackaging: fhirtypes.IdentifierType = Field( - None, - alias="immediatePackaging", - title=( - "A number appearing on the immediate packaging (and not the outer " - "packaging)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - outerPackaging: fhirtypes.IdentifierType = Field( - ..., - alias="outerPackaging", - title="A number appearing on the outer packaging of a specific batch", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductPackagedBatchIdentifier`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "outerPackaging", - "immediatePackaging", - ] - - -class MedicinalProductPackagedPackageItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A packaging item, as a contained for medicine, possibly with other - packaging items within. - """ - - resource_type = Field("MedicinalProductPackagedPackageItem", const=True) - - alternateMaterial: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="alternateMaterial", - title="A possible alternate material for the packaging", - description=None, - # if property is element of this resource. - element_property=True, - ) - - device: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="device", - title="A device accompanying a medicinal product", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DeviceDefinition"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Including possibly Data Carrier Identifier", - description=None, - # if property is element of this resource. - element_property=True, - ) - - manufacturedItem: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="manufacturedItem", - title="The manufactured item as contained in the packaged medicinal product", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProductManufactured"], - ) - - manufacturer: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="manufacturer", - title="Manufacturer of this Package Item", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - material: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="material", - title="Material type of the package item", - description=None, - # if property is element of this resource. - element_property=True, - ) - - otherCharacteristics: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="otherCharacteristics", - title="Other codeable characteristics", - description=None, - # if property is element of this resource. - element_property=True, - ) - - packageItem: typing.List[fhirtypes.MedicinalProductPackagedPackageItemType] = Field( - None, - alias="packageItem", - title="Allows containers within containers", - description=None, - # if property is element of this resource. - element_property=True, - ) - - physicalCharacteristics: fhirtypes.ProdCharacteristicType = Field( - None, - alias="physicalCharacteristics", - title="Dimensions, color etc.", - description="Dimensions, color etc.", - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - ..., - alias="quantity", - title=( - "The quantity of this package in the medicinal product, at the current " - "level of packaging. The outermost is always 1" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - shelfLifeStorage: typing.List[fhirtypes.ProductShelfLifeType] = Field( - None, - alias="shelfLifeStorage", - title="Shelf Life and storage information", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="The physical type of the container of the medicine", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductPackagedPackageItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "type", - "quantity", - "material", - "alternateMaterial", - "device", - "manufacturedItem", - "packageItem", - "physicalCharacteristics", - "otherCharacteristics", - "shelfLifeStorage", - "manufacturer", - ] diff --git a/fhir/resources/medicinalproductpharmaceutical.py b/fhir/resources/medicinalproductpharmaceutical.py deleted file mode 100644 index 5ddf13de..00000000 --- a/fhir/resources/medicinalproductpharmaceutical.py +++ /dev/null @@ -1,392 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductPharmaceutical -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class MedicinalProductPharmaceutical(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A pharmaceutical product described in terms of its composition and dose - form. - """ - - resource_type = Field("MedicinalProductPharmaceutical", const=True) - - administrableDoseForm: fhirtypes.CodeableConceptType = Field( - ..., - alias="administrableDoseForm", - title="The administrable dose form, after necessary reconstitution", - description=None, - # if property is element of this resource. - element_property=True, - ) - - characteristics: typing.List[ - fhirtypes.MedicinalProductPharmaceuticalCharacteristicsType - ] = Field( - None, - alias="characteristics", - title="Characteristics e.g. a products onset of action", - description=None, - # if property is element of this resource. - element_property=True, - ) - - device: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="device", - title="Accompanying device", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DeviceDefinition"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="An identifier for the pharmaceutical medicinal product", - description=None, - # if property is element of this resource. - element_property=True, - ) - - ingredient: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="ingredient", - title="Ingredient", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProductIngredient"], - ) - - routeOfAdministration: typing.List[ - fhirtypes.MedicinalProductPharmaceuticalRouteOfAdministrationType - ] = Field( - ..., - alias="routeOfAdministration", - title=( - "The path by which the pharmaceutical product is taken into or makes " - "contact with the body" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - unitOfPresentation: fhirtypes.CodeableConceptType = Field( - None, - alias="unitOfPresentation", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductPharmaceutical`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "administrableDoseForm", - "unitOfPresentation", - "ingredient", - "device", - "characteristics", - "routeOfAdministration", - ] - - -class MedicinalProductPharmaceuticalCharacteristics(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Characteristics e.g. a products onset of action. - """ - - resource_type = Field("MedicinalProductPharmaceuticalCharacteristics", const=True) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="A coded characteristic", - description=None, - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.CodeableConceptType = Field( - None, - alias="status", - title="The status of characteristic e.g. assigned or pending", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductPharmaceuticalCharacteristics`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "status"] - - -class MedicinalProductPharmaceuticalRouteOfAdministration( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The path by which the pharmaceutical product is taken into or makes contact - with the body. - """ - - resource_type = Field( - "MedicinalProductPharmaceuticalRouteOfAdministration", const=True - ) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Coded expression for the route", - description=None, - # if property is element of this resource. - element_property=True, - ) - - firstDose: fhirtypes.QuantityType = Field( - None, - alias="firstDose", - title=( - "The first dose (dose quantity) administered in humans can be " - "specified, for a product under investigation, using a numerical value " - "and its unit of measurement" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - maxDosePerDay: fhirtypes.QuantityType = Field( - None, - alias="maxDosePerDay", - title=( - "The maximum dose per day (maximum dose quantity to be administered in " - "any one 24-h period) that can be administered as per the protocol " - "referenced in the clinical trial authorisation" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - maxDosePerTreatmentPeriod: fhirtypes.RatioType = Field( - None, - alias="maxDosePerTreatmentPeriod", - title=( - "The maximum dose per treatment period that can be administered as per " - "the protocol referenced in the clinical trial authorisation" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - maxSingleDose: fhirtypes.QuantityType = Field( - None, - alias="maxSingleDose", - title=( - "The maximum single dose that can be administered as per the protocol " - "of a clinical trial can be specified using a numerical value and its " - "unit of measurement" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - maxTreatmentPeriod: fhirtypes.DurationType = Field( - None, - alias="maxTreatmentPeriod", - title=( - "The maximum treatment period during which an Investigational Medicinal" - " Product can be administered as per the protocol referenced in the " - "clinical trial authorisation" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - targetSpecies: typing.List[ - fhirtypes.MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesType - ] = Field( - None, - alias="targetSpecies", - title="A species for which this route applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductPharmaceuticalRouteOfAdministration`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "firstDose", - "maxSingleDose", - "maxDosePerDay", - "maxDosePerTreatmentPeriod", - "maxTreatmentPeriod", - "targetSpecies", - ] - - -class MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpecies( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A species for which this route applies. - """ - - resource_type = Field( - "MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpecies", const=True - ) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Coded expression for the species", - description=None, - # if property is element of this resource. - element_property=True, - ) - - withdrawalPeriod: typing.List[ - fhirtypes.MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesWithdrawalPeriodType # noqa: B950 - ] = Field( - None, - alias="withdrawalPeriod", - title=( - "A species specific time during which consumption of animal product is " - "not appropriate" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpecies`` - according specification, with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "withdrawalPeriod"] - - -class MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesWithdrawalPeriod( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A species specific time during which consumption of animal product is not - appropriate. - """ - - resource_type = Field( - "MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesWithdrawalPeriod", - const=True, - ) - - supportingInformation: fhirtypes.String = Field( - None, - alias="supportingInformation", - title="Extra information about the withdrawal period", - description=None, - # if property is element of this resource. - element_property=True, - ) - supportingInformation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_supportingInformation", - title="Extension field for ``supportingInformation``.", - ) - - tissue: fhirtypes.CodeableConceptType = Field( - ..., - alias="tissue", - title=( - "Coded expression for the type of tissue for which the withdrawal " - "period applues, e.g. meat, milk" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.QuantityType = Field( - ..., - alias="value", - title="A value for the time", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductPharmaceuticalRouteOfAdministrationTargetSpeciesWithdrawalPeriod`` - according specification, with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "tissue", - "value", - "supportingInformation", - ] diff --git a/fhir/resources/medicinalproductundesirableeffect.py b/fhir/resources/medicinalproductundesirableeffect.py deleted file mode 100644 index 60037995..00000000 --- a/fhir/resources/medicinalproductundesirableeffect.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductUndesirableEffect -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import domainresource, fhirtypes - - -class MedicinalProductUndesirableEffect(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - MedicinalProductUndesirableEffect. - Describe the undesirable effects of the medicinal product. - """ - - resource_type = Field("MedicinalProductUndesirableEffect", const=True) - - classification: fhirtypes.CodeableConceptType = Field( - None, - alias="classification", - title="Classification of the effect", - description=None, - # if property is element of this resource. - element_property=True, - ) - - frequencyOfOccurrence: fhirtypes.CodeableConceptType = Field( - None, - alias="frequencyOfOccurrence", - title="The frequency of occurrence of the effect", - description=None, - # if property is element of this resource. - element_property=True, - ) - - population: typing.List[fhirtypes.PopulationType] = Field( - None, - alias="population", - title="The population group to which this applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - subject: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="subject", - title="The medication for which this is an indication", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MedicinalProduct", "Medication"], - ) - - symptomConditionEffect: fhirtypes.CodeableConceptType = Field( - None, - alias="symptomConditionEffect", - title="The symptom, condition or undesirable effect", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MedicinalProductUndesirableEffect`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "subject", - "symptomConditionEffect", - "classification", - "frequencyOfOccurrence", - "population", - ] diff --git a/fhir/resources/messagedefinition.py b/fhir/resources/messagedefinition.py deleted file mode 100644 index f73e4b51..00000000 --- a/fhir/resources/messagedefinition.py +++ /dev/null @@ -1,813 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MessageDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class MessageDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A resource that defines a type of message that can be exchanged between - systems. - Defines the characteristics of a message that can be shared between - systems, including the type of event that initiates the message, the - content to be transmitted and what response(s), if any, are permitted. - """ - - resource_type = Field("MessageDefinition", const=True) - - allowedResponse: typing.List[ - fhirtypes.MessageDefinitionAllowedResponseType - ] = Field( - None, - alias="allowedResponse", - title="Responses to this message", - description=( - "Indicates what types of messages may be sent as an application-level " - "response to this message." - ), - # if property is element of this resource. - element_property=True, - ) - - base: fhirtypes.Canonical = Field( - None, - alias="base", - title="Definition this one is based on", - description=( - "The MessageDefinition that is the basis for the contents of this " - "resource." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MessageDefinition"], - ) - base__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_base", title="Extension field for ``base``." - ) - - category: fhirtypes.Code = Field( - None, - alias="category", - title="consequence | currency | notification", - description="The impact of the content of the message.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["consequence", "currency", "notification"], - ) - category__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_category", title="Extension field for ``category``." - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the message definition and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the message definition." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the message definition was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the message definition changes." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the message definition", - description=( - "A free text natural language description of the message definition " - "from a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - eventCoding: fhirtypes.CodingType = Field( - None, - alias="eventCoding", - title="Event code or link to the EventDefinition", - description="Event code or link to the EventDefinition.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e event[x] - one_of_many="event", - one_of_many_required=True, - ) - - eventUri: fhirtypes.Uri = Field( - None, - alias="eventUri", - title="Event code or link to the EventDefinition", - description="Event code or link to the EventDefinition.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e event[x] - one_of_many="event", - one_of_many_required=True, - ) - eventUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_eventUri", title="Extension field for ``eventUri``." - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this message definition is authored " - "for testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - focus: typing.List[fhirtypes.MessageDefinitionFocusType] = Field( - None, - alias="focus", - title="Resource(s) that are the subject of the event", - description=( - "Identifies the resource (or resources) that are being addressed by the" - " event. For example, the Encounter for an admit message or two " - "Account records for a merge." - ), - # if property is element of this resource. - element_property=True, - ) - - graph: typing.List[fhirtypes.Canonical] = Field( - None, - alias="graph", - title="Canonical reference to a GraphDefinition", - description=( - "Canonical reference to a GraphDefinition. If a URL is provided, it is " - "the canonical reference to a [GraphDefinition](graphdefinition.html) " - "that it controls what resources are to be added to the bundle when " - "building the document. The GraphDefinition can also specify profiles " - "that apply to the various resources." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["GraphDefinition"], - ) - graph__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_graph", title="Extension field for ``graph``.") - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Primary key for the message definition on a given server", - description=( - "A formal identifier that is used to identify this message definition " - "when it is represented in other formats, or referenced in a " - "specification, model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for message definition (if applicable)", - description=( - "A legal or geographic region in which the message definition is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this message definition (computer friendly)", - description=( - "A natural language name identifying the message definition. This name " - "should be usable as an identifier for the module by machine processing" - " applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - parent: typing.List[fhirtypes.Canonical] = Field( - None, - alias="parent", - title="Protocol/workflow this is part of", - description=( - "Identifies a protocol or workflow that this MessageDefinition " - "represents a step in." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ActivityDefinition", "PlanDefinition"], - ) - parent__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_parent", title="Extension field for ``parent``.") - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the message " - "definition." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this message definition is defined", - description=( - "Explanation of why this message definition is needed and why it has " - "been designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - replaces: typing.List[fhirtypes.Canonical] = Field( - None, - alias="replaces", - title="Takes the place of", - description="A MessageDefinition that is superseded by this definition.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MessageDefinition"], - ) - replaces__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_replaces", title="Extension field for ``replaces``.") - - responseRequired: fhirtypes.Code = Field( - None, - alias="responseRequired", - title="always | on-error | never | on-success", - description=( - "Declare at a message definition level whether a response is required " - "or only upon error or success, or never." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["always", "on-error", "never", "on-success"], - ) - responseRequired__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_responseRequired", - title="Extension field for ``responseRequired``.", - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this message definition. Enables tracking the life-cycle" - " of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this message definition (human friendly)", - description="A short, descriptive, user-friendly title for the message definition.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title="Business Identifier for a given MessageDefinition", - description=( - "The business identifier that is used to reference the " - "MessageDefinition and *is* expected to be consistent from server to " - "server." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate message definition instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the message definition", - description=( - "The identifier that is used to identify this version of the message " - "definition when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the message definition" - " author and is not expected to be globally unique. For example, it " - "might be a timestamp (e.g. yyyymmdd) if a managed version is not " - "available. There is also no expectation that versions can be placed in" - " a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MessageDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "replaces", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "copyright", - "base", - "parent", - "eventCoding", - "eventUri", - "category", - "focus", - "responseRequired", - "allowedResponse", - "graph", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1929( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("date", "date__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1929( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"event": ["eventCoding", "eventUri"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class MessageDefinitionAllowedResponse(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Responses to this message. - Indicates what types of messages may be sent as an application-level - response to this message. - """ - - resource_type = Field("MessageDefinitionAllowedResponse", const=True) - - message: fhirtypes.Canonical = Field( - None, - alias="message", - title="Reference to allowed message definition response", - description=( - "A reference to the message definition that must be adhered to by this " - "supported response." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MessageDefinition"], - ) - message__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_message", title="Extension field for ``message``." - ) - - situation: fhirtypes.Markdown = Field( - None, - alias="situation", - title="When should this response be used", - description=( - "Provides a description of the circumstances in which this response " - "should be used (as opposed to one of the alternative responses)." - ), - # if property is element of this resource. - element_property=True, - ) - situation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_situation", title="Extension field for ``situation``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MessageDefinitionAllowedResponse`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "message", "situation"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3479( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("message", "message__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class MessageDefinitionFocus(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Resource(s) that are the subject of the event. - Identifies the resource (or resources) that are being addressed by the - event. For example, the Encounter for an admit message or two Account - records for a merge. - """ - - resource_type = Field("MessageDefinitionFocus", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Type of resource", - description="The kind of resource that must be the focus for this message.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - max: fhirtypes.String = Field( - None, - alias="max", - title="Maximum number of focuses of this type", - description=( - "Identifies the maximum number of resources of this type that must be " - "pointed to by a message in order for it to be valid against this " - "MessageDefinition." - ), - # if property is element of this resource. - element_property=True, - ) - max__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_max", title="Extension field for ``max``." - ) - - min: fhirtypes.UnsignedInt = Field( - None, - alias="min", - title="Minimum number of focuses of this type", - description=( - "Identifies the minimum number of resources of this type that must be " - "pointed to by a message in order for it to be valid against this " - "MessageDefinition." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - min__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_min", title="Extension field for ``min``." - ) - - profile: fhirtypes.Canonical = Field( - None, - alias="profile", - title="Profile that must be adhered to by focus", - description=( - "A profile that reflects constraints for the focal resource (and " - "potentially for related resources)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - profile__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_profile", title="Extension field for ``profile``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MessageDefinitionFocus`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "profile", "min", "max"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2446( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext"), ("min", "min__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/messageheader.py b/fhir/resources/messageheader.py deleted file mode 100644 index c0683e5b..00000000 --- a/fhir/resources/messageheader.py +++ /dev/null @@ -1,683 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MessageHeader -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class MessageHeader(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A resource that describes a message that is exchanged between systems. - The header for a message exchange that is either requesting or responding - to an action. The reference(s) that are the subject of the action as well - as other information related to the action are typically transmitted in a - bundle in which the MessageHeader resource instance is the first resource - in the bundle. - """ - - resource_type = Field("MessageHeader", const=True) - - author: fhirtypes.ReferenceType = Field( - None, - alias="author", - title="The source of the decision", - description=( - "The logical author of the message - the person or device that decided " - "the described event should happen. When there is more than one " - "candidate, pick the most proximal to the MessageHeader. Can provide " - "other authors in extensions." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - definition: fhirtypes.Canonical = Field( - None, - alias="definition", - title="Link to the definition for this message", - description="Permanent link to the MessageDefinition for this message.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MessageDefinition"], - ) - definition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_definition", title="Extension field for ``definition``." - ) - - destination: typing.List[fhirtypes.MessageHeaderDestinationType] = Field( - None, - alias="destination", - title="Message destination application(s)", - description="The destination application which the message is intended for.", - # if property is element of this resource. - element_property=True, - ) - - enterer: fhirtypes.ReferenceType = Field( - None, - alias="enterer", - title="The source of the data entry", - description=( - "The person or device that performed the data entry leading to this " - "message. When there is more than one candidate, pick the most proximal" - " to the message. Can provide other enterers in extensions." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - eventCoding: fhirtypes.CodingType = Field( - None, - alias="eventCoding", - title="Code for the event this message represents or link to event definition", - description=( - "Code that identifies the event this message represents and connects it" - " with its definition. Events defined as part of the FHIR specification" - ' have the system value "http://terminology.hl7.org/CodeSystem/message-' - 'events". Alternatively uri to the EventDefinition.' - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e event[x] - one_of_many="event", - one_of_many_required=True, - ) - - eventUri: fhirtypes.Uri = Field( - None, - alias="eventUri", - title="Code for the event this message represents or link to event definition", - description=( - "Code that identifies the event this message represents and connects it" - " with its definition. Events defined as part of the FHIR specification" - ' have the system value "http://terminology.hl7.org/CodeSystem/message-' - 'events". Alternatively uri to the EventDefinition.' - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e event[x] - one_of_many="event", - one_of_many_required=True, - ) - eventUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_eventUri", title="Extension field for ``eventUri``." - ) - - focus: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="focus", - title="The actual content of the message", - description=( - "The actual data of the message - a reference to the root/focus class " - "of the event." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - reason: fhirtypes.CodeableConceptType = Field( - None, - alias="reason", - title="Cause of event", - description=( - "Coded indication of the cause for the event - indicates a reason for " - "the occurrence of the event that is a focus of this message." - ), - # if property is element of this resource. - element_property=True, - ) - - response: fhirtypes.MessageHeaderResponseType = Field( - None, - alias="response", - title="If this is a reply to prior message", - description=( - "Information about the message that this message is a response to. " - "Only present if this message is a response." - ), - # if property is element of this resource. - element_property=True, - ) - - responsible: fhirtypes.ReferenceType = Field( - None, - alias="responsible", - title="Final responsibility for event", - description=( - "The person or organization that accepts overall responsibility for the" - " contents of the message. The implication is that the message event " - "happened under the policies of the responsible party." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - sender: fhirtypes.ReferenceType = Field( - None, - alias="sender", - title="Real world sender of the message", - description=( - "Identifies the sending system to allow the use of a trust " "relationship." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - source: fhirtypes.MessageHeaderSourceType = Field( - ..., - alias="source", - title="Message source application", - description="The source application from which this message originated.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MessageHeader`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "eventCoding", - "eventUri", - "destination", - "sender", - "enterer", - "author", - "source", - "responsible", - "reason", - "response", - "focus", - "definition", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1485( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"event": ["eventCoding", "eventUri"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class MessageHeaderDestination(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Message destination application(s). - The destination application which the message is intended for. - """ - - resource_type = Field("MessageHeaderDestination", const=True) - - endpoint: fhirtypes.Url = Field( - None, - alias="endpoint", - title="Actual destination address or id", - description="Indicates where the message should be routed to.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - endpoint__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_endpoint", title="Extension field for ``endpoint``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name of system", - description="Human-readable name for the target system.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - receiver: fhirtypes.ReferenceType = Field( - None, - alias="receiver", - title='Intended "real-world" recipient for the data', - description=( - "Allows data conveyed by a message to be addressed to a particular " - "person or department when routing to a specific application isn't " - "sufficient." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - target: fhirtypes.ReferenceType = Field( - None, - alias="target", - title="Particular delivery destination within the destination", - description=( - "Identifies the target end system in situations where the initial " - "message transmission is to an intermediary system." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MessageHeaderDestination`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "target", - "endpoint", - "receiver", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2635( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("endpoint", "endpoint__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class MessageHeaderResponse(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - If this is a reply to prior message. - Information about the message that this message is a response to. Only - present if this message is a response. - """ - - resource_type = Field("MessageHeaderResponse", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="ok | transient-error | fatal-error", - description=( - "Code that identifies the type of response to the message - whether it " - "was successful or not, and whether it should be resent or not." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["ok", "transient-error", "fatal-error"], - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - details: fhirtypes.ReferenceType = Field( - None, - alias="details", - title="Specific list of hints/warnings/errors", - description="Full details of any issues found in the message.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["OperationOutcome"], - ) - - identifier: fhirtypes.Id = Field( - None, - alias="identifier", - title="Id of original message", - description=( - "The MessageHeader.id of the message to which this message is a " - "response." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - identifier__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_identifier", title="Extension field for ``identifier``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MessageHeaderResponse`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "identifier", "code", "details"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2319( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext"), ("identifier", "identifier__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class MessageHeaderSource(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Message source application. - The source application from which this message originated. - """ - - resource_type = Field("MessageHeaderSource", const=True) - - contact: fhirtypes.ContactPointType = Field( - None, - alias="contact", - title="Human contact for problems", - description=( - "An e-mail, phone, website or other contact point to use to resolve " - "issues with message communications." - ), - # if property is element of this resource. - element_property=True, - ) - - endpoint: fhirtypes.Url = Field( - None, - alias="endpoint", - title="Actual message source address or id", - description="Identifies the routing target to send acknowledgements to.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - endpoint__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_endpoint", title="Extension field for ``endpoint``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name of system", - description="Human-readable name for the source system.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - software: fhirtypes.String = Field( - None, - alias="software", - title="Name of software running the system", - description="May include configuration or other information useful in debugging.", - # if property is element of this resource. - element_property=True, - ) - software__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_software", title="Extension field for ``software``." - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Version of software running", - description=( - "Can convey versions of multiple systems in situations where a message " - "passes through multiple hands." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MessageHeaderSource`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "software", - "version", - "contact", - "endpoint", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2097( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("endpoint", "endpoint__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/meta.py b/fhir/resources/meta.py deleted file mode 100644 index 3788077b..00000000 --- a/fhir/resources/meta.py +++ /dev/null @@ -1,136 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Meta -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import element, fhirtypes - - -class Meta(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Metadata about a resource. - The metadata about a resource. This is content in the resource that is - maintained by the infrastructure. Changes to the content might not always - be associated with version changes to the resource. - """ - - resource_type = Field("Meta", const=True) - - lastUpdated: fhirtypes.Instant = Field( - None, - alias="lastUpdated", - title="When the resource version last changed", - description="When the resource last changed - e.g. when the version changed.", - # if property is element of this resource. - element_property=True, - ) - lastUpdated__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastUpdated", title="Extension field for ``lastUpdated``." - ) - - profile: typing.List[fhirtypes.Canonical] = Field( - None, - alias="profile", - title="Profiles this resource claims to conform to", - description=( - "A list of profiles (references to " - "[StructureDefinition](structuredefinition.html#) resources) that this " - "resource claims to conform to. The URL is a reference to " - "[StructureDefinition.url](structuredefinition-" - "definitions.html#StructureDefinition.url)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - profile__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_profile", title="Extension field for ``profile``.") - - security: typing.List[fhirtypes.CodingType] = Field( - None, - alias="security", - title="Security Labels applied to this resource", - description=( - "Security labels applied to this resource. These tags connect specific " - "resources to the overall security policy and infrastructure." - ), - # if property is element of this resource. - element_property=True, - ) - - source: fhirtypes.Uri = Field( - None, - alias="source", - title="Identifies where the resource comes from", - description=( - "A uri that identifies the source system of the resource. This provides" - " a minimal amount of [Provenance](provenance.html#) information that " - "can be used to track or differentiate the source of information in the" - " resource. The source may identify another FHIR server, document, " - "message, database, etc." - ), - # if property is element of this resource. - element_property=True, - ) - source__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_source", title="Extension field for ``source``." - ) - - tag: typing.List[fhirtypes.CodingType] = Field( - None, - alias="tag", - title="Tags applied to this resource", - description=( - "Tags applied to this resource. Tags are intended to be used to " - "identify and relate resources to process and workflow, and " - "applications are not required to consider the tags when interpreting " - "the meaning of a resource." - ), - # if property is element of this resource. - element_property=True, - ) - - versionId: fhirtypes.Id = Field( - None, - alias="versionId", - title="Version specific identifier", - description=( - "The version specific identifier, as it appears in the version portion " - "of the URL. This value changes when the resource is created, updated, " - "or deleted." - ), - # if property is element of this resource. - element_property=True, - ) - versionId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_versionId", title="Extension field for ``versionId``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Meta`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "versionId", - "lastUpdated", - "source", - "profile", - "security", - "tag", - ] diff --git a/fhir/resources/metadataresource.py b/fhir/resources/metadataresource.py deleted file mode 100644 index 7d83561d..00000000 --- a/fhir/resources/metadataresource.py +++ /dev/null @@ -1,308 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MetadataResource -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class MetadataResource(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Common Ancestor declaration for definitional resources. - Common Ancestor declaration for conformance and knowledge artifact - resources. - """ - - resource_type = Field("MetadataResource", const=True) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the metadata resource was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the metadata resource changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the metadata resource", - description=( - "A free text natural language description of the metadata resource from" - " a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this metadata resource is authored " - "for testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for metadata resource (if applicable)", - description=( - "A legal or geographic region in which the metadata resource is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this metadata resource (computer friendly)", - description=( - "A natural language name identifying the metadata resource. This name " - "should be usable as an identifier for the module by machine processing" - " applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the metadata" - " resource." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this metadata resource. Enables tracking the life-cycle " - "of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this metadata resource (human friendly)", - description="A short, descriptive, user-friendly title for the metadata resource.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this metadata resource, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this metadata resource when " - "it is referenced in a specification, model, design or an instance; " - "also called its canonical identifier. This SHOULD be globally unique " - "and SHOULD be a literal address at which at which an authoritative " - "instance of this metadata resource is (or will be) published. This URL" - " can be the target of a canonical reference. It SHALL remain the same " - "when the metadata resource is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate metadata resource instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the metadata resource", - description=( - "The identifier that is used to identify this version of the metadata " - "resource when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the metadata resource " - "author and is not expected to be globally unique. For example, it " - "might be a timestamp (e.g. yyyymmdd) if a managed version is not " - "available. There is also no expectation that versions can be placed in" - " a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MetadataResource`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "version", - "name", - "title", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1819( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/molecularsequence.py b/fhir/resources/molecularsequence.py deleted file mode 100644 index 207e8ad3..00000000 --- a/fhir/resources/molecularsequence.py +++ /dev/null @@ -1,1474 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MolecularSequence -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class MolecularSequence(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about a biological sequence. - Raw data describing a biological sequence. - """ - - resource_type = Field("MolecularSequence", const=True) - - coordinateSystem: fhirtypes.Integer = Field( - None, - alias="coordinateSystem", - title=( - "Base number of coordinate system (0 for 0-based numbering or " - "coordinates, inclusive start, exclusive end, 1 for 1-based numbering, " - "inclusive start, inclusive end)" - ), - description=( - "Whether the sequence is numbered starting at 0 (0-based numbering or " - "coordinates, inclusive start, exclusive end) or starting at 1 (1-based" - " numbering, inclusive start and inclusive end)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - coordinateSystem__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_coordinateSystem", - title="Extension field for ``coordinateSystem``.", - ) - - device: fhirtypes.ReferenceType = Field( - None, - alias="device", - title="The method for sequencing", - description="The method for sequencing, for example, chip information.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Unique ID for this particular sequence. This is a FHIR-defined id", - description=( - "A unique identifier for this particular sequence instance. This is a " - "FHIR-defined id." - ), - # if property is element of this resource. - element_property=True, - ) - - observedSeq: fhirtypes.String = Field( - None, - alias="observedSeq", - title="Sequence that was observed", - description=( - "Sequence that was observed. It is the result marked by referenceSeq " - "along with variant records on referenceSeq. This shall start from " - "referenceSeq.windowStart and end by referenceSeq.windowEnd." - ), - # if property is element of this resource. - element_property=True, - ) - observedSeq__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_observedSeq", title="Extension field for ``observedSeq``." - ) - - patient: fhirtypes.ReferenceType = Field( - None, - alias="patient", - title="Who and/or what this is about", - description="The patient whose sequencing results are described by this resource.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - performer: fhirtypes.ReferenceType = Field( - None, - alias="performer", - title="Who should be responsible for test result", - description="The organization or lab that should be responsible for this result.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - pointer: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="pointer", - title="Pointer to next atomic sequence", - description="Pointer to next atomic sequence which at most contains one variant.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MolecularSequence"], - ) - - quality: typing.List[fhirtypes.MolecularSequenceQualityType] = Field( - None, - alias="quality", - title="An set of value as quality of sequence", - description=( - "An experimental feature attribute that defines the quality of the " - "feature in a quantitative way, such as a phred quality score ([SO:0001" - "686](http://www.sequenceontology.org/browser/current_svn/term/SO:00016" - "86))." - ), - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="The number of copies of the sequence of interest. (RNASeq)", - description="The number of copies of the sequence of interest. (RNASeq).", - # if property is element of this resource. - element_property=True, - ) - - readCoverage: fhirtypes.Integer = Field( - None, - alias="readCoverage", - title=( - "Average number of reads representing a given nucleotide in the " - "reconstructed sequence" - ), - description=( - "Coverage (read depth or depth) is the average number of reads " - "representing a given nucleotide in the reconstructed sequence." - ), - # if property is element of this resource. - element_property=True, - ) - readCoverage__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_readCoverage", title="Extension field for ``readCoverage``." - ) - - referenceSeq: fhirtypes.MolecularSequenceReferenceSeqType = Field( - None, - alias="referenceSeq", - title="A sequence used as reference", - description=( - "A sequence that is used as a reference to describe variants that are " - "present in a sequence analyzed." - ), - # if property is element of this resource. - element_property=True, - ) - - repository: typing.List[fhirtypes.MolecularSequenceRepositoryType] = Field( - None, - alias="repository", - title=( - "External repository which contains detailed report related with " - "observedSeq in this resource" - ), - description=( - "Configurations of the external repository. The repository shall store " - "target's observedSeq or records related with target's observedSeq." - ), - # if property is element of this resource. - element_property=True, - ) - - specimen: fhirtypes.ReferenceType = Field( - None, - alias="specimen", - title="Specimen used for sequencing", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Specimen"], - ) - - structureVariant: typing.List[ - fhirtypes.MolecularSequenceStructureVariantType - ] = Field( - None, - alias="structureVariant", - title="Structural variant", - description="Information about chromosome structure variation.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="aa | dna | rna", - description="Amino Acid Sequence/ DNA Sequence / RNA Sequence.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["aa", "dna", "rna"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - variant: typing.List[fhirtypes.MolecularSequenceVariantType] = Field( - None, - alias="variant", - title="Variant in sequence", - description=( - "The definition of variant here originates from Sequence ontology ([var" - "iant_of](http://www.sequenceontology.org/browser/current_svn/term/vari" - "ant_of)). This element can represent amino acid or nucleic sequence " - "change(including insertion,deletion,SNP,etc.) It can represent some " - "complex mutation or segment variation with the assist of CIGAR string." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MolecularSequence`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "type", - "coordinateSystem", - "patient", - "specimen", - "device", - "performer", - "quantity", - "referenceSeq", - "variant", - "observedSeq", - "quality", - "readCoverage", - "repository", - "pointer", - "structureVariant", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1935( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("coordinateSystem", "coordinateSystem__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class MolecularSequenceQuality(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An set of value as quality of sequence. - An experimental feature attribute that defines the quality of the feature - in a quantitative way, such as a phred quality score ([SO:0001686](http://w - ww.sequenceontology.org/browser/current_svn/term/SO:0001686)). - """ - - resource_type = Field("MolecularSequenceQuality", const=True) - - end: fhirtypes.Integer = Field( - None, - alias="end", - title="End position of the sequence", - description=( - "End position of the sequence. If the coordinate system is 0-based then" - " end is exclusive and does not include the last position. If the " - "coordinate system is 1-base, then end is inclusive and includes the " - "last position." - ), - # if property is element of this resource. - element_property=True, - ) - end__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_end", title="Extension field for ``end``." - ) - - fScore: fhirtypes.Decimal = Field( - None, - alias="fScore", - title="F-score", - description=( - "Harmonic mean of Recall and Precision, computed as: 2 * precision * " - "recall / (precision + recall)." - ), - # if property is element of this resource. - element_property=True, - ) - fScore__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fScore", title="Extension field for ``fScore``." - ) - - gtFP: fhirtypes.Decimal = Field( - None, - alias="gtFP", - title=( - "False positives where the non-REF alleles in the Truth and Query Call " - "Sets match" - ), - description=( - "The number of false positives where the non-REF alleles in the Truth " - "and Query Call Sets match (i.e. cases where the truth is 1/1 and the " - "query is 0/1 or similar)." - ), - # if property is element of this resource. - element_property=True, - ) - gtFP__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_gtFP", title="Extension field for ``gtFP``." - ) - - method: fhirtypes.CodeableConceptType = Field( - None, - alias="method", - title="Method to get quality", - description="Which method is used to get sequence quality.", - # if property is element of this resource. - element_property=True, - ) - - precision: fhirtypes.Decimal = Field( - None, - alias="precision", - title="Precision of comparison", - description="QUERY.TP / (QUERY.TP + QUERY.FP).", - # if property is element of this resource. - element_property=True, - ) - precision__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_precision", title="Extension field for ``precision``." - ) - - queryFP: fhirtypes.Decimal = Field( - None, - alias="queryFP", - title="False positives", - description=( - "False positives, i.e. the number of sites in the Query Call Set for " - "which there is no path through the Truth Call Set that is consistent " - "with this site. Sites with correct variant but incorrect genotype are " - "counted here." - ), - # if property is element of this resource. - element_property=True, - ) - queryFP__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_queryFP", title="Extension field for ``queryFP``." - ) - - queryTP: fhirtypes.Decimal = Field( - None, - alias="queryTP", - title="True positives from the perspective of the query data", - description=( - "True positives, from the perspective of the query data, i.e. the " - "number of sites in the Query Call Set for which there are paths " - "through the Truth Call Set that are consistent with all of the alleles" - " at this site, and for which there is an accurate genotype call for " - "the event." - ), - # if property is element of this resource. - element_property=True, - ) - queryTP__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_queryTP", title="Extension field for ``queryTP``." - ) - - recall: fhirtypes.Decimal = Field( - None, - alias="recall", - title="Recall of comparison", - description="TRUTH.TP / (TRUTH.TP + TRUTH.FN).", - # if property is element of this resource. - element_property=True, - ) - recall__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_recall", title="Extension field for ``recall``." - ) - - roc: fhirtypes.MolecularSequenceQualityRocType = Field( - None, - alias="roc", - title="Receiver Operator Characteristic (ROC) Curve", - description=( - "Receiver Operator Characteristic (ROC) Curve to give " - "sensitivity/specificity tradeoff." - ), - # if property is element of this resource. - element_property=True, - ) - - score: fhirtypes.QuantityType = Field( - None, - alias="score", - title="Quality score for the comparison", - description=( - "The score of an experimentally derived feature such as a p-value ([SO:" - "0001685](http://www.sequenceontology.org/browser/current_svn/term/SO:0" - "001685))." - ), - # if property is element of this resource. - element_property=True, - ) - - standardSequence: fhirtypes.CodeableConceptType = Field( - None, - alias="standardSequence", - title="Standard sequence for comparison", - description="Gold standard sequence used for comparing against.", - # if property is element of this resource. - element_property=True, - ) - - start: fhirtypes.Integer = Field( - None, - alias="start", - title="Start position of the sequence", - description=( - "Start position of the sequence. If the coordinate system is either " - "0-based or 1-based, then start position is inclusive." - ), - # if property is element of this resource. - element_property=True, - ) - start__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_start", title="Extension field for ``start``." - ) - - truthFN: fhirtypes.Decimal = Field( - None, - alias="truthFN", - title="False negatives", - description=( - "False negatives, i.e. the number of sites in the Truth Call Set for " - "which there is no path through the Query Call Set that is consistent " - "with all of the alleles at this site, or sites for which there is an " - "inaccurate genotype call for the event. Sites with correct variant but" - " incorrect genotype are counted here." - ), - # if property is element of this resource. - element_property=True, - ) - truthFN__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_truthFN", title="Extension field for ``truthFN``." - ) - - truthTP: fhirtypes.Decimal = Field( - None, - alias="truthTP", - title="True positives from the perspective of the truth data", - description=( - "True positives, from the perspective of the truth data, i.e. the " - "number of sites in the Truth Call Set for which there are paths " - "through the Query Call Set that are consistent with all of the alleles" - " at this site, and for which there is an accurate genotype call for " - "the event." - ), - # if property is element of this resource. - element_property=True, - ) - truthTP__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_truthTP", title="Extension field for ``truthTP``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="indel | snp | unknown", - description="INDEL / SNP / Undefined variant.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["indel", "snp", "unknown"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MolecularSequenceQuality`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "standardSequence", - "start", - "end", - "score", - "method", - "truthTP", - "queryTP", - "truthFN", - "queryFP", - "gtFP", - "precision", - "recall", - "fScore", - "roc", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2700( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class MolecularSequenceQualityRoc(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Receiver Operator Characteristic (ROC) Curve. - Receiver Operator Characteristic (ROC) Curve to give - sensitivity/specificity tradeoff. - """ - - resource_type = Field("MolecularSequenceQualityRoc", const=True) - - fMeasure: typing.List[fhirtypes.Decimal] = Field( - None, - alias="fMeasure", - title="FScore of the GQ score", - description=( - 'Calculated fScore if the GQ score threshold was set to "score" field ' - "value." - ), - # if property is element of this resource. - element_property=True, - ) - fMeasure__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_fMeasure", title="Extension field for ``fMeasure``.") - - numFN: typing.List[fhirtypes.Integer] = Field( - None, - alias="numFN", - title="Roc score false negative numbers", - description=( - "The number of false negatives if the GQ score threshold was set to " - '"score" field value.' - ), - # if property is element of this resource. - element_property=True, - ) - numFN__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_numFN", title="Extension field for ``numFN``.") - - numFP: typing.List[fhirtypes.Integer] = Field( - None, - alias="numFP", - title="Roc score false positive numbers", - description=( - "The number of false positives if the GQ score threshold was set to " - '"score" field value.' - ), - # if property is element of this resource. - element_property=True, - ) - numFP__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_numFP", title="Extension field for ``numFP``.") - - numTP: typing.List[fhirtypes.Integer] = Field( - None, - alias="numTP", - title="Roc score true positive numbers", - description=( - "The number of true positives if the GQ score threshold was set to " - '"score" field value.' - ), - # if property is element of this resource. - element_property=True, - ) - numTP__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_numTP", title="Extension field for ``numTP``.") - - precision: typing.List[fhirtypes.Decimal] = Field( - None, - alias="precision", - title="Precision of the GQ score", - description=( - 'Calculated precision if the GQ score threshold was set to "score" ' - "field value." - ), - # if property is element of this resource. - element_property=True, - ) - precision__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_precision", title="Extension field for ``precision``.") - - score: typing.List[fhirtypes.Integer] = Field( - None, - alias="score", - title="Genotype quality score", - description=( - "Invidual data point representing the GQ (genotype quality) score " - "threshold." - ), - # if property is element of this resource. - element_property=True, - ) - score__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_score", title="Extension field for ``score``.") - - sensitivity: typing.List[fhirtypes.Decimal] = Field( - None, - alias="sensitivity", - title="Sensitivity of the GQ score", - description=( - 'Calculated sensitivity if the GQ score threshold was set to "score" ' - "field value." - ), - # if property is element of this resource. - element_property=True, - ) - sensitivity__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_sensitivity", title="Extension field for ``sensitivity``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MolecularSequenceQualityRoc`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "score", - "numTP", - "numFP", - "numFN", - "precision", - "sensitivity", - "fMeasure", - ] - - -class MolecularSequenceReferenceSeq(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A sequence used as reference. - A sequence that is used as a reference to describe variants that are - present in a sequence analyzed. - """ - - resource_type = Field("MolecularSequenceReferenceSeq", const=True) - - chromosome: fhirtypes.CodeableConceptType = Field( - None, - alias="chromosome", - title="Chromosome containing genetic finding", - description=( - "Structural unit composed of a nucleic acid molecule which controls its" - " own replication through the interaction of specific proteins at one " - "or more origins of replication ([SO:0000340](http://www.sequenceontolo" - "gy.org/browser/current_svn/term/SO:0000340))." - ), - # if property is element of this resource. - element_property=True, - ) - - genomeBuild: fhirtypes.String = Field( - None, - alias="genomeBuild", - title=( - "The Genome Build used for reference, following GRCh build versions " - "e.g. 'GRCh 37'" - ), - description=( - "The Genome Build used for reference, following GRCh build versions " - "e.g. 'GRCh 37'. Version number must be included if a versioned " - "release of a primary build was used." - ), - # if property is element of this resource. - element_property=True, - ) - genomeBuild__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_genomeBuild", title="Extension field for ``genomeBuild``." - ) - - orientation: fhirtypes.Code = Field( - None, - alias="orientation", - title="sense | antisense", - description=( - "A relative reference to a DNA strand based on gene orientation. The " - 'strand that contains the open reading frame of the gene is the "sense"' - ' strand, and the opposite complementary strand is the "antisense" ' - "strand." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["sense", "antisense"], - ) - orientation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_orientation", title="Extension field for ``orientation``." - ) - - referenceSeqId: fhirtypes.CodeableConceptType = Field( - None, - alias="referenceSeqId", - title="Reference identifier", - description=( - "Reference identifier of reference sequence submitted to NCBI. It must " - "match the type in the MolecularSequence.type field. For example, the " - "prefix, \u201cNG_\u201d identifies reference sequence " - "for genes, \u201cNM_\u201d for " - "messenger RNA transcripts, and \u201cNP_\u201d for amino acid sequences." - ), - # if property is element of this resource. - element_property=True, - ) - - referenceSeqPointer: fhirtypes.ReferenceType = Field( - None, - alias="referenceSeqPointer", - title="A pointer to another MolecularSequence entity as reference sequence", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["MolecularSequence"], - ) - - referenceSeqString: fhirtypes.String = Field( - None, - alias="referenceSeqString", - title="A string to represent reference sequence", - description='A string like "ACGT".', - # if property is element of this resource. - element_property=True, - ) - referenceSeqString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_referenceSeqString", - title="Extension field for ``referenceSeqString``.", - ) - - strand: fhirtypes.Code = Field( - None, - alias="strand", - title="watson | crick", - description=( - "An absolute reference to a strand. The Watson strand is the strand " - "whose 5'-end is on the short arm of the chromosome, and the Crick " - "strand as the one whose 5'-end is on the long arm." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["watson", "crick"], - ) - strand__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_strand", title="Extension field for ``strand``." - ) - - windowEnd: fhirtypes.Integer = Field( - None, - alias="windowEnd", - title="End position of the window on the reference sequence", - description=( - "End position of the window on the reference sequence. If the " - "coordinate system is 0-based then end is exclusive and does not " - "include the last position. If the coordinate system is 1-base, then " - "end is inclusive and includes the last position." - ), - # if property is element of this resource. - element_property=True, - ) - windowEnd__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_windowEnd", title="Extension field for ``windowEnd``." - ) - - windowStart: fhirtypes.Integer = Field( - None, - alias="windowStart", - title="Start position of the window on the reference sequence", - description=( - "Start position of the window on the reference sequence. If the " - "coordinate system is either 0-based or 1-based, then start position is" - " inclusive." - ), - # if property is element of this resource. - element_property=True, - ) - windowStart__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_windowStart", title="Extension field for ``windowStart``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MolecularSequenceReferenceSeq`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "chromosome", - "genomeBuild", - "orientation", - "referenceSeqId", - "referenceSeqPointer", - "referenceSeqString", - "strand", - "windowStart", - "windowEnd", - ] - - -class MolecularSequenceRepository(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - External repository which contains detailed report related with observedSeq - in this resource. - Configurations of the external repository. The repository shall store - target's observedSeq or records related with target's observedSeq. - """ - - resource_type = Field("MolecularSequenceRepository", const=True) - - datasetId: fhirtypes.String = Field( - None, - alias="datasetId", - title="Id of the dataset that used to call for dataset in repository", - description=( - "Id of the variant in this external repository. The server will " - "understand how to use this id to call for more info about datasets in " - "external repository." - ), - # if property is element of this resource. - element_property=True, - ) - datasetId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_datasetId", title="Extension field for ``datasetId``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Repository's name", - description=( - "URI of an external repository which contains further details about the" - " genetics data." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - readsetId: fhirtypes.String = Field( - None, - alias="readsetId", - title="Id of the read", - description="Id of the read in this external repository.", - # if property is element of this resource. - element_property=True, - ) - readsetId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_readsetId", title="Extension field for ``readsetId``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="directlink | openapi | login | oauth | other", - description=( - "Click and see / RESTful API / Need login to see / RESTful API with " - "authentication / Other ways to see resource." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["directlink", "openapi", "login", "oauth", "other"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title="URI of the repository", - description=( - "URI of an external repository which contains further details about the" - " genetics data." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - variantsetId: fhirtypes.String = Field( - None, - alias="variantsetId", - title="Id of the variantset that used to call for variantset in repository", - description=( - "Id of the variantset in this external repository. The server will " - "understand how to use this id to call for more info about variantsets " - "in external repository." - ), - # if property is element of this resource. - element_property=True, - ) - variantsetId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_variantsetId", title="Extension field for ``variantsetId``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MolecularSequenceRepository`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "url", - "name", - "datasetId", - "variantsetId", - "readsetId", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3043( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class MolecularSequenceStructureVariant(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Structural variant. - Information about chromosome structure variation. - """ - - resource_type = Field("MolecularSequenceStructureVariant", const=True) - - exact: bool = Field( - None, - alias="exact", - title="Does the structural variant have base pair resolution breakpoints?", - description=( - "Used to indicate if the outer and inner start-end values have the same" - " meaning." - ), - # if property is element of this resource. - element_property=True, - ) - exact__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_exact", title="Extension field for ``exact``." - ) - - inner: fhirtypes.MolecularSequenceStructureVariantInnerType = Field( - None, - alias="inner", - title="Structural variant inner", - description=None, - # if property is element of this resource. - element_property=True, - ) - - length: fhirtypes.Integer = Field( - None, - alias="length", - title="Structural variant length", - description="Length of the variant chromosome.", - # if property is element of this resource. - element_property=True, - ) - length__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_length", title="Extension field for ``length``." - ) - - outer: fhirtypes.MolecularSequenceStructureVariantOuterType = Field( - None, - alias="outer", - title="Structural variant outer", - description=None, - # if property is element of this resource. - element_property=True, - ) - - variantType: fhirtypes.CodeableConceptType = Field( - None, - alias="variantType", - title="Structural variant change type", - description="Information about chromosome structure variation DNA change type.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MolecularSequenceStructureVariant`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "variantType", - "exact", - "length", - "outer", - "inner", - ] - - -class MolecularSequenceStructureVariantInner(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Structural variant inner. - """ - - resource_type = Field("MolecularSequenceStructureVariantInner", const=True) - - end: fhirtypes.Integer = Field( - None, - alias="end", - title="Structural variant inner end", - description=( - "Structural variant inner end. If the coordinate system is 0-based then" - " end is exclusive and does not include the last position. If the " - "coordinate system is 1-base, then end is inclusive and includes the " - "last position." - ), - # if property is element of this resource. - element_property=True, - ) - end__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_end", title="Extension field for ``end``." - ) - - start: fhirtypes.Integer = Field( - None, - alias="start", - title="Structural variant inner start", - description=( - "Structural variant inner start. If the coordinate system is either " - "0-based or 1-based, then start position is inclusive." - ), - # if property is element of this resource. - element_property=True, - ) - start__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_start", title="Extension field for ``start``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MolecularSequenceStructureVariantInner`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "start", "end"] - - -class MolecularSequenceStructureVariantOuter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Structural variant outer. - """ - - resource_type = Field("MolecularSequenceStructureVariantOuter", const=True) - - end: fhirtypes.Integer = Field( - None, - alias="end", - title="Structural variant outer end", - description=( - "Structural variant outer end. If the coordinate system is 0-based then" - " end is exclusive and does not include the last position. If the " - "coordinate system is 1-base, then end is inclusive and includes the " - "last position." - ), - # if property is element of this resource. - element_property=True, - ) - end__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_end", title="Extension field for ``end``." - ) - - start: fhirtypes.Integer = Field( - None, - alias="start", - title="Structural variant outer start", - description=( - "Structural variant outer start. If the coordinate system is either " - "0-based or 1-based, then start position is inclusive." - ), - # if property is element of this resource. - element_property=True, - ) - start__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_start", title="Extension field for ``start``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MolecularSequenceStructureVariantOuter`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "start", "end"] - - -class MolecularSequenceVariant(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Variant in sequence. - The definition of variant here originates from Sequence ontology ([variant_ - of](http://www.sequenceontology.org/browser/current_svn/term/variant_of)). - This element can represent amino acid or nucleic sequence change(including - insertion,deletion,SNP,etc.) It can represent some complex mutation or - segment variation with the assist of CIGAR string. - """ - - resource_type = Field("MolecularSequenceVariant", const=True) - - cigar: fhirtypes.String = Field( - None, - alias="cigar", - title="Extended CIGAR string for aligning the sequence with reference bases", - description=( - "Extended CIGAR string for aligning the sequence with reference bases. " - "See detailed documentation [here](http://support.illumina.com/help/Seq" - "uencingAnalysisWorkflow/Content/Vault/Informatics/Sequencing_Analysis/" - "CASAVA/swSEQ_mCA_ExtendedCIGARFormat.htm)." - ), - # if property is element of this resource. - element_property=True, - ) - cigar__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_cigar", title="Extension field for ``cigar``." - ) - - end: fhirtypes.Integer = Field( - None, - alias="end", - title="End position of the variant on the reference sequence", - description=( - "End position of the variant on the reference sequence. If the " - "coordinate system is 0-based then end is exclusive and does not " - "include the last position. If the coordinate system is 1-base, then " - "end is inclusive and includes the last position." - ), - # if property is element of this resource. - element_property=True, - ) - end__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_end", title="Extension field for ``end``." - ) - - observedAllele: fhirtypes.String = Field( - None, - alias="observedAllele", - title="Allele that was observed", - description=( - "An allele is one of a set of coexisting sequence variants of a gene ([" - "SO:0001023](http://www.sequenceontology.org/browser/current_svn/term/S" - "O:0001023)). Nucleotide(s)/amino acids from start position of " - "sequence to stop position of sequence on the positive (+) strand of " - "the observed sequence. When the sequence type is DNA, it should be " - "the sequence on the positive (+) strand. This will lay in the range " - "between variant.start and variant.end." - ), - # if property is element of this resource. - element_property=True, - ) - observedAllele__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_observedAllele", title="Extension field for ``observedAllele``." - ) - - referenceAllele: fhirtypes.String = Field( - None, - alias="referenceAllele", - title="Allele in the reference sequence", - description=( - "An allele is one of a set of coexisting sequence variants of a gene ([" - "SO:0001023](http://www.sequenceontology.org/browser/current_svn/term/S" - "O:0001023)). Nucleotide(s)/amino acids from start position of sequence" - " to stop position of sequence on the positive (+) strand of the " - "reference sequence. When the sequence type is DNA, it should be the " - "sequence on the positive (+) strand. This will lay in the range " - "between variant.start and variant.end." - ), - # if property is element of this resource. - element_property=True, - ) - referenceAllele__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_referenceAllele", title="Extension field for ``referenceAllele``." - ) - - start: fhirtypes.Integer = Field( - None, - alias="start", - title="Start position of the variant on the reference sequence", - description=( - "Start position of the variant on the reference sequence. If the " - "coordinate system is either 0-based or 1-based, then start position is" - " inclusive." - ), - # if property is element of this resource. - element_property=True, - ) - start__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_start", title="Extension field for ``start``." - ) - - variantPointer: fhirtypes.ReferenceType = Field( - None, - alias="variantPointer", - title="Pointer to observed variant information", - description="A pointer to an Observation containing variant information.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Observation"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``MolecularSequenceVariant`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "start", - "end", - "observedAllele", - "referenceAllele", - "cigar", - "variantPointer", - ] diff --git a/fhir/resources/money.py b/fhir/resources/money.py deleted file mode 100644 index 50c5de9d..00000000 --- a/fhir/resources/money.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Money -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import element, fhirtypes - - -class Money(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An amount of economic utility in some recognized currency. - """ - - resource_type = Field("Money", const=True) - - currency: fhirtypes.Code = Field( - None, - alias="currency", - title="ISO 4217 Currency Code", - description=None, - # if property is element of this resource. - element_property=True, - ) - currency__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_currency", title="Extension field for ``currency``." - ) - - value: fhirtypes.Decimal = Field( - None, - alias="value", - title="Numerical value (with implicit precision)", - description=None, - # if property is element of this resource. - element_property=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Money`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "value", "currency"] diff --git a/fhir/resources/namingsystem.py b/fhir/resources/namingsystem.py deleted file mode 100644 index e59e4600..00000000 --- a/fhir/resources/namingsystem.py +++ /dev/null @@ -1,485 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/NamingSystem -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class NamingSystem(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - System of unique identification. - A curated namespace that issues unique symbols within that namespace for - the identification of concepts, people, devices, etc. Represents a - "System" used within the Identifier and Coding data types. - """ - - resource_type = Field("NamingSystem", const=True) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the naming system was published. " - "The date must change when the business version changes and it must " - "change if the status code changes. In addition, it should change when " - "the substantive content of the naming system changes." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the naming system", - description=( - "A free text natural language description of the naming system from a " - "consumer's perspective. Details about what the namespace identifies " - "including scope, granularity, version labeling, etc." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for naming system (if applicable)", - description=( - "A legal or geographic region in which the naming system is intended to" - " be used." - ), - # if property is element of this resource. - element_property=True, - ) - - kind: fhirtypes.Code = Field( - None, - alias="kind", - title="codesystem | identifier | root", - description=( - "Indicates the purpose for the naming system - what kinds of things " - "does it make unique?" - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["codesystem", "identifier", "root"], - ) - kind__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_kind", title="Extension field for ``kind``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this naming system (computer friendly)", - description=( - "A natural language name identifying the naming system. This name " - "should be usable as an identifier for the module by machine processing" - " applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the naming " - "system." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - responsible: fhirtypes.String = Field( - None, - alias="responsible", - title="Who maintains system namespace?", - description=( - "The name of the organization that is responsible for issuing " - "identifiers or codes for this namespace and ensuring their non-" - "collision." - ), - # if property is element of this resource. - element_property=True, - ) - responsible__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_responsible", title="Extension field for ``responsible``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this naming system. Enables tracking the life-cycle of " - "the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="e.g. driver, provider, patient, bank etc.", - description=( - "Categorizes a naming system for easier search by grouping related " - "naming systems." - ), - # if property is element of this resource. - element_property=True, - ) - - uniqueId: typing.List[fhirtypes.NamingSystemUniqueIdType] = Field( - ..., - alias="uniqueId", - title="Unique identifiers used for system", - description=( - "Indicates how the system may be identified when referenced in " - "electronic exchange." - ), - # if property is element of this resource. - element_property=True, - ) - - usage: fhirtypes.String = Field( - None, - alias="usage", - title="How/where is it used", - description=( - "Provides guidance on the use of the namespace, including the handling " - "of formatting characters, use of upper vs. lower case, etc." - ), - # if property is element of this resource. - element_property=True, - ) - usage__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_usage", title="Extension field for ``usage``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate naming system instances." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``NamingSystem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "name", - "status", - "kind", - "date", - "publisher", - "contact", - "responsible", - "type", - "description", - "useContext", - "jurisdiction", - "usage", - "uniqueId", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1434( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("date", "date__ext"), - ("kind", "kind__ext"), - ("name", "name__ext"), - ("status", "status__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class NamingSystemUniqueId(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Unique identifiers used for system. - Indicates how the system may be identified when referenced in electronic - exchange. - """ - - resource_type = Field("NamingSystemUniqueId", const=True) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Notes about identifier usage", - description="Notes about the past or intended usage of this identifier.", - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="When is identifier valid?", - description=( - "Identifies the period of time over which this identifier is considered" - " appropriate to refer to the naming system. Outside of this window, " - "the identifier might be non-deterministic." - ), - # if property is element of this resource. - element_property=True, - ) - - preferred: bool = Field( - None, - alias="preferred", - title="Is this the id that should be used for this type", - description=( - 'Indicates whether this identifier is the "preferred" identifier of ' - "this type." - ), - # if property is element of this resource. - element_property=True, - ) - preferred__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_preferred", title="Extension field for ``preferred``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="oid | uuid | uri | other", - description=( - "Identifies the unique identifier scheme used for this particular " - "identifier." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["oid", "uuid", "uri", "other"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="The unique identifier", - description=( - "The string that should be sent over the wire to identify the code " - "system or identifier system." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``NamingSystemUniqueId`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "value", - "preferred", - "comment", - "period", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2229( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext"), ("value", "value__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/narrative.py b/fhir/resources/narrative.py deleted file mode 100644 index 3f4d8602..00000000 --- a/fhir/resources/narrative.py +++ /dev/null @@ -1,129 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Narrative -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import element, fhirtypes - - -class Narrative(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Human-readable summary of the resource (essential clinical and business - information). - A human-readable summary of the resource conveying the essential clinical - and business information for the resource. - """ - - resource_type = Field("Narrative", const=True) - - div: fhirtypes.Xhtml = Field( - None, - alias="div", - title="Limited xhtml content", - description="The actual narrative content, a stripped down version of XHTML.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - div__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_div", title="Extension field for ``div``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="generated | extensions | additional | empty", - description=( - "The status of the narrative - whether it's entirely generated (from " - "just the defined data or the extensions too), or whether a human " - "authored it and it may contain additional data." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["generated", "extensions", "additional", "empty"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Narrative`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "status", "div"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1119( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("div", "div__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/nutritionorder.py b/fhir/resources/nutritionorder.py deleted file mode 100644 index 20239009..00000000 --- a/fhir/resources/nutritionorder.py +++ /dev/null @@ -1,991 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/NutritionOrder -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class NutritionOrder(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Diet, formula or nutritional supplement request. - A request to supply a diet, formula feeding (enteral) or oral nutritional - supplement to a patient/resident. - """ - - resource_type = Field("NutritionOrder", const=True) - - allergyIntolerance: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="allergyIntolerance", - title=( - "List of the patient's food and nutrition-related allergies and " - "intolerances" - ), - description=( - "A link to a record of allergies or intolerances which should be " - "included in the nutrition order." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["AllergyIntolerance"], - ) - - dateTime: fhirtypes.DateTime = Field( - None, - alias="dateTime", - title="Date and time the nutrition order was requested", - description="The date and time that this nutrition order was requested.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - dateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_dateTime", title="Extension field for ``dateTime``." - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="The encounter associated with this nutrition order", - description=( - "An encounter that provides additional information about the healthcare" - " context in which this request is made." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - enteralFormula: fhirtypes.NutritionOrderEnteralFormulaType = Field( - None, - alias="enteralFormula", - title="Enteral formula components", - description=( - "Feeding provided through the gastrointestinal tract via a tube, " - "catheter, or stoma that delivers nutrition distal to the oral cavity." - ), - # if property is element of this resource. - element_property=True, - ) - - excludeFoodModifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="excludeFoodModifier", - title=( - "Order-specific modifier about the type of food that should not be " "given" - ), - description=( - "This modifier is used to convey Order-specific modifier about the type" - " of oral food or oral fluids that should not be given. These can be " - "derived from patient allergies, intolerances, or preferences such as " - "No Red Meat, No Soy or No Wheat or Gluten-Free. While it should not " - "be necessary to repeat allergy or intolerance information captured in " - "the referenced AllergyIntolerance resource in the excludeFoodModifier," - " this element may be used to convey additional specificity related to " - "foods that should be eliminated from the patient\u2019s diet for any " - "reason. This modifier applies to the entire nutrition order inclusive" - " of the oral diet, nutritional supplements and enteral formula " - "feedings." - ), - # if property is element of this resource. - element_property=True, - ) - - foodPreferenceModifier: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="foodPreferenceModifier", - title="Order-specific modifier about the type of food that should be given", - description=( - "This modifier is used to convey order-specific modifiers about the " - "type of food that should be given. These can be derived from patient " - "allergies, intolerances, or preferences such as Halal, Vegan or " - "Kosher. This modifier applies to the entire nutrition order inclusive " - "of the oral diet, nutritional supplements and enteral formula " - "feedings." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Identifiers assigned to this order", - description=( - "Identifiers assigned to this order by the order sender or by the order" - " receiver." - ), - # if property is element of this resource. - element_property=True, - ) - - instantiates: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiates", - title="Instantiates protocol or definition", - description=( - "The URL pointing to a protocol, guideline, orderset or other " - "definition that is adhered to in whole or in part by this " - "NutritionOrder." - ), - # if property is element of this resource. - element_property=True, - ) - instantiates__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiates", title="Extension field for ``instantiates``." - ) - - instantiatesCanonical: typing.List[fhirtypes.Canonical] = Field( - None, - alias="instantiatesCanonical", - title="Instantiates FHIR protocol or definition", - description=( - "The URL pointing to a FHIR-defined protocol, guideline, orderset or " - "other definition that is adhered to in whole or in part by this " - "NutritionOrder." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ActivityDefinition", "PlanDefinition"], - ) - instantiatesCanonical__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_instantiatesCanonical", - title="Extension field for ``instantiatesCanonical``.", - ) - - instantiatesUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiatesUri", - title="Instantiates external protocol or definition", - description=( - "The URL pointing to an externally maintained protocol, guideline, " - "orderset or other definition that is adhered to in whole or in part by" - " this NutritionOrder." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - intent: fhirtypes.Code = Field( - None, - alias="intent", - title=( - "proposal | plan | directive | order | original-order | reflex-order | " - "filler-order | instance-order | option" - ), - description=( - "Indicates the level of authority/intentionality associated with the " - "NutrionOrder and where the request fits into the workflow chain." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "proposal", - "plan", - "directive", - "order", - "original-order", - "reflex-order", - "filler-order", - "instance-order", - "option", - ], - ) - intent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_intent", title="Extension field for ``intent``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments", - description=( - "Comments made about the {{title}} by the requester, performer, subject" - " or other participants." - ), - # if property is element of this resource. - element_property=True, - ) - - oralDiet: fhirtypes.NutritionOrderOralDietType = Field( - None, - alias="oralDiet", - title="Oral diet components", - description="Diet given orally in contrast to enteral (tube) feeding.", - # if property is element of this resource. - element_property=True, - ) - - orderer: fhirtypes.ReferenceType = Field( - None, - alias="orderer", - title="Who ordered the diet, formula or nutritional supplement", - description=( - "The practitioner that holds legal responsibility for ordering the " - "diet, nutritional supplement, or formula feedings." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="The person who requires the diet, formula or nutritional supplement", - description=( - "The person (patient) who needs the nutrition order for an oral diet, " - "nutritional supplement and/or enteral or formula feeding." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "draft | active | on-hold | revoked | completed | entered-in-error | " - "unknown" - ), - description="The workflow status of the nutrition order/request.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "draft", - "active", - "on-hold", - "revoked", - "completed", - "entered-in-error", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - supplement: typing.List[fhirtypes.NutritionOrderSupplementType] = Field( - None, - alias="supplement", - title="Supplement components", - description=( - "Oral nutritional products given in order to add further nutritional " - "value to the patient's diet." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``NutritionOrder`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "instantiatesCanonical", - "instantiatesUri", - "instantiates", - "status", - "intent", - "patient", - "encounter", - "dateTime", - "orderer", - "allergyIntolerance", - "foodPreferenceModifier", - "excludeFoodModifier", - "oralDiet", - "supplement", - "enteralFormula", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1672( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("dateTime", "dateTime__ext"), - ("intent", "intent__ext"), - ("status", "status__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class NutritionOrderEnteralFormula(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Enteral formula components. - Feeding provided through the gastrointestinal tract via a tube, catheter, - or stoma that delivers nutrition distal to the oral cavity. - """ - - resource_type = Field("NutritionOrderEnteralFormula", const=True) - - additiveProductName: fhirtypes.String = Field( - None, - alias="additiveProductName", - title="Product or brand name of the modular additive", - description=( - "The product or brand name of the type of modular component to be added" - " to the formula." - ), - # if property is element of this resource. - element_property=True, - ) - additiveProductName__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_additiveProductName", - title="Extension field for ``additiveProductName``.", - ) - - additiveType: fhirtypes.CodeableConceptType = Field( - None, - alias="additiveType", - title="Type of modular component to add to the feeding", - description=( - "Indicates the type of modular component such as protein, carbohydrate," - " fat or fiber to be provided in addition to or mixed with the base " - "formula." - ), - # if property is element of this resource. - element_property=True, - ) - - administration: typing.List[ - fhirtypes.NutritionOrderEnteralFormulaAdministrationType - ] = Field( - None, - alias="administration", - title="Formula feeding instruction as structured data", - description=( - "Formula administration instructions as structured data. This " - "repeating structure allows for changing the administration rate or " - "volume over time for both bolus and continuous feeding. An example of" - " this would be an instruction to increase the rate of continuous " - "feeding every 2 hours." - ), - # if property is element of this resource. - element_property=True, - ) - - administrationInstruction: fhirtypes.String = Field( - None, - alias="administrationInstruction", - title="Formula feeding instructions expressed as text", - description=( - "Free text formula administration, feeding instructions or additional " - "instructions or information." - ), - # if property is element of this resource. - element_property=True, - ) - administrationInstruction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_administrationInstruction", - title="Extension field for ``administrationInstruction``.", - ) - - baseFormulaProductName: fhirtypes.String = Field( - None, - alias="baseFormulaProductName", - title="Product or brand name of the enteral or infant formula", - description=( - "The product or brand name of the enteral or infant formula product " - 'such as "ACME Adult Standard Formula".' - ), - # if property is element of this resource. - element_property=True, - ) - baseFormulaProductName__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_baseFormulaProductName", - title="Extension field for ``baseFormulaProductName``.", - ) - - baseFormulaType: fhirtypes.CodeableConceptType = Field( - None, - alias="baseFormulaType", - title="Type of enteral or infant formula", - description=( - "The type of enteral or infant formula such as an adult standard " - "formula with fiber or a soy-based infant formula." - ), - # if property is element of this resource. - element_property=True, - ) - - caloricDensity: fhirtypes.QuantityType = Field( - None, - alias="caloricDensity", - title="Amount of energy per specified volume that is required", - description=( - "The amount of energy (calories) that the formula should provide per " - "specified volume, typically per mL or fluid oz. For example, an " - "infant may require a formula that provides 24 calories per fluid ounce" - " or an adult may require an enteral formula that provides 1.5 " - "calorie/mL." - ), - # if property is element of this resource. - element_property=True, - ) - - maxVolumeToDeliver: fhirtypes.QuantityType = Field( - None, - alias="maxVolumeToDeliver", - title="Upper limit on formula volume per unit of time", - description=( - "The maximum total quantity of formula that may be administered to a " - "subject over the period of time, e.g. 1440 mL over 24 hours." - ), - # if property is element of this resource. - element_property=True, - ) - - routeofAdministration: fhirtypes.CodeableConceptType = Field( - None, - alias="routeofAdministration", - title="How the formula should enter the patient's gastrointestinal tract", - description=( - "The route or physiological path of administration into the patient's " - "gastrointestinal tract for purposes of providing the formula feeding," - " e.g. nasogastric tube." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``NutritionOrderEnteralFormula`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "baseFormulaType", - "baseFormulaProductName", - "additiveType", - "additiveProductName", - "caloricDensity", - "routeofAdministration", - "administration", - "maxVolumeToDeliver", - "administrationInstruction", - ] - - -class NutritionOrderEnteralFormulaAdministration(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Formula feeding instruction as structured data. - Formula administration instructions as structured data. This repeating - structure allows for changing the administration rate or volume over time - for both bolus and continuous feeding. An example of this would be an - instruction to increase the rate of continuous feeding every 2 hours. - """ - - resource_type = Field("NutritionOrderEnteralFormulaAdministration", const=True) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="The volume of formula to provide", - description=( - "The volume of formula to provide to the patient per the specified " - "administration schedule." - ), - # if property is element of this resource. - element_property=True, - ) - - rateQuantity: fhirtypes.QuantityType = Field( - None, - alias="rateQuantity", - title="Speed with which the formula is provided per period of time", - description=( - "The rate of administration of formula via a feeding pump, e.g. 60 mL " - "per hour, according to the specified schedule." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e rate[x] - one_of_many="rate", - one_of_many_required=False, - ) - - rateRatio: fhirtypes.RatioType = Field( - None, - alias="rateRatio", - title="Speed with which the formula is provided per period of time", - description=( - "The rate of administration of formula via a feeding pump, e.g. 60 mL " - "per hour, according to the specified schedule." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e rate[x] - one_of_many="rate", - one_of_many_required=False, - ) - - schedule: fhirtypes.TimingType = Field( - None, - alias="schedule", - title="Scheduled frequency of enteral feeding", - description=( - "The time period and frequency at which the enteral formula should be " - "delivered to the patient." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``NutritionOrderEnteralFormulaAdministration`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "schedule", - "quantity", - "rateQuantity", - "rateRatio", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4587( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"rate": ["rateQuantity", "rateRatio"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class NutritionOrderOralDiet(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Oral diet components. - Diet given orally in contrast to enteral (tube) feeding. - """ - - resource_type = Field("NutritionOrderOralDiet", const=True) - - fluidConsistencyType: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="fluidConsistencyType", - title="The required consistency of fluids and liquids provided to the patient", - description=( - "The required consistency (e.g. honey-thick, nectar-thick, thin, " - "thickened.) of liquids or fluids served to the patient." - ), - # if property is element of this resource. - element_property=True, - ) - - instruction: fhirtypes.String = Field( - None, - alias="instruction", - title="Instructions or additional information about the oral diet", - description=( - "Free text or additional instructions or information pertaining to the " - "oral diet." - ), - # if property is element of this resource. - element_property=True, - ) - instruction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_instruction", title="Extension field for ``instruction``." - ) - - nutrient: typing.List[fhirtypes.NutritionOrderOralDietNutrientType] = Field( - None, - alias="nutrient", - title="Required nutrient modifications", - description=( - "Class that defines the quantity and type of nutrient modifications " - "(for example carbohydrate, fiber or sodium) required for the oral " - "diet." - ), - # if property is element of this resource. - element_property=True, - ) - - schedule: typing.List[fhirtypes.TimingType] = Field( - None, - alias="schedule", - title="Scheduled frequency of diet", - description=( - "The time period and frequency at which the diet should be given. The " - "diet should be given for the combination of all schedules if more than" - " one schedule is present." - ), - # if property is element of this resource. - element_property=True, - ) - - texture: typing.List[fhirtypes.NutritionOrderOralDietTextureType] = Field( - None, - alias="texture", - title="Required texture modifications", - description=( - "Class that describes any texture modifications required for the " - "patient to safely consume various types of solid foods." - ), - # if property is element of this resource. - element_property=True, - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title=( - "Type of oral diet or diet restrictions that describe what can be " - "consumed orally" - ), - description=( - "The kind of diet or dietary restriction such as fiber restricted diet " - "or diabetic diet." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``NutritionOrderOralDiet`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "schedule", - "nutrient", - "texture", - "fluidConsistencyType", - "instruction", - ] - - -class NutritionOrderOralDietNutrient(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Required nutrient modifications. - Class that defines the quantity and type of nutrient modifications (for - example carbohydrate, fiber or sodium) required for the oral diet. - """ - - resource_type = Field("NutritionOrderOralDietNutrient", const=True) - - amount: fhirtypes.QuantityType = Field( - None, - alias="amount", - title="Quantity of the specified nutrient", - description="The quantity of the specified nutrient to include in diet.", - # if property is element of this resource. - element_property=True, - ) - - modifier: fhirtypes.CodeableConceptType = Field( - None, - alias="modifier", - title="Type of nutrient that is being modified", - description="The nutrient that is being modified such as carbohydrate or sodium.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``NutritionOrderOralDietNutrient`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "modifier", "amount"] - - -class NutritionOrderOralDietTexture(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Required texture modifications. - Class that describes any texture modifications required for the patient to - safely consume various types of solid foods. - """ - - resource_type = Field("NutritionOrderOralDietTexture", const=True) - - foodType: fhirtypes.CodeableConceptType = Field( - None, - alias="foodType", - title=( - "Concepts that are used to identify an entity that is ingested for " - "nutritional purposes" - ), - description=( - "The food type(s) (e.g. meats, all foods) that the texture " - "modification applies to. This could be all foods types." - ), - # if property is element of this resource. - element_property=True, - ) - - modifier: fhirtypes.CodeableConceptType = Field( - None, - alias="modifier", - title="Code to indicate how to alter the texture of the foods, e.g. pureed", - description=( - "Any texture modifications (for solid foods) that should be made, e.g. " - "easy to chew, chopped, ground, and pureed." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``NutritionOrderOralDietTexture`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "modifier", "foodType"] - - -class NutritionOrderSupplement(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Supplement components. - Oral nutritional products given in order to add further nutritional value - to the patient's diet. - """ - - resource_type = Field("NutritionOrderSupplement", const=True) - - instruction: fhirtypes.String = Field( - None, - alias="instruction", - title="Instructions or additional information about the oral supplement", - description=( - "Free text or additional instructions or information pertaining to the " - "oral supplement." - ), - # if property is element of this resource. - element_property=True, - ) - instruction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_instruction", title="Extension field for ``instruction``." - ) - - productName: fhirtypes.String = Field( - None, - alias="productName", - title="Product or brand name of the nutritional supplement", - description=( - 'The product or brand name of the nutritional supplement such as "Acme ' - 'Protein Shake".' - ), - # if property is element of this resource. - element_property=True, - ) - productName__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_productName", title="Extension field for ``productName``." - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Amount of the nutritional supplement", - description="The amount of the nutritional supplement to be given.", - # if property is element of this resource. - element_property=True, - ) - - schedule: typing.List[fhirtypes.TimingType] = Field( - None, - alias="schedule", - title="Scheduled frequency of supplement", - description=( - "The time period and frequency at which the supplement(s) should be " - "given. The supplement should be given for the combination of all " - "schedules if more than one schedule is present." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of supplement product requested", - description=( - "The kind of nutritional supplement product required such as a high " - "protein or pediatric clear liquid supplement." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``NutritionOrderSupplement`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "productName", - "schedule", - "quantity", - "instruction", - ] diff --git a/fhir/resources/observation.py b/fhir/resources/observation.py deleted file mode 100644 index b2d0ec30..00000000 --- a/fhir/resources/observation.py +++ /dev/null @@ -1,1227 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Observation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Observation(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Measurements and simple assertions. - Measurements and simple assertions made about a patient, device or other - subject. - """ - - resource_type = Field("Observation", const=True) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Fulfills plan, proposal or order", - description=( - "A plan, proposal or order that is fulfilled in whole or in part by " - "this event. For example, a MedicationRequest may require a patient to" - " have laboratory test performed before it is dispensed." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "CarePlan", - "DeviceRequest", - "ImmunizationRecommendation", - "MedicationRequest", - "NutritionOrder", - "ServiceRequest", - ], - ) - - bodySite: fhirtypes.CodeableConceptType = Field( - None, - alias="bodySite", - title="Observed body part", - description=( - "Indicates the site on the subject's body where the observation was " - "made (i.e. the target site)." - ), - # if property is element of this resource. - element_property=True, - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Classification of type of observation", - description="A code that classifies the general type of observation being made.", - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Type of observation (code / type)", - description=( - "Describes what was observed. Sometimes this is called the observation " - '"name".' - ), - # if property is element of this resource. - element_property=True, - ) - - component: typing.List[fhirtypes.ObservationComponentType] = Field( - None, - alias="component", - title="Component results", - description=( - "Some observations have multiple component observations. These " - "component observations are expressed as separate code value pairs that" - " share the same attributes. Examples include systolic and diastolic " - "component observations for blood pressure measurement and multiple " - "component observations for genetics observations." - ), - # if property is element of this resource. - element_property=True, - ) - - dataAbsentReason: fhirtypes.CodeableConceptType = Field( - None, - alias="dataAbsentReason", - title="Why the result is missing", - description=( - "Provides a reason why the expected value in the element " - "Observation.value[x] is missing." - ), - # if property is element of this resource. - element_property=True, - ) - - derivedFrom: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="derivedFrom", - title="Related measurements the observation is made from", - description=( - "The target resource that represents a measurement from which this " - "observation value is derived. For example, a calculated anion gap or a" - " fetal measurement based on an ultrasound image." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "DocumentReference", - "ImagingStudy", - "Media", - "QuestionnaireResponse", - "Observation", - "MolecularSequence", - ], - ) - - device: fhirtypes.ReferenceType = Field( - None, - alias="device", - title="(Measurement) Device", - description="The device used to generate the observation data.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device", "DeviceMetric"], - ) - - effectiveDateTime: fhirtypes.DateTime = Field( - None, - alias="effectiveDateTime", - title="Clinically relevant time/time-period for observation", - description=( - "The time or time-period the observed value is asserted as being true. " - "For biological subjects - e.g. human patients - this is usually called" - ' the "physiologically relevant time". This is usually either the time ' - "of the procedure or of specimen collection, but very often the source " - "of the date/time is not known, only the date/time itself." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=False, - ) - effectiveDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_effectiveDateTime", - title="Extension field for ``effectiveDateTime``.", - ) - - effectiveInstant: fhirtypes.Instant = Field( - None, - alias="effectiveInstant", - title="Clinically relevant time/time-period for observation", - description=( - "The time or time-period the observed value is asserted as being true. " - "For biological subjects - e.g. human patients - this is usually called" - ' the "physiologically relevant time". This is usually either the time ' - "of the procedure or of specimen collection, but very often the source " - "of the date/time is not known, only the date/time itself." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=False, - ) - effectiveInstant__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_effectiveInstant", - title="Extension field for ``effectiveInstant``.", - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="Clinically relevant time/time-period for observation", - description=( - "The time or time-period the observed value is asserted as being true. " - "For biological subjects - e.g. human patients - this is usually called" - ' the "physiologically relevant time". This is usually either the time ' - "of the procedure or of specimen collection, but very often the source " - "of the date/time is not known, only the date/time itself." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=False, - ) - - effectiveTiming: fhirtypes.TimingType = Field( - None, - alias="effectiveTiming", - title="Clinically relevant time/time-period for observation", - description=( - "The time or time-period the observed value is asserted as being true. " - "For biological subjects - e.g. human patients - this is usually called" - ' the "physiologically relevant time". This is usually either the time ' - "of the procedure or of specimen collection, but very often the source " - "of the date/time is not known, only the date/time itself." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e effective[x] - one_of_many="effective", - one_of_many_required=False, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Healthcare event during which this observation is made", - description=( - "The healthcare event (e.g. a patient and healthcare provider " - "interaction) during which this observation is made." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - focus: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="focus", - title=( - "What the observation is about, when it is not about the subject of " - "record" - ), - description=( - "The actual focus of an observation when it is not the patient of " - "record representing something or someone associated with the patient " - "such as a spouse, parent, fetus, or donor. For example, fetus " - "observations in a mother's record. The focus of an observation could " - "also be an existing condition, an intervention, the subject's diet, " - "another observation of the subject, or a body structure such as tumor" - " or implanted device. An example use case would be using the " - "Observation resource to capture whether the mother is trained to " - "change her child's tracheostomy tube. In this example, the child is " - "the patient of record and the mother is the focus." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - hasMember: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="hasMember", - title="Related resource that belongs to the Observation group", - description=( - "This observation is a group observation (e.g. a battery, a panel of " - "tests, a set of vital sign measurements) that includes the target as a" - " member of the group." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Observation", - "QuestionnaireResponse", - "MolecularSequence", - ], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for observation", - description="A unique identifier assigned to this observation.", - # if property is element of this resource. - element_property=True, - ) - - interpretation: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="interpretation", - title="High, low, normal, etc.", - description=( - "A categorical assessment of an observation value. For example, high, " - "low, normal." - ), - # if property is element of this resource. - element_property=True, - ) - - issued: fhirtypes.Instant = Field( - None, - alias="issued", - title="Date/Time this version was made available", - description=( - "The date and time this version of the observation was made available " - "to providers, typically after the results have been reviewed and " - "verified." - ), - # if property is element of this resource. - element_property=True, - ) - issued__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_issued", title="Extension field for ``issued``." - ) - - method: fhirtypes.CodeableConceptType = Field( - None, - alias="method", - title="How it was done", - description="Indicates the mechanism used to perform the observation.", - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments about the observation", - description="Comments about the observation or the results.", - # if property is element of this resource. - element_property=True, - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Part of referenced event", - description=( - "A larger event of which this particular Observation is a component or " - "step. For example, an observation as part of a procedure." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "MedicationAdministration", - "MedicationDispense", - "MedicationStatement", - "Procedure", - "Immunization", - "ImagingStudy", - ], - ) - - performer: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="performer", - title="Who is responsible for the observation", - description='Who was responsible for asserting the observed value as "true".', - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "CareTeam", - "Patient", - "RelatedPerson", - ], - ) - - referenceRange: typing.List[fhirtypes.ObservationReferenceRangeType] = Field( - None, - alias="referenceRange", - title="Provides guide for interpretation", - description=( - "Guidance on how to interpret the value by comparison to a normal or " - "recommended range. Multiple reference ranges are interpreted as an " - '"OR". In other words, to represent two distinct target populations, ' - "two `referenceRange` elements would be used." - ), - # if property is element of this resource. - element_property=True, - ) - - specimen: fhirtypes.ReferenceType = Field( - None, - alias="specimen", - title="Specimen used for this observation", - description="The specimen that was used when this observation was made.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Specimen"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="registered | preliminary | final | amended +", - description="The status of the result value.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["registered", "preliminary", "final", "amended", "+"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Who and/or what the observation is about", - description=( - "The patient, or group of patients, location, or device this " - "observation is about and into whose record the observation is placed. " - "If the actual focus of the observation is different from the subject " - "(or a sample of, part, or region of the subject), the `focus` element " - "or the `code` itself specifies the actual focus of the observation." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group", "Device", "Location"], - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Actual result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="Actual result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="Actual result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Actual result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valuePeriod: fhirtypes.PeriodType = Field( - None, - alias="valuePeriod", - title="Actual result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Actual result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRange: fhirtypes.RangeType = Field( - None, - alias="valueRange", - title="Actual result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRatio: fhirtypes.RatioType = Field( - None, - alias="valueRatio", - title="Actual result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueSampledData: fhirtypes.SampledDataType = Field( - None, - alias="valueSampledData", - title="Actual result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Actual result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - valueTime: fhirtypes.Time = Field( - None, - alias="valueTime", - title="Actual result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueTime", title="Extension field for ``valueTime``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Observation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "basedOn", - "partOf", - "status", - "category", - "code", - "subject", - "focus", - "encounter", - "effectiveDateTime", - "effectivePeriod", - "effectiveTiming", - "effectiveInstant", - "issued", - "performer", - "valueQuantity", - "valueCodeableConcept", - "valueString", - "valueBoolean", - "valueInteger", - "valueRange", - "valueRatio", - "valueSampledData", - "valueTime", - "valueDateTime", - "valuePeriod", - "dataAbsentReason", - "interpretation", - "note", - "bodySite", - "method", - "specimen", - "device", - "referenceRange", - "hasMember", - "derivedFrom", - "component", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1353( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1353( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "effective": [ - "effectiveDateTime", - "effectiveInstant", - "effectivePeriod", - "effectiveTiming", - ], - "value": [ - "valueBoolean", - "valueCodeableConcept", - "valueDateTime", - "valueInteger", - "valuePeriod", - "valueQuantity", - "valueRange", - "valueRatio", - "valueSampledData", - "valueString", - "valueTime", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ObservationComponent(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Component results. - Some observations have multiple component observations. These component - observations are expressed as separate code value pairs that share the same - attributes. Examples include systolic and diastolic component observations - for blood pressure measurement and multiple component observations for - genetics observations. - """ - - resource_type = Field("ObservationComponent", const=True) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Type of component observation (code / type)", - description=( - "Describes what was observed. Sometimes this is called the observation " - '"code".' - ), - # if property is element of this resource. - element_property=True, - ) - - dataAbsentReason: fhirtypes.CodeableConceptType = Field( - None, - alias="dataAbsentReason", - title="Why the component result is missing", - description=( - "Provides a reason why the expected value in the element " - "Observation.component.value[x] is missing." - ), - # if property is element of this resource. - element_property=True, - ) - - interpretation: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="interpretation", - title="High, low, normal, etc.", - description=( - "A categorical assessment of an observation value. For example, high, " - "low, normal." - ), - # if property is element of this resource. - element_property=True, - ) - - referenceRange: typing.List[fhirtypes.ObservationReferenceRangeType] = Field( - None, - alias="referenceRange", - title="Provides guide for interpretation of component result", - description=( - "Guidance on how to interpret the value by comparison to a normal or " - "recommended range." - ), - # if property is element of this resource. - element_property=True, - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Actual component result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="Actual component result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="Actual component result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Actual component result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valuePeriod: fhirtypes.PeriodType = Field( - None, - alias="valuePeriod", - title="Actual component result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Actual component result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRange: fhirtypes.RangeType = Field( - None, - alias="valueRange", - title="Actual component result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRatio: fhirtypes.RatioType = Field( - None, - alias="valueRatio", - title="Actual component result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueSampledData: fhirtypes.SampledDataType = Field( - None, - alias="valueSampledData", - title="Actual component result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Actual component result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - valueTime: fhirtypes.Time = Field( - None, - alias="valueTime", - title="Actual component result", - description=( - "The information determined as a result of making the observation, if " - "the information has a simple value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueTime", title="Extension field for ``valueTime``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ObservationComponent`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "valueQuantity", - "valueCodeableConcept", - "valueString", - "valueBoolean", - "valueInteger", - "valueRange", - "valueRatio", - "valueSampledData", - "valueTime", - "valueDateTime", - "valuePeriod", - "dataAbsentReason", - "interpretation", - "referenceRange", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2306( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueBoolean", - "valueCodeableConcept", - "valueDateTime", - "valueInteger", - "valuePeriod", - "valueQuantity", - "valueRange", - "valueRatio", - "valueSampledData", - "valueString", - "valueTime", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ObservationReferenceRange(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Provides guide for interpretation. - Guidance on how to interpret the value by comparison to a normal or - recommended range. Multiple reference ranges are interpreted as an "OR". - In other words, to represent two distinct target populations, two - `referenceRange` elements would be used. - """ - - resource_type = Field("ObservationReferenceRange", const=True) - - age: fhirtypes.RangeType = Field( - None, - alias="age", - title="Applicable age range, if relevant", - description=( - "The age at which this reference range is applicable. This is a " - "neonatal age (e.g. number of weeks at term) if the meaning says so." - ), - # if property is element of this resource. - element_property=True, - ) - - appliesTo: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="appliesTo", - title="Reference range population", - description=( - "Codes to indicate the target population this reference range applies " - "to. For example, a reference range may be based on the normal " - "population or a particular sex or race. Multiple `appliesTo` are " - 'interpreted as an "AND" of the target populations. For example, to ' - "represent a target population of African American females, both a code" - " of female and a code for African American would be used." - ), - # if property is element of this resource. - element_property=True, - ) - - high: fhirtypes.QuantityType = Field( - None, - alias="high", - title="High Range, if relevant", - description=( - "The value of the high bound of the reference range. The high bound of" - " the reference range endpoint is inclusive of the value (e.g. " - "reference range is >=5 - <=9). If the high bound is omitted, it is " - "assumed to be meaningless (e.g. reference range is >= 2.3)." - ), - # if property is element of this resource. - element_property=True, - ) - - low: fhirtypes.QuantityType = Field( - None, - alias="low", - title="Low Range, if relevant", - description=( - "The value of the low bound of the reference range. The low bound of " - "the reference range endpoint is inclusive of the value (e.g. " - "reference range is >=5 - <=9). If the low bound is omitted, it is " - "assumed to be meaningless (e.g. reference range is <=2.3)." - ), - # if property is element of this resource. - element_property=True, - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Text based reference range in an observation", - description=( - "Text based reference range in an observation which may be used when a " - "quantitative range is not appropriate for an observation. An example " - 'would be a reference value of "Negative" or a list or table of ' - '"normals".' - ), - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Reference range qualifier", - description=( - "Codes to indicate the what part of the targeted reference population " - "it applies to. For example, the normal or therapeutic range." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ObservationReferenceRange`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "low", - "high", - "type", - "appliesTo", - "age", - "text", - ] diff --git a/fhir/resources/observationdefinition.py b/fhir/resources/observationdefinition.py deleted file mode 100644 index cd842be0..00000000 --- a/fhir/resources/observationdefinition.py +++ /dev/null @@ -1,482 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ObservationDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class ObservationDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Definition of an observation. - Set of definitional characteristics for a kind of observation or - measurement produced or consumed by an orderable health care service. - """ - - resource_type = Field("ObservationDefinition", const=True) - - abnormalCodedValueSet: fhirtypes.ReferenceType = Field( - None, - alias="abnormalCodedValueSet", - title=( - "Value set of abnormal coded values for the observations conforming to " - "this ObservationDefinition" - ), - description=( - "The set of abnormal coded results for the observation conforming to " - "this ObservationDefinition." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Category of observation", - description="A code that classifies the general type of observation.", - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Type of observation (code / type)", - description=( - "Describes what will be observed. Sometimes this is called the " - 'observation "name".' - ), - # if property is element of this resource. - element_property=True, - ) - - criticalCodedValueSet: fhirtypes.ReferenceType = Field( - None, - alias="criticalCodedValueSet", - title=( - "Value set of critical coded values for the observations conforming to " - "this ObservationDefinition" - ), - description=( - "The set of critical coded results for the observation conforming to " - "this ObservationDefinition." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier for this ObservationDefinition instance", - description="A unique identifier assigned to this ObservationDefinition artifact.", - # if property is element of this resource. - element_property=True, - ) - - method: fhirtypes.CodeableConceptType = Field( - None, - alias="method", - title="Method used to produce the observation", - description="The method or technique used to perform the observation.", - # if property is element of this resource. - element_property=True, - ) - - multipleResultsAllowed: bool = Field( - None, - alias="multipleResultsAllowed", - title="Multiple results allowed", - description=( - "Multiple results allowed for observations conforming to this " - "ObservationDefinition." - ), - # if property is element of this resource. - element_property=True, - ) - multipleResultsAllowed__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_multipleResultsAllowed", - title="Extension field for ``multipleResultsAllowed``.", - ) - - normalCodedValueSet: fhirtypes.ReferenceType = Field( - None, - alias="normalCodedValueSet", - title=( - "Value set of normal coded values for the observations conforming to " - "this ObservationDefinition" - ), - description=( - "The set of normal coded results for the observations conforming to " - "this ObservationDefinition." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - - permittedDataType: typing.List[fhirtypes.Code] = Field( - None, - alias="permittedDataType", - title=( - "Quantity | CodeableConcept | string | boolean | integer | Range | " - "Ratio | SampledData | time | dateTime | Period" - ), - description=( - "The data types allowed for the value element of the instance " - "observations conforming to this ObservationDefinition." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "Quantity", - "CodeableConcept", - "string", - "boolean", - "integer", - "Range", - "Ratio", - "SampledData", - "time", - "dateTime", - "Period", - ], - ) - permittedDataType__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_permittedDataType", - title="Extension field for ``permittedDataType``.", - ) - - preferredReportName: fhirtypes.String = Field( - None, - alias="preferredReportName", - title="Preferred report name", - description=( - "The preferred name to be used when reporting the results of " - "observations conforming to this ObservationDefinition." - ), - # if property is element of this resource. - element_property=True, - ) - preferredReportName__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_preferredReportName", - title="Extension field for ``preferredReportName``.", - ) - - qualifiedInterval: typing.List[ - fhirtypes.ObservationDefinitionQualifiedIntervalType - ] = Field( - None, - alias="qualifiedInterval", - title="Qualified range for continuous and ordinal observation results", - description=( - "Multiple ranges of results qualified by different contexts for " - "ordinal or continuous observations conforming to this " - "ObservationDefinition." - ), - # if property is element of this resource. - element_property=True, - ) - - quantitativeDetails: fhirtypes.ObservationDefinitionQuantitativeDetailsType = Field( - None, - alias="quantitativeDetails", - title="Characteristics of quantitative results", - description="Characteristics for quantitative results of this observation.", - # if property is element of this resource. - element_property=True, - ) - - validCodedValueSet: fhirtypes.ReferenceType = Field( - None, - alias="validCodedValueSet", - title=( - "Value set of valid coded values for the observations conforming to " - "this ObservationDefinition" - ), - description=( - "The set of valid coded results for the observations conforming to " - "this ObservationDefinition." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ObservationDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "category", - "code", - "identifier", - "permittedDataType", - "multipleResultsAllowed", - "method", - "preferredReportName", - "quantitativeDetails", - "qualifiedInterval", - "validCodedValueSet", - "normalCodedValueSet", - "abnormalCodedValueSet", - "criticalCodedValueSet", - ] - - -class ObservationDefinitionQualifiedInterval(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Qualified range for continuous and ordinal observation results. - Multiple ranges of results qualified by different contexts for ordinal or - continuous observations conforming to this ObservationDefinition. - """ - - resource_type = Field("ObservationDefinitionQualifiedInterval", const=True) - - age: fhirtypes.RangeType = Field( - None, - alias="age", - title="Applicable age range, if relevant", - description=( - "The age at which this reference range is applicable. This is a " - "neonatal age (e.g. number of weeks at term) if the meaning says so." - ), - # if property is element of this resource. - element_property=True, - ) - - appliesTo: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="appliesTo", - title="Targetted population of the range", - description=( - "Codes to indicate the target population this reference range applies " - "to." - ), - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.Code = Field( - None, - alias="category", - title="reference | critical | absolute", - description=( - "The category of interval of values for continuous or ordinal " - "observations conforming to this ObservationDefinition." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["reference", "critical", "absolute"], - ) - category__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_category", title="Extension field for ``category``." - ) - - condition: fhirtypes.String = Field( - None, - alias="condition", - title="Condition associated with the reference range", - description="Text based condition for which the reference range is valid.", - # if property is element of this resource. - element_property=True, - ) - condition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_condition", title="Extension field for ``condition``." - ) - - context: fhirtypes.CodeableConceptType = Field( - None, - alias="context", - title="Range context qualifier", - description=( - "Codes to indicate the health context the range applies to. For " - "example, the normal or therapeutic range." - ), - # if property is element of this resource. - element_property=True, - ) - - gender: fhirtypes.Code = Field( - None, - alias="gender", - title="male | female | other | unknown", - description="Sex of the population the range applies to.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["male", "female", "other", "unknown"], - ) - gender__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_gender", title="Extension field for ``gender``." - ) - - gestationalAge: fhirtypes.RangeType = Field( - None, - alias="gestationalAge", - title="Applicable gestational age range, if relevant", - description=( - "The gestational age to which this reference range is applicable, in " - "the context of pregnancy." - ), - # if property is element of this resource. - element_property=True, - ) - - range: fhirtypes.RangeType = Field( - None, - alias="range", - title="The interval itself, for continuous or ordinal observations", - description=( - "The low and high values determining the interval. There may be only " - "one of the two." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ObservationDefinitionQualifiedInterval`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "category", - "range", - "context", - "appliesTo", - "gender", - "age", - "gestationalAge", - "condition", - ] - - -class ObservationDefinitionQuantitativeDetails(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Characteristics of quantitative results. - Characteristics for quantitative results of this observation. - """ - - resource_type = Field("ObservationDefinitionQuantitativeDetails", const=True) - - conversionFactor: fhirtypes.Decimal = Field( - None, - alias="conversionFactor", - title="SI to Customary unit conversion factor", - description=( - "Factor for converting value expressed with SI unit to value expressed " - "with customary unit." - ), - # if property is element of this resource. - element_property=True, - ) - conversionFactor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_conversionFactor", - title="Extension field for ``conversionFactor``.", - ) - - customaryUnit: fhirtypes.CodeableConceptType = Field( - None, - alias="customaryUnit", - title="Customary unit for quantitative results", - description=( - "Customary unit used to report quantitative results of observations " - "conforming to this ObservationDefinition." - ), - # if property is element of this resource. - element_property=True, - ) - - decimalPrecision: fhirtypes.Integer = Field( - None, - alias="decimalPrecision", - title="Decimal precision of observation quantitative results", - description=( - "Number of digits after decimal separator when the results of such " - "observations are of type Quantity." - ), - # if property is element of this resource. - element_property=True, - ) - decimalPrecision__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_decimalPrecision", - title="Extension field for ``decimalPrecision``.", - ) - - unit: fhirtypes.CodeableConceptType = Field( - None, - alias="unit", - title="SI unit for quantitative results", - description=( - "SI unit used to report quantitative results of observations conforming" - " to this ObservationDefinition." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ObservationDefinitionQuantitativeDetails`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "customaryUnit", - "unit", - "conversionFactor", - "decimalPrecision", - ] diff --git a/fhir/resources/operationdefinition.py b/fhir/resources/operationdefinition.py deleted file mode 100644 index bef1abde..00000000 --- a/fhir/resources/operationdefinition.py +++ /dev/null @@ -1,1097 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/OperationDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class OperationDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Definition of an operation or a named query. - A formal computable definition of an operation (on the RESTful interface) - or a named query (using the search interaction). - """ - - resource_type = Field("OperationDefinition", const=True) - - affectsState: bool = Field( - None, - alias="affectsState", - title="Whether content is changed by the operation", - description=( - "Whether the operation affects state. Side effects such as producing " - "audit trail entries do not count as 'affecting state'." - ), - # if property is element of this resource. - element_property=True, - ) - affectsState__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_affectsState", title="Extension field for ``affectsState``." - ) - - base: fhirtypes.Canonical = Field( - None, - alias="base", - title="Marks this as a profile of the base", - description=( - "Indicates that this operation definition is a constraining profile on " - "the base." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["OperationDefinition"], - ) - base__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_base", title="Extension field for ``base``." - ) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Name used to invoke the operation", - description="The name used to invoke the operation.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - comment: fhirtypes.Markdown = Field( - None, - alias="comment", - title="Additional information about use", - description="Additional information about how to use this operation or named query.", - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the operation definition was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the operation definition " - "changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the operation definition", - description=( - "A free text natural language description of the operation definition " - "from a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this operation definition is authored" - " for testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - inputProfile: fhirtypes.Canonical = Field( - None, - alias="inputProfile", - title="Validation information for in parameters", - description=( - "Additional validation information for the in parameters - a single " - "profile that covers all the parameters. The profile is a constraint on" - " the parameters resource as a whole." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - inputProfile__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_inputProfile", title="Extension field for ``inputProfile``." - ) - - instance: bool = Field( - None, - alias="instance", - title="Invoke on an instance?", - description=( - "Indicates whether this operation can be invoked on a particular " - "instance of one of the given types." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - instance__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_instance", title="Extension field for ``instance``." - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for operation definition (if applicable)", - description=( - "A legal or geographic region in which the operation definition is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - kind: fhirtypes.Code = Field( - None, - alias="kind", - title="operation | query", - description="Whether this is an operation or a named query.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["operation", "query"], - ) - kind__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_kind", title="Extension field for ``kind``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this operation definition (computer friendly)", - description=( - "A natural language name identifying the operation definition. This " - "name should be usable as an identifier for the module by machine " - "processing applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - outputProfile: fhirtypes.Canonical = Field( - None, - alias="outputProfile", - title="Validation information for out parameters", - description=( - "Additional validation information for the out parameters - a single " - "profile that covers all the parameters. The profile is a constraint on" - " the parameters resource." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - outputProfile__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_outputProfile", title="Extension field for ``outputProfile``." - ) - - overload: typing.List[fhirtypes.OperationDefinitionOverloadType] = Field( - None, - alias="overload", - title="Define overloaded variants for when generating code", - description=( - "Defines an appropriate combination of parameters to use when invoking " - "this operation, to help code generators when generating overloaded " - "parameter sets for this operation." - ), - # if property is element of this resource. - element_property=True, - ) - - parameter: typing.List[fhirtypes.OperationDefinitionParameterType] = Field( - None, - alias="parameter", - title="Parameters for the operation/query", - description="The parameters for the operation/query.", - # if property is element of this resource. - element_property=True, - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the " - "operation definition." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this operation definition is defined", - description=( - "Explanation of why this operation definition is needed and why it has " - "been designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - resource: typing.List[fhirtypes.Code] = Field( - None, - alias="resource", - title="Types this operation applies to", - description="The types on which this operation can be executed.", - # if property is element of this resource. - element_property=True, - ) - resource__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_resource", title="Extension field for ``resource``.") - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this operation definition. Enables tracking the life-" - "cycle of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - system: bool = Field( - None, - alias="system", - title="Invoke at the system level?", - description=( - "Indicates whether this operation or named query can be invoked at the " - "system level (e.g. without needing to choose a resource type for the " - "context)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - system__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_system", title="Extension field for ``system``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this operation definition (human friendly)", - description=( - "A short, descriptive, user-friendly title for the operation " "definition." - ), - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - type: bool = Field( - None, - alias="type", - title="Invoke at the type level?", - description=( - "Indicates whether this operation or named query can be invoked at the " - "resource type level for any given resource type level (e.g. without " - "needing to choose a specific resource id for the context)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this operation definition, represented as a " - "URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this operation definition " - "when it is referenced in a specification, model, design or an " - "instance; also called its canonical identifier. This SHOULD be " - "globally unique and SHOULD be a literal address at which at which an " - "authoritative instance of this operation definition is (or will be) " - "published. This URL can be the target of a canonical reference. It " - "SHALL remain the same when the operation definition is stored on " - "different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate operation definition instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the operation definition", - description=( - "The identifier that is used to identify this version of the operation " - "definition when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the operation " - "definition author and is not expected to be globally unique. For " - "example, it might be a timestamp (e.g. yyyymmdd) if a managed version " - "is not available. There is also no expectation that versions can be " - "placed in a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``OperationDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "version", - "name", - "title", - "status", - "kind", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "affectsState", - "code", - "comment", - "base", - "resource", - "system", - "type", - "instance", - "inputProfile", - "outputProfile", - "parameter", - "overload", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2167( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("code", "code__ext"), - ("instance", "instance__ext"), - ("kind", "kind__ext"), - ("name", "name__ext"), - ("status", "status__ext"), - ("system", "system__ext"), - ("type", "type__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class OperationDefinitionOverload(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Define overloaded variants for when generating code. - Defines an appropriate combination of parameters to use when invoking this - operation, to help code generators when generating overloaded parameter - sets for this operation. - """ - - resource_type = Field("OperationDefinitionOverload", const=True) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Comments to go on overload", - description=None, - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - parameterName: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="parameterName", - title="Name of parameter to include in overload", - description=None, - # if property is element of this resource. - element_property=True, - ) - parameterName__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_parameterName", title="Extension field for ``parameterName``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``OperationDefinitionOverload`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "parameterName", "comment"] - - -class OperationDefinitionParameter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Parameters for the operation/query. - The parameters for the operation/query. - """ - - resource_type = Field("OperationDefinitionParameter", const=True) - - binding: fhirtypes.OperationDefinitionParameterBindingType = Field( - None, - alias="binding", - title="ValueSet details if this is coded", - description=( - "Binds to a value set if this parameter is coded (code, Coding, " - "CodeableConcept)." - ), - # if property is element of this resource. - element_property=True, - ) - - documentation: fhirtypes.String = Field( - None, - alias="documentation", - title="Description of meaning/use", - description="Describes the meaning or use of this parameter.", - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - max: fhirtypes.String = Field( - None, - alias="max", - title="Maximum Cardinality (a number or *)", - description=( - "The maximum number of times this element is permitted to appear in the" - " request or response." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - max__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_max", title="Extension field for ``max``." - ) - - min: fhirtypes.Integer = Field( - None, - alias="min", - title="Minimum Cardinality", - description=( - "The minimum number of times this parameter SHALL appear in the request" - " or response." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - min__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_min", title="Extension field for ``min``." - ) - - name: fhirtypes.Code = Field( - None, - alias="name", - title="Name in Parameters.parameter.name or in URL", - description="The name of used to identify the parameter.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - part: typing.List[fhirtypes.OperationDefinitionParameterType] = Field( - None, - alias="part", - title="Parts of a nested Parameter", - description="The parts of a nested Parameter.", - # if property is element of this resource. - element_property=True, - ) - - referencedFrom: typing.List[ - fhirtypes.OperationDefinitionParameterReferencedFromType - ] = Field( - None, - alias="referencedFrom", - title="References to this parameter", - description=( - "Identifies other resource parameters within the operation invocation " - "that are expected to resolve to this resource." - ), - # if property is element of this resource. - element_property=True, - ) - - searchType: fhirtypes.Code = Field( - None, - alias="searchType", - title=( - "number | date | string | token | reference | composite | quantity | " - "uri | special" - ), - description=( - "How the parameter is understood as a search parameter. This is only " - "used if the parameter type is 'string'." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "number", - "date", - "string", - "token", - "reference", - "composite", - "quantity", - "uri", - "special", - ], - ) - searchType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_searchType", title="Extension field for ``searchType``." - ) - - targetProfile: typing.List[fhirtypes.Canonical] = Field( - None, - alias="targetProfile", - title="If type is Reference | canonical, allowed targets", - description=( - 'Used when the type is "Reference" or "canonical", and identifies a ' - "profile structure or implementation Guide that applies to the target " - "of the reference this parameter refers to. If any profiles are " - "specified, then the content must conform to at least one of them. The " - "URL can be a local reference - to a contained StructureDefinition, or " - "a reference to another StructureDefinition or Implementation Guide by " - "a canonical URL. When an implementation guide is specified, the target" - " resource SHALL conform to at least one profile defined in the " - "implementation guide." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - targetProfile__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_targetProfile", title="Extension field for ``targetProfile``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="What type this parameter has", - description="The type for this parameter.", - # if property is element of this resource. - element_property=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - use: fhirtypes.Code = Field( - None, - alias="use", - title="in | out", - description="Whether this is an input or an output parameter.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["in", "out"], - ) - use__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_use", title="Extension field for ``use``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``OperationDefinitionParameter`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "use", - "min", - "max", - "documentation", - "type", - "targetProfile", - "searchType", - "binding", - "referencedFrom", - "part", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3100( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("max", "max__ext"), - ("min", "min__ext"), - ("name", "name__ext"), - ("use", "use__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class OperationDefinitionParameterBinding(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - ValueSet details if this is coded. - Binds to a value set if this parameter is coded (code, Coding, - CodeableConcept). - """ - - resource_type = Field("OperationDefinitionParameterBinding", const=True) - - strength: fhirtypes.Code = Field( - None, - alias="strength", - title="required | extensible | preferred | example", - description=( - "Indicates the degree of conformance expectations associated with this " - "binding - that is, the degree to which the provided value set must be " - "adhered to in the instances." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["required", "extensible", "preferred", "example"], - ) - strength__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_strength", title="Extension field for ``strength``." - ) - - valueSet: fhirtypes.Canonical = Field( - None, - alias="valueSet", - title="Source of value set", - description=( - "Points to the value set or external definition (e.g. implicit value " - "set) that identifies the set of codes to be used." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - valueSet__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueSet", title="Extension field for ``valueSet``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``OperationDefinitionParameterBinding`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "strength", "valueSet"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3788( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("strength", "strength__ext"), ("valueSet", "valueSet__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class OperationDefinitionParameterReferencedFrom(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - References to this parameter. - Identifies other resource parameters within the operation invocation that - are expected to resolve to this resource. - """ - - resource_type = Field("OperationDefinitionParameterReferencedFrom", const=True) - - source: fhirtypes.String = Field( - None, - alias="source", - title="Referencing parameter", - description=( - "The name of the parameter or dot-separated path of parameter names " - "pointing to the resource parameter that is expected to contain a " - "reference to this resource." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - source__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_source", title="Extension field for ``source``." - ) - - sourceId: fhirtypes.String = Field( - None, - alias="sourceId", - title="Element id of reference", - description=( - "The id of the element in the referencing resource that is expected to " - "resolve to this resource." - ), - # if property is element of this resource. - element_property=True, - ) - sourceId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sourceId", title="Extension field for ``sourceId``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``OperationDefinitionParameterReferencedFrom`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "source", "sourceId"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4510( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("source", "source__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/operationoutcome.py b/fhir/resources/operationoutcome.py deleted file mode 100644 index 0b968b18..00000000 --- a/fhir/resources/operationoutcome.py +++ /dev/null @@ -1,246 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/OperationOutcome -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class OperationOutcome(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about the success/failure of an action. - A collection of error, warning, or information messages that result from a - system action. - """ - - resource_type = Field("OperationOutcome", const=True) - - issue: typing.List[fhirtypes.OperationOutcomeIssueType] = Field( - ..., - alias="issue", - title="A single issue associated with the action", - description=( - "An error, warning, or information message that results from a system " - "action." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``OperationOutcome`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "issue", - ] - - -class OperationOutcomeIssue(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A single issue associated with the action. - An error, warning, or information message that results from a system - action. - """ - - resource_type = Field("OperationOutcomeIssue", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Error or warning code", - description=( - "Describes the type of the issue. The system that creates an " - "OperationOutcome SHALL choose the most applicable code from the " - "IssueType value set, and may additional provide its own code for the " - "error in the details element." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - details: fhirtypes.CodeableConceptType = Field( - None, - alias="details", - title="Additional details about the error", - description=( - "Additional details about the error. This may be a text description of " - "the error or a system code that identifies the error." - ), - # if property is element of this resource. - element_property=True, - ) - - diagnostics: fhirtypes.String = Field( - None, - alias="diagnostics", - title="Additional diagnostic information about the issue", - description=None, - # if property is element of this resource. - element_property=True, - ) - diagnostics__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_diagnostics", title="Extension field for ``diagnostics``." - ) - - expression: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="expression", - title="FHIRPath of element(s) related to issue", - description=( - "A [simple subset of FHIRPath](fhirpath.html#simple) limited to element" - " names, repetition indicators and the default child accessor that " - "identifies one of the elements in the resource that caused this issue " - "to be raised." - ), - # if property is element of this resource. - element_property=True, - ) - expression__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_expression", title="Extension field for ``expression``.") - - location: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="location", - title="Deprecated: Path of element(s) related to issue", - description=( - "This element is deprecated because it is XML specific. It is replaced " - "by issue.expression, which is format independent, and simpler to " - "parse. For resource issues, this will be a simple XPath limited to " - "element names, repetition indicators and the default child accessor " - "that identifies one of the elements in the resource that caused this " - 'issue to be raised. For HTTP errors, will be "http." + the parameter ' - "name." - ), - # if property is element of this resource. - element_property=True, - ) - location__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_location", title="Extension field for ``location``.") - - severity: fhirtypes.Code = Field( - None, - alias="severity", - title="fatal | error | warning | information", - description=( - "Indicates whether the issue indicates a variation from successful " - "processing." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["fatal", "error", "warning", "information"], - ) - severity__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_severity", title="Extension field for ``severity``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``OperationOutcomeIssue`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "severity", - "code", - "details", - "diagnostics", - "location", - "expression", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2378( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext"), ("severity", "severity__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/organization.py b/fhir/resources/organization.py deleted file mode 100644 index db19dfbd..00000000 --- a/fhir/resources/organization.py +++ /dev/null @@ -1,233 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Organization -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class Organization(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A grouping of people or organizations with a common purpose. - A formally or informally recognized grouping of people or organizations - formed for the purpose of achieving some form of collective action. - Includes companies, institutions, corporations, departments, community - groups, healthcare practice groups, payer/insurer, etc. - """ - - resource_type = Field("Organization", const=True) - - active: bool = Field( - None, - alias="active", - title="Whether the organization's record is still in active use", - description=None, - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - address: typing.List[fhirtypes.AddressType] = Field( - None, - alias="address", - title="An address for the organization", - description=None, - # if property is element of this resource. - element_property=True, - ) - - alias: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="alias", - title=( - "A list of alternate names that the organization is known as, or was " - "known as in the past" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - alias__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_alias", title="Extension field for ``alias``.") - - contact: typing.List[fhirtypes.OrganizationContactType] = Field( - None, - alias="contact", - title="Contact for the organization for a certain purpose", - description=None, - # if property is element of this resource. - element_property=True, - ) - - endpoint: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="endpoint", - title=( - "Technical endpoints providing access to services operated for the " - "organization" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Endpoint"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Identifies this organization across multiple systems", - description=( - "Identifier for the organization that is used to identify the " - "organization across multiple disparate systems." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name used for the organization", - description="A name associated with the organization.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - partOf: fhirtypes.ReferenceType = Field( - None, - alias="partOf", - title="The organization of which this organization forms a part", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="A contact detail for the organization", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title="Kind of organization", - description="The kind(s) of organization that this is.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Organization`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "active", - "type", - "name", - "alias", - "telecom", - "address", - "partOf", - "contact", - "endpoint", - ] - - -class OrganizationContact(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Contact for the organization for a certain purpose. - """ - - resource_type = Field("OrganizationContact", const=True) - - address: fhirtypes.AddressType = Field( - None, - alias="address", - title="Visiting or postal addresses for the contact", - description=None, - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.HumanNameType = Field( - None, - alias="name", - title="A name associated with the contact", - description=None, - # if property is element of this resource. - element_property=True, - ) - - purpose: fhirtypes.CodeableConceptType = Field( - None, - alias="purpose", - title="The type of contact", - description="Indicates a purpose for which the contact can be reached.", - # if property is element of this resource. - element_property=True, - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="Contact details (telephone, email, etc.) for a contact", - description=( - "A contact detail (e.g. a telephone number or an email address) by " - "which the party may be contacted." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``OrganizationContact`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "purpose", - "name", - "telecom", - "address", - ] diff --git a/fhir/resources/organizationaffiliation.py b/fhir/resources/organizationaffiliation.py deleted file mode 100644 index eb0ddf74..00000000 --- a/fhir/resources/organizationaffiliation.py +++ /dev/null @@ -1,205 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/OrganizationAffiliation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import domainresource, fhirtypes - - -class OrganizationAffiliation(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Defines an affiliation/assotiation/relationship between 2 distinct - oganizations, that is not a part-of relationship/sub-division relationship. - """ - - resource_type = Field("OrganizationAffiliation", const=True) - - active: bool = Field( - None, - alias="active", - title="Whether this organization affiliation record is in active use", - description=None, - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - code: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="code", - title="Definition of the role the participatingOrganization plays", - description=( - "Definition of the role the participatingOrganization plays in the " - "association." - ), - # if property is element of this resource. - element_property=True, - ) - - endpoint: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="endpoint", - title=( - "Technical endpoints providing access to services operated for this " "role" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Endpoint"], - ) - - healthcareService: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="healthcareService", - title="Healthcare services provided through the role", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["HealthcareService"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifiers that are specific to this role", - description=None, - # if property is element of this resource. - element_property=True, - ) - - location: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="location", - title="The location(s) at which the role occurs", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - network: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="network", - title=( - "Health insurance provider network in which the " - "participatingOrganization provides the role's services (if defined) at" - " the indicated locations (if defined)" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - organization: fhirtypes.ReferenceType = Field( - None, - alias="organization", - title="Organization where the role is available", - description=( - "Organization where the role is available (primary organization/has " - "members)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - participatingOrganization: fhirtypes.ReferenceType = Field( - None, - alias="participatingOrganization", - title=( - "Organization that provides/performs the role (e.g. providing services " - "or is a member of)" - ), - description=( - "The Participating Organization provides/performs the role(s) defined " - "by the code to the Primary Organization (e.g. providing services or is" - " a member of)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title=( - "The period during which the participatingOrganization is affiliated " - "with the primary organization" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - specialty: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="specialty", - title=( - "Specific specialty of the participatingOrganization in the context of " - "the role" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title=( - "Contact details at the participatingOrganization relevant to this " - "Affiliation" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``OrganizationAffiliation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "active", - "period", - "organization", - "participatingOrganization", - "network", - "code", - "specialty", - "location", - "healthcareService", - "telecom", - "endpoint", - ] diff --git a/fhir/resources/parameterdefinition.py b/fhir/resources/parameterdefinition.py deleted file mode 100644 index c0e4ab60..00000000 --- a/fhir/resources/parameterdefinition.py +++ /dev/null @@ -1,213 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ParameterDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import element, fhirtypes - - -class ParameterDefinition(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Definition of a parameter to a module. - The parameters to the module. This collection specifies both the input and - output parameters. Input parameters are provided by the caller as part of - the $evaluate operation. Output parameters are included in the - GuidanceResponse. - """ - - resource_type = Field("ParameterDefinition", const=True) - - documentation: fhirtypes.String = Field( - None, - alias="documentation", - title="A brief description of the parameter", - description=( - "A brief discussion of what the parameter is for and how it is used by " - "the module." - ), - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - max: fhirtypes.String = Field( - None, - alias="max", - title="Maximum cardinality (a number of *)", - description=( - "The maximum number of times this element is permitted to appear in the" - " request or response." - ), - # if property is element of this resource. - element_property=True, - ) - max__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_max", title="Extension field for ``max``." - ) - - min: fhirtypes.Integer = Field( - None, - alias="min", - title="Minimum cardinality", - description=( - "The minimum number of times this parameter SHALL appear in the request" - " or response." - ), - # if property is element of this resource. - element_property=True, - ) - min__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_min", title="Extension field for ``min``." - ) - - name: fhirtypes.Code = Field( - None, - alias="name", - title="Name used to access the parameter value", - description=( - "The name of the parameter used to allow access to the value of the " - "parameter in evaluation contexts." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - profile: fhirtypes.Canonical = Field( - None, - alias="profile", - title="What profile the value is expected to be", - description=( - "If specified, this indicates a profile that the input data must " - "conform to, or that the output data will conform to." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - profile__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_profile", title="Extension field for ``profile``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="What type of value", - description="The type of the parameter.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - use: fhirtypes.Code = Field( - None, - alias="use", - title="in | out", - description="Whether the parameter is input or output for the module.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["in", "out"], - ) - use__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_use", title="Extension field for ``use``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ParameterDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "name", - "use", - "min", - "max", - "documentation", - "type", - "profile", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2152( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext"), ("use", "use__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/parameters.py b/fhir/resources/parameters.py deleted file mode 100644 index 709d1767..00000000 --- a/fhir/resources/parameters.py +++ /dev/null @@ -1,967 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Parameters -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, fhirtypes, resource - - -class Parameters(resource.Resource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Operation Request or Response. - This resource is a non-persisted resource used to pass information into and - back from an [operation](operations.html). It has no other use, and there - is no RESTful endpoint associated with it. - """ - - resource_type = Field("Parameters", const=True) - - parameter: typing.List[fhirtypes.ParametersParameterType] = Field( - None, - alias="parameter", - title="Operation Parameter", - description="A parameter passed to or received from the operation.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Parameters`` according specification, - with preserving original sequence order. - """ - return ["id", "meta", "implicitRules", "language", "parameter"] - - -class ParametersParameter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Operation Parameter. - A parameter passed to or received from the operation. - """ - - resource_type = Field("ParametersParameter", const=True) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name from the definition", - description="The name of the parameter (reference to the operation definition).", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - part: typing.List[fhirtypes.ParametersParameterType] = Field( - None, - alias="part", - title="Named part of a multi-part parameter", - description="A named part of a multi-part parameter.", - # if property is element of this resource. - element_property=True, - ) - - resource: fhirtypes.ResourceType = Field( - None, - alias="resource", - title="If parameter is a whole resource", - description="If the parameter is a whole resource.", - # if property is element of this resource. - element_property=True, - ) - - valueAddress: fhirtypes.AddressType = Field( - None, - alias="valueAddress", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueAge: fhirtypes.AgeType = Field( - None, - alias="valueAge", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueAnnotation: fhirtypes.AnnotationType = Field( - None, - alias="valueAnnotation", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="valueAttachment", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueBase64Binary: fhirtypes.Base64Binary = Field( - None, - alias="valueBase64Binary", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueBase64Binary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valueBase64Binary", - title="Extension field for ``valueBase64Binary``.", - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCanonical: fhirtypes.Canonical = Field( - None, - alias="valueCanonical", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueCanonical", title="Extension field for ``valueCanonical``." - ) - - valueCode: fhirtypes.Code = Field( - None, - alias="valueCode", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueCode", title="Extension field for ``valueCode``." - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueCoding: fhirtypes.CodingType = Field( - None, - alias="valueCoding", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueContactDetail: fhirtypes.ContactDetailType = Field( - None, - alias="valueContactDetail", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueContactPoint: fhirtypes.ContactPointType = Field( - None, - alias="valueContactPoint", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueContributor: fhirtypes.ContributorType = Field( - None, - alias="valueContributor", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueCount: fhirtypes.CountType = Field( - None, - alias="valueCount", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDataRequirement: fhirtypes.DataRequirementType = Field( - None, - alias="valueDataRequirement", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDate: fhirtypes.Date = Field( - None, - alias="valueDate", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDate", title="Extension field for ``valueDate``." - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueDecimal: fhirtypes.Decimal = Field( - None, - alias="valueDecimal", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDecimal", title="Extension field for ``valueDecimal``." - ) - - valueDistance: fhirtypes.DistanceType = Field( - None, - alias="valueDistance", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDosage: fhirtypes.DosageType = Field( - None, - alias="valueDosage", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDuration: fhirtypes.DurationType = Field( - None, - alias="valueDuration", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueExpression: fhirtypes.ExpressionType = Field( - None, - alias="valueExpression", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueHumanName: fhirtypes.HumanNameType = Field( - None, - alias="valueHumanName", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueId: fhirtypes.Id = Field( - None, - alias="valueId", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueId", title="Extension field for ``valueId``." - ) - - valueIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="valueIdentifier", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueInstant: fhirtypes.Instant = Field( - None, - alias="valueInstant", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueInstant__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInstant", title="Extension field for ``valueInstant``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valueMarkdown: fhirtypes.Markdown = Field( - None, - alias="valueMarkdown", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueMarkdown__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueMarkdown", title="Extension field for ``valueMarkdown``." - ) - - valueMeta: fhirtypes.MetaType = Field( - None, - alias="valueMeta", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueMoney: fhirtypes.MoneyType = Field( - None, - alias="valueMoney", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueOid: fhirtypes.Oid = Field( - None, - alias="valueOid", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueOid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueOid", title="Extension field for ``valueOid``." - ) - - valueParameterDefinition: fhirtypes.ParameterDefinitionType = Field( - None, - alias="valueParameterDefinition", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valuePeriod: fhirtypes.PeriodType = Field( - None, - alias="valuePeriod", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valuePositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="valuePositiveInt", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valuePositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valuePositiveInt", - title="Extension field for ``valuePositiveInt``.", - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRange: fhirtypes.RangeType = Field( - None, - alias="valueRange", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRatio: fhirtypes.RatioType = Field( - None, - alias="valueRatio", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRelatedArtifact: fhirtypes.RelatedArtifactType = Field( - None, - alias="valueRelatedArtifact", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueSampledData: fhirtypes.SampledDataType = Field( - None, - alias="valueSampledData", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueSignature: fhirtypes.SignatureType = Field( - None, - alias="valueSignature", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - valueTime: fhirtypes.Time = Field( - None, - alias="valueTime", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueTime", title="Extension field for ``valueTime``." - ) - - valueTiming: fhirtypes.TimingType = Field( - None, - alias="valueTiming", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueTriggerDefinition: fhirtypes.TriggerDefinitionType = Field( - None, - alias="valueTriggerDefinition", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="valueUnsignedInt", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valueUnsignedInt", - title="Extension field for ``valueUnsignedInt``.", - ) - - valueUri: fhirtypes.Uri = Field( - None, - alias="valueUri", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUri", title="Extension field for ``valueUri``." - ) - - valueUrl: fhirtypes.Url = Field( - None, - alias="valueUrl", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUrl", title="Extension field for ``valueUrl``." - ) - - valueUsageContext: fhirtypes.UsageContextType = Field( - None, - alias="valueUsageContext", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueUuid: fhirtypes.Uuid = Field( - None, - alias="valueUuid", - title="If parameter is a data type", - description="If the parameter is a data type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueUuid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUuid", title="Extension field for ``valueUuid``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ParametersParameter`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "valueBase64Binary", - "valueBoolean", - "valueCanonical", - "valueCode", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueId", - "valueInstant", - "valueInteger", - "valueMarkdown", - "valueOid", - "valuePositiveInt", - "valueString", - "valueTime", - "valueUnsignedInt", - "valueUri", - "valueUrl", - "valueUuid", - "valueAddress", - "valueAge", - "valueAnnotation", - "valueAttachment", - "valueCodeableConcept", - "valueCoding", - "valueContactPoint", - "valueCount", - "valueDistance", - "valueDuration", - "valueHumanName", - "valueIdentifier", - "valueMoney", - "valuePeriod", - "valueQuantity", - "valueRange", - "valueRatio", - "valueReference", - "valueSampledData", - "valueSignature", - "valueTiming", - "valueContactDetail", - "valueContributor", - "valueDataRequirement", - "valueExpression", - "valueParameterDefinition", - "valueRelatedArtifact", - "valueTriggerDefinition", - "valueUsageContext", - "valueDosage", - "valueMeta", - "resource", - "part", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2167( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2167( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueAddress", - "valueAge", - "valueAnnotation", - "valueAttachment", - "valueBase64Binary", - "valueBoolean", - "valueCanonical", - "valueCode", - "valueCodeableConcept", - "valueCoding", - "valueContactDetail", - "valueContactPoint", - "valueContributor", - "valueCount", - "valueDataRequirement", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueDistance", - "valueDosage", - "valueDuration", - "valueExpression", - "valueHumanName", - "valueId", - "valueIdentifier", - "valueInstant", - "valueInteger", - "valueMarkdown", - "valueMeta", - "valueMoney", - "valueOid", - "valueParameterDefinition", - "valuePeriod", - "valuePositiveInt", - "valueQuantity", - "valueRange", - "valueRatio", - "valueReference", - "valueRelatedArtifact", - "valueSampledData", - "valueSignature", - "valueString", - "valueTime", - "valueTiming", - "valueTriggerDefinition", - "valueUnsignedInt", - "valueUri", - "valueUrl", - "valueUsageContext", - "valueUuid", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/patient.py b/fhir/resources/patient.py deleted file mode 100644 index 5e8e7b1c..00000000 --- a/fhir/resources/patient.py +++ /dev/null @@ -1,613 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Patient -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Patient(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about an individual or animal receiving health care services. - Demographics and other administrative information about an individual or - animal receiving care or other health-related services. - """ - - resource_type = Field("Patient", const=True) - - active: bool = Field( - None, - alias="active", - title="Whether this patient's record is in active use", - description=( - "Whether this patient record is in active use. Many systems use this " - "property to mark as non-current patients, such as those that have not " - "been seen for a period of time based on an organization's business " - "rules. It is often used to filter patient lists to exclude inactive " - "patients Deceased patients may also be marked as inactive for the " - "same reasons, but may be active for some time after death." - ), - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - address: typing.List[fhirtypes.AddressType] = Field( - None, - alias="address", - title="An address for the individual", - description=None, - # if property is element of this resource. - element_property=True, - ) - - birthDate: fhirtypes.Date = Field( - None, - alias="birthDate", - title="The date of birth for the individual", - description=None, - # if property is element of this resource. - element_property=True, - ) - birthDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_birthDate", title="Extension field for ``birthDate``." - ) - - communication: typing.List[fhirtypes.PatientCommunicationType] = Field( - None, - alias="communication", - title=( - "A language which may be used to communicate with the patient about his" - " or her health" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.PatientContactType] = Field( - None, - alias="contact", - title="A contact party (e.g. guardian, partner, friend) for the patient", - description=None, - # if property is element of this resource. - element_property=True, - ) - - deceasedBoolean: bool = Field( - None, - alias="deceasedBoolean", - title="Indicates if the individual is deceased or not", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e deceased[x] - one_of_many="deceased", - one_of_many_required=False, - ) - deceasedBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_deceasedBoolean", title="Extension field for ``deceasedBoolean``." - ) - - deceasedDateTime: fhirtypes.DateTime = Field( - None, - alias="deceasedDateTime", - title="Indicates if the individual is deceased or not", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e deceased[x] - one_of_many="deceased", - one_of_many_required=False, - ) - deceasedDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_deceasedDateTime", - title="Extension field for ``deceasedDateTime``.", - ) - - gender: fhirtypes.Code = Field( - None, - alias="gender", - title="male | female | other | unknown", - description=( - "Administrative Gender - the gender that the patient is considered to " - "have for administration and record keeping purposes." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["male", "female", "other", "unknown"], - ) - gender__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_gender", title="Extension field for ``gender``." - ) - - generalPractitioner: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="generalPractitioner", - title="Patient's nominated primary care provider", - description="Patient's nominated care provider.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization", "Practitioner", "PractitionerRole"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="An identifier for this patient", - description=None, - # if property is element of this resource. - element_property=True, - ) - - link: typing.List[fhirtypes.PatientLinkType] = Field( - None, - alias="link", - title="Link to another patient resource that concerns the same actual person", - description=( - "Link to another patient resource that concerns the same actual " "patient." - ), - # if property is element of this resource. - element_property=True, - ) - - managingOrganization: fhirtypes.ReferenceType = Field( - None, - alias="managingOrganization", - title="Organization that is the custodian of the patient record", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - maritalStatus: fhirtypes.CodeableConceptType = Field( - None, - alias="maritalStatus", - title="Marital (civil) status of a patient", - description="This field contains a patient's most recent marital (civil) status.", - # if property is element of this resource. - element_property=True, - ) - - multipleBirthBoolean: bool = Field( - None, - alias="multipleBirthBoolean", - title="Whether patient is part of a multiple birth", - description=( - "Indicates whether the patient is part of a multiple (boolean) or " - "indicates the actual birth order (integer)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e multipleBirth[x] - one_of_many="multipleBirth", - one_of_many_required=False, - ) - multipleBirthBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_multipleBirthBoolean", - title="Extension field for ``multipleBirthBoolean``.", - ) - - multipleBirthInteger: fhirtypes.Integer = Field( - None, - alias="multipleBirthInteger", - title="Whether patient is part of a multiple birth", - description=( - "Indicates whether the patient is part of a multiple (boolean) or " - "indicates the actual birth order (integer)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e multipleBirth[x] - one_of_many="multipleBirth", - one_of_many_required=False, - ) - multipleBirthInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_multipleBirthInteger", - title="Extension field for ``multipleBirthInteger``.", - ) - - name: typing.List[fhirtypes.HumanNameType] = Field( - None, - alias="name", - title="A name associated with the patient", - description="A name associated with the individual.", - # if property is element of this resource. - element_property=True, - ) - - photo: typing.List[fhirtypes.AttachmentType] = Field( - None, - alias="photo", - title="Image of the patient", - description=None, - # if property is element of this resource. - element_property=True, - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="A contact detail for the individual", - description=( - "A contact detail (e.g. a telephone number or an email address) by " - "which the individual may be contacted." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Patient`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "active", - "name", - "telecom", - "gender", - "birthDate", - "deceasedBoolean", - "deceasedDateTime", - "address", - "maritalStatus", - "multipleBirthBoolean", - "multipleBirthInteger", - "photo", - "contact", - "communication", - "generalPractitioner", - "managingOrganization", - "link", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_921( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "deceased": ["deceasedBoolean", "deceasedDateTime"], - "multipleBirth": ["multipleBirthBoolean", "multipleBirthInteger"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class PatientCommunication(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A language which may be used to communicate with the patient about his or - her health. - """ - - resource_type = Field("PatientCommunication", const=True) - - language: fhirtypes.CodeableConceptType = Field( - ..., - alias="language", - title=( - "The language which can be used to communicate with the patient about " - "his or her health" - ), - description=( - "The ISO-639-1 alpha 2 code in lower case for the language, optionally " - "followed by a hyphen and the ISO-3166-1 alpha 2 code for the region in" - ' upper case; e.g. "en" for English, or "en-US" for American English ' - 'versus "en-EN" for England English.' - ), - # if property is element of this resource. - element_property=True, - ) - - preferred: bool = Field( - None, - alias="preferred", - title="Language preference indicator", - description=( - "Indicates whether or not the patient prefers this language (over other" - " languages he masters up a certain level)." - ), - # if property is element of this resource. - element_property=True, - ) - preferred__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_preferred", title="Extension field for ``preferred``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PatientCommunication`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "language", "preferred"] - - -class PatientContact(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A contact party (e.g. guardian, partner, friend) for the patient. - """ - - resource_type = Field("PatientContact", const=True) - - address: fhirtypes.AddressType = Field( - None, - alias="address", - title="Address for the contact person", - description=None, - # if property is element of this resource. - element_property=True, - ) - - gender: fhirtypes.Code = Field( - None, - alias="gender", - title="male | female | other | unknown", - description=( - "Administrative Gender - the gender that the contact person is " - "considered to have for administration and record keeping purposes." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["male", "female", "other", "unknown"], - ) - gender__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_gender", title="Extension field for ``gender``." - ) - - name: fhirtypes.HumanNameType = Field( - None, - alias="name", - title="A name associated with the contact person", - description=None, - # if property is element of this resource. - element_property=True, - ) - - organization: fhirtypes.ReferenceType = Field( - None, - alias="organization", - title="Organization that is associated with the contact", - description=( - "Organization on behalf of which the contact is acting or for which the" - " contact is working." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title=( - "The period during which this contact person or organization is valid " - "to be contacted relating to this patient" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - relationship: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="relationship", - title="The kind of relationship", - description=( - "The nature of the relationship between the patient and the contact " - "person." - ), - # if property is element of this resource. - element_property=True, - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="A contact detail for the person", - description=( - "A contact detail for the person, e.g. a telephone number or an email " - "address." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PatientContact`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "relationship", - "name", - "telecom", - "address", - "gender", - "organization", - "period", - ] - - -class PatientLink(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Link to another patient resource that concerns the same actual person. - Link to another patient resource that concerns the same actual patient. - """ - - resource_type = Field("PatientLink", const=True) - - other: fhirtypes.ReferenceType = Field( - ..., - alias="other", - title="The other patient or related person resource that the link refers to", - description="The other patient resource that the link refers to.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "RelatedPerson"], - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="replaced-by | replaces | refer | seealso", - description=( - "The type of link between this patient resource and another patient " - "resource." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["replaced-by", "replaces", "refer", "seealso"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PatientLink`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "other", "type"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1310( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/paymentnotice.py b/fhir/resources/paymentnotice.py deleted file mode 100644 index cf76b952..00000000 --- a/fhir/resources/paymentnotice.py +++ /dev/null @@ -1,256 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/PaymentNotice -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class PaymentNotice(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - PaymentNotice request. - This resource provides the status of the payment for goods and services - rendered, and the request and response resource references. - """ - - resource_type = Field("PaymentNotice", const=True) - - amount: fhirtypes.MoneyType = Field( - ..., - alias="amount", - title="Monetary amount of the payment", - description="The amount sent to the payee.", - # if property is element of this resource. - element_property=True, - ) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="Creation date", - description="The date when this resource was created.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for the payment noctice", - description="A unique identifier assigned to this payment notice.", - # if property is element of this resource. - element_property=True, - ) - - payee: fhirtypes.ReferenceType = Field( - None, - alias="payee", - title="Party being paid", - description=( - "The party who will receive or has received payment that is the subject" - " of this notification." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - payment: fhirtypes.ReferenceType = Field( - ..., - alias="payment", - title="Payment reference", - description="A reference to the payment which is the subject of this notice.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["PaymentReconciliation"], - ) - - paymentDate: fhirtypes.Date = Field( - None, - alias="paymentDate", - title="Payment or clearing date", - description="The date when the above payment action occurred.", - # if property is element of this resource. - element_property=True, - ) - paymentDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_paymentDate", title="Extension field for ``paymentDate``." - ) - - paymentStatus: fhirtypes.CodeableConceptType = Field( - None, - alias="paymentStatus", - title="Issued or cleared Status of the payment", - description="A code indicating whether payment has been sent or cleared.", - # if property is element of this resource. - element_property=True, - ) - - provider: fhirtypes.ReferenceType = Field( - None, - alias="provider", - title="Responsible practitioner", - description=( - "The practitioner who is responsible for the services rendered to the " - "patient." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - recipient: fhirtypes.ReferenceType = Field( - ..., - alias="recipient", - title="Party being notified", - description="The party who is notified of the payment status.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - request: fhirtypes.ReferenceType = Field( - None, - alias="request", - title="Request reference", - description="Reference of resource for which payment is being made.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - response: fhirtypes.ReferenceType = Field( - None, - alias="response", - title="Response reference", - description="Reference of response to resource for which payment is being made.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | cancelled | draft | entered-in-error", - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "cancelled", "draft", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PaymentNotice`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "request", - "response", - "created", - "provider", - "payment", - "paymentDate", - "payee", - "recipient", - "amount", - "paymentStatus", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1525( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("created", "created__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/paymentreconciliation.py b/fhir/resources/paymentreconciliation.py deleted file mode 100644 index 0cdd8a27..00000000 --- a/fhir/resources/paymentreconciliation.py +++ /dev/null @@ -1,502 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/PaymentReconciliation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class PaymentReconciliation(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - PaymentReconciliation resource. - This resource provides the details including amount of a payment and - allocates the payment items being paid. - """ - - resource_type = Field("PaymentReconciliation", const=True) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="Creation date", - description="The date when the resource was created.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - detail: typing.List[fhirtypes.PaymentReconciliationDetailType] = Field( - None, - alias="detail", - title="Settlement particulars", - description=( - "Distribution of the payment amount for a previously acknowledged " - "payable." - ), - # if property is element of this resource. - element_property=True, - ) - - disposition: fhirtypes.String = Field( - None, - alias="disposition", - title="Disposition message", - description=( - "A human readable description of the status of the request for the " - "reconciliation." - ), - # if property is element of this resource. - element_property=True, - ) - disposition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_disposition", title="Extension field for ``disposition``." - ) - - formCode: fhirtypes.CodeableConceptType = Field( - None, - alias="formCode", - title="Printed form identifier", - description="A code for the form to be used for printing the content.", - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for a payment reconciliation", - description="A unique identifier assigned to this payment reconciliation.", - # if property is element of this resource. - element_property=True, - ) - - outcome: fhirtypes.Code = Field( - None, - alias="outcome", - title="queued | complete | error | partial", - description="The outcome of a request for a reconciliation.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["queued", "complete", "error", "partial"], - ) - outcome__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_outcome", title="Extension field for ``outcome``." - ) - - paymentAmount: fhirtypes.MoneyType = Field( - ..., - alias="paymentAmount", - title="Total amount of Payment", - description="Total payment amount as indicated on the financial instrument.", - # if property is element of this resource. - element_property=True, - ) - - paymentDate: fhirtypes.Date = Field( - None, - alias="paymentDate", - title="When payment issued", - description="The date of payment as indicated on the financial instrument.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - paymentDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_paymentDate", title="Extension field for ``paymentDate``." - ) - - paymentIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="paymentIdentifier", - title="Business identifier for the payment", - description="Issuer's unique identifier for the payment instrument.", - # if property is element of this resource. - element_property=True, - ) - - paymentIssuer: fhirtypes.ReferenceType = Field( - None, - alias="paymentIssuer", - title="Party generating payment", - description="The party who generated the payment.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Period covered", - description=( - "The period of time for which payments have been gathered into this " - "bulk payment for settlement." - ), - # if property is element of this resource. - element_property=True, - ) - - processNote: typing.List[fhirtypes.PaymentReconciliationProcessNoteType] = Field( - None, - alias="processNote", - title="Note concerning processing", - description=( - "A note that describes or explains the processing in a human readable " - "form." - ), - # if property is element of this resource. - element_property=True, - ) - - request: fhirtypes.ReferenceType = Field( - None, - alias="request", - title="Reference to requesting resource", - description="Original request resource reference.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Task"], - ) - - requestor: fhirtypes.ReferenceType = Field( - None, - alias="requestor", - title="Responsible practitioner", - description=( - "The practitioner who is responsible for the services rendered to the " - "patient." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | cancelled | draft | entered-in-error", - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "cancelled", "draft", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PaymentReconciliation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "period", - "created", - "paymentIssuer", - "request", - "requestor", - "outcome", - "disposition", - "paymentDate", - "paymentAmount", - "paymentIdentifier", - "detail", - "formCode", - "processNote", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2383( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("created", "created__ext"), - ("paymentDate", "paymentDate__ext"), - ("status", "status__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class PaymentReconciliationDetail(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Settlement particulars. - Distribution of the payment amount for a previously acknowledged payable. - """ - - resource_type = Field("PaymentReconciliationDetail", const=True) - - amount: fhirtypes.MoneyType = Field( - None, - alias="amount", - title="Amount allocated to this payable", - description="The monetary amount allocated from the total payment to the payable.", - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.Date = Field( - None, - alias="date", - title="Date of commitment to pay", - description="The date from the response resource containing a commitment to pay.", - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Business identifier of the payment detail", - description=( - "Unique identifier for the current payment item for the referenced " - "payable." - ), - # if property is element of this resource. - element_property=True, - ) - - payee: fhirtypes.ReferenceType = Field( - None, - alias="payee", - title="Recipient of the payment", - description="The party which is receiving the payment.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - predecessor: fhirtypes.IdentifierType = Field( - None, - alias="predecessor", - title="Business identifier of the prior payment detail", - description=( - "Unique identifier for the prior payment item for the referenced " - "payable." - ), - # if property is element of this resource. - element_property=True, - ) - - request: fhirtypes.ReferenceType = Field( - None, - alias="request", - title="Request giving rise to the payment", - description=( - "A resource, such as a Claim, the evaluation of which could lead to " - "payment." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - response: fhirtypes.ReferenceType = Field( - None, - alias="response", - title="Response committing to a payment", - description=( - "A resource, such as a ClaimResponse, which contains a commitment to " - "payment." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - responsible: fhirtypes.ReferenceType = Field( - None, - alias="responsible", - title="Contact for the response", - description=( - "A reference to the individual who is responsible for inquiries " - "regarding the response and its payment." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["PractitionerRole"], - ) - - submitter: fhirtypes.ReferenceType = Field( - None, - alias="submitter", - title="Submitter of the request", - description="The party which submitted the claim or financial transaction.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Category of payment", - description="Code to indicate the nature of the payment.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PaymentReconciliationDetail`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "predecessor", - "type", - "request", - "submitter", - "response", - "date", - "responsible", - "payee", - "amount", - ] - - -class PaymentReconciliationProcessNote(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Note concerning processing. - A note that describes or explains the processing in a human readable form. - """ - - resource_type = Field("PaymentReconciliationProcessNote", const=True) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Note explanatory text", - description="The explanation or description associated with the processing.", - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="display | print | printoper", - description="The business purpose of the note text.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["display", "print", "printoper"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PaymentReconciliationProcessNote`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "text"] diff --git a/fhir/resources/period.py b/fhir/resources/period.py deleted file mode 100644 index ba6e57d3..00000000 --- a/fhir/resources/period.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Period -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import element, fhirtypes - - -class Period(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Time range defined by start and end date/time. - A time period defined by a start and end date and optionally time. - """ - - resource_type = Field("Period", const=True) - - end: fhirtypes.DateTime = Field( - None, - alias="end", - title="End time with inclusive boundary, if not ongoing", - description=( - "The end of the period. If the end of the period is missing, it means " - "no end was known or planned at the time the instance was created. The " - "start may be in the past, and the end date in the future, which means " - "that period is expected/planned to end at that time." - ), - # if property is element of this resource. - element_property=True, - ) - end__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_end", title="Extension field for ``end``." - ) - - start: fhirtypes.DateTime = Field( - None, - alias="start", - title="Starting time with inclusive boundary", - description="The start of the period. The boundary is inclusive.", - # if property is element of this resource. - element_property=True, - ) - start__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_start", title="Extension field for ``start``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Period`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "start", "end"] diff --git a/fhir/resources/person.py b/fhir/resources/person.py deleted file mode 100644 index 207151c0..00000000 --- a/fhir/resources/person.py +++ /dev/null @@ -1,211 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Person -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class Person(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A generic person record. - Demographics and administrative information about a person independent of a - specific health-related context. - """ - - resource_type = Field("Person", const=True) - - active: bool = Field( - None, - alias="active", - title="This person's record is in active use", - description="Whether this person's record is in active use.", - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - address: typing.List[fhirtypes.AddressType] = Field( - None, - alias="address", - title="One or more addresses for the person", - description=None, - # if property is element of this resource. - element_property=True, - ) - - birthDate: fhirtypes.Date = Field( - None, - alias="birthDate", - title="The date on which the person was born", - description="The birth date for the person.", - # if property is element of this resource. - element_property=True, - ) - birthDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_birthDate", title="Extension field for ``birthDate``." - ) - - gender: fhirtypes.Code = Field( - None, - alias="gender", - title="male | female | other | unknown", - description="Administrative Gender.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["male", "female", "other", "unknown"], - ) - gender__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_gender", title="Extension field for ``gender``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="A human identifier for this person", - description="Identifier for a person within a particular scope.", - # if property is element of this resource. - element_property=True, - ) - - link: typing.List[fhirtypes.PersonLinkType] = Field( - None, - alias="link", - title="Link to a resource that concerns the same actual person", - description=None, - # if property is element of this resource. - element_property=True, - ) - - managingOrganization: fhirtypes.ReferenceType = Field( - None, - alias="managingOrganization", - title="The organization that is the custodian of the person record", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - name: typing.List[fhirtypes.HumanNameType] = Field( - None, - alias="name", - title="A name associated with the person", - description=None, - # if property is element of this resource. - element_property=True, - ) - - photo: fhirtypes.AttachmentType = Field( - None, - alias="photo", - title="Image of the person", - description=( - "An image that can be displayed as a thumbnail of the person to enhance" - " the identification of the individual." - ), - # if property is element of this resource. - element_property=True, - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="A contact detail for the person", - description=( - "A contact detail for the person, e.g. a telephone number or an email " - "address." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Person`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "name", - "telecom", - "gender", - "birthDate", - "address", - "photo", - "managingOrganization", - "active", - "link", - ] - - -class PersonLink(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Link to a resource that concerns the same actual person. - """ - - resource_type = Field("PersonLink", const=True) - - assurance: fhirtypes.Code = Field( - None, - alias="assurance", - title="level1 | level2 | level3 | level4", - description=( - "Level of assurance that this link is associated with the target " - "resource." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["level1", "level2", "level3", "level4"], - ) - assurance__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_assurance", title="Extension field for ``assurance``." - ) - - target: fhirtypes.ReferenceType = Field( - ..., - alias="target", - title="The resource to which this actual person is associated", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Practitioner", "RelatedPerson", "Person"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PersonLink`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "target", "assurance"] diff --git a/fhir/resources/plandefinition.py b/fhir/resources/plandefinition.py deleted file mode 100644 index 863992e6..00000000 --- a/fhir/resources/plandefinition.py +++ /dev/null @@ -1,1973 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/PlanDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class PlanDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The definition of a plan for a series of actions, independent of any - specific patient or context. - This resource allows for the definition of various types of plans as a - sharable, consumable, and executable artifact. The resource is general - enough to support the description of a broad range of clinical artifacts - such as clinical decision support rules, order sets and protocols. - """ - - resource_type = Field("PlanDefinition", const=True) - - action: typing.List[fhirtypes.PlanDefinitionActionType] = Field( - None, - alias="action", - title="Action defined by the plan", - description="An action or group of actions to be taken as part of the plan.", - # if property is element of this resource. - element_property=True, - ) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the plan definition was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - author: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="author", - title="Who authored the content", - description=( - "An individiual or organization primarily involved in the creation and " - "maintenance of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the plan definition and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the plan definition." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the plan definition was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the plan definition changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the plan definition", - description=( - "A free text natural language description of the plan definition from a" - " consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - editor: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="editor", - title="Who edited the content", - description=( - "An individual or organization primarily responsible for internal " - "coherence of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the plan definition is expected to be used", - description=( - "The period during which the plan definition content was or is planned " - "to be in active use." - ), - # if property is element of this resource. - element_property=True, - ) - - endorser: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="endorser", - title="Who endorsed the content", - description=( - "An individual or organization responsible for officially endorsing the" - " content for use in some setting." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this plan definition is authored for " - "testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - goal: typing.List[fhirtypes.PlanDefinitionGoalType] = Field( - None, - alias="goal", - title="What the plan is trying to accomplish", - description=( - "Goals that describe what the activities within the plan are intended " - "to achieve. For example, weight loss, restoring an activity of daily " - "living, obtaining herd immunity via immunization, meeting a process " - "improvement objective, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the plan definition", - description=( - "A formal identifier that is used to identify this plan definition when" - " it is represented in other formats, or referenced in a specification," - " model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for plan definition (if applicable)", - description=( - "A legal or geographic region in which the plan definition is intended " - "to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the plan definition was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - library: typing.List[fhirtypes.Canonical] = Field( - None, - alias="library", - title="Logic used by the plan definition", - description=( - "A reference to a Library resource containing any formal logic used by " - "the plan definition." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Library"], - ) - library__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_library", title="Extension field for ``library``.") - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this plan definition (computer friendly)", - description=( - "A natural language name identifying the plan definition. This name " - "should be usable as an identifier for the module by machine processing" - " applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the plan " - "definition." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this plan definition is defined", - description=( - "Explanation of why this plan definition is needed and why it has been " - "designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="Additional documentation, citations", - description=( - "Related artifacts such as additional documentation, justification, or " - "bibliographic references." - ), - # if property is element of this resource. - element_property=True, - ) - - reviewer: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="reviewer", - title="Who reviewed the content", - description=( - "An individual or organization primarily responsible for review of some" - " aspect of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this plan definition. Enables tracking the life-cycle of" - " the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subjectCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="subjectCodeableConcept", - title="Type of individual the plan definition is focused on", - description=( - "A code or group definition that describes the intended subject of the " - "plan definition." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - ) - - subjectReference: fhirtypes.ReferenceType = Field( - None, - alias="subjectReference", - title="Type of individual the plan definition is focused on", - description=( - "A code or group definition that describes the intended subject of the " - "plan definition." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Group"], - ) - - subtitle: fhirtypes.String = Field( - None, - alias="subtitle", - title="Subordinate title of the plan definition", - description=( - "An explanatory or alternate title for the plan definition giving " - "additional information about its content." - ), - # if property is element of this resource. - element_property=True, - ) - subtitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subtitle", title="Extension field for ``subtitle``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this plan definition (human friendly)", - description="A short, descriptive, user-friendly title for the plan definition.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="topic", - title="E.g. Education, Treatment, Assessment", - description=( - "Descriptive topics related to the content of the plan definition. " - "Topics provide a high-level categorization of the definition that can " - "be useful for filtering and searching." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="order-set | clinical-protocol | eca-rule | workflow-definition", - description=( - "A high-level category for the plan definition that distinguishes the " - "kinds of systems that would be interested in the plan definition." - ), - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this plan definition, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this plan definition when it " - "is referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this plan definition is (or will be) published. This URL " - "can be the target of a canonical reference. It SHALL remain the same " - "when the plan definition is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - usage: fhirtypes.String = Field( - None, - alias="usage", - title="Describes the clinical usage of the plan", - description=( - "A detailed description of how the plan definition is used from a " - "clinical perspective." - ), - # if property is element of this resource. - element_property=True, - ) - usage__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_usage", title="Extension field for ``usage``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate plan definition instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the plan definition", - description=( - "The identifier that is used to identify this version of the plan " - "definition when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the plan definition " - "author and is not expected to be globally unique. For example, it " - "might be a timestamp (e.g. yyyymmdd) if a managed version is not " - "available. There is also no expectation that versions can be placed in" - " a lexicographical sequence. To provide a version consistent with the " - "Decision Support Service specification, use the format " - "Major.Minor.Revision (e.g. 1.0.0). For more information on versioning " - "knowledge assets, refer to the Decision Support Service specification." - " Note that a version is required for non-experimental active " - "artifacts." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PlanDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "subtitle", - "type", - "status", - "experimental", - "subjectCodeableConcept", - "subjectReference", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "usage", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "topic", - "author", - "editor", - "reviewer", - "endorser", - "relatedArtifact", - "library", - "goal", - "action", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1618( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1618( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"subject": ["subjectCodeableConcept", "subjectReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class PlanDefinitionAction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Action defined by the plan. - An action or group of actions to be taken as part of the plan. - """ - - resource_type = Field("PlanDefinitionAction", const=True) - - action: typing.List[fhirtypes.PlanDefinitionActionType] = Field( - None, - alias="action", - title="A sub-action", - description=( - "Sub actions that are contained within the action. The behavior of this" - " action determines the functionality of the sub-actions. For example, " - "a selection behavior of at-most-one indicates that of the sub-actions," - " at most one may be chosen as part of realizing the action definition." - ), - # if property is element of this resource. - element_property=True, - ) - - cardinalityBehavior: fhirtypes.Code = Field( - None, - alias="cardinalityBehavior", - title="single | multiple", - description="Defines whether the action can be selected multiple times.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["single", "multiple"], - ) - cardinalityBehavior__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_cardinalityBehavior", - title="Extension field for ``cardinalityBehavior``.", - ) - - code: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="code", - title="Code representing the meaning of the action or sub-actions", - description=( - "A code that provides meaning for the action or action group. For " - "example, a section may have a LOINC code for the section of a " - "documentation template." - ), - # if property is element of this resource. - element_property=True, - ) - - condition: typing.List[fhirtypes.PlanDefinitionActionConditionType] = Field( - None, - alias="condition", - title="Whether or not the action is applicable", - description=( - "An expression that describes applicability criteria or start/stop " - "conditions for the action." - ), - # if property is element of this resource. - element_property=True, - ) - - definitionCanonical: fhirtypes.Canonical = Field( - None, - alias="definitionCanonical", - title="Description of the activity to be performed", - description=( - "A reference to an ActivityDefinition that describes the action to be " - "taken in detail, or a PlanDefinition that describes a series of " - "actions to be taken." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ActivityDefinition", "PlanDefinition", "Questionnaire"], - ) - definitionCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_definitionCanonical", - title="Extension field for ``definitionCanonical``.", - ) - - definitionUri: fhirtypes.Uri = Field( - None, - alias="definitionUri", - title="Description of the activity to be performed", - description=( - "A reference to an ActivityDefinition that describes the action to be " - "taken in detail, or a PlanDefinition that describes a series of " - "actions to be taken." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=False, - ) - definitionUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_definitionUri", title="Extension field for ``definitionUri``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Brief description of the action", - description=( - "A brief description of the action used to provide a summary to display" - " to the user." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - documentation: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="documentation", - title="Supporting documentation for the intended performer of the action", - description=( - "Didactic or other informational resources associated with the action " - "that can be provided to the CDS recipient. Information resources can " - "include inline text commentary and links to web resources." - ), - # if property is element of this resource. - element_property=True, - ) - - dynamicValue: typing.List[fhirtypes.PlanDefinitionActionDynamicValueType] = Field( - None, - alias="dynamicValue", - title="Dynamic aspects of the definition", - description=( - "Customizations that should be applied to the statically defined " - "resource. For example, if the dosage of a medication must be computed " - "based on the patient's weight, a customization would be used to " - "specify an expression that calculated the weight, and the path on the " - "resource that would contain the result." - ), - # if property is element of this resource. - element_property=True, - ) - - goalId: typing.List[fhirtypes.Id] = Field( - None, - alias="goalId", - title="What goals this action supports", - description=( - "Identifies goals that this action supports. The reference must be to a" - " goal element defined within this plan definition." - ), - # if property is element of this resource. - element_property=True, - ) - goalId__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_goalId", title="Extension field for ``goalId``.") - - groupingBehavior: fhirtypes.Code = Field( - None, - alias="groupingBehavior", - title="visual-group | logical-group | sentence-group", - description="Defines the grouping behavior for the action and its children.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["visual-group", "logical-group", "sentence-group"], - ) - groupingBehavior__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_groupingBehavior", - title="Extension field for ``groupingBehavior``.", - ) - - input: typing.List[fhirtypes.DataRequirementType] = Field( - None, - alias="input", - title="Input data requirements", - description="Defines input data requirements for the action.", - # if property is element of this resource. - element_property=True, - ) - - output: typing.List[fhirtypes.DataRequirementType] = Field( - None, - alias="output", - title="Output data definition", - description="Defines the outputs of the action, if any.", - # if property is element of this resource. - element_property=True, - ) - - participant: typing.List[fhirtypes.PlanDefinitionActionParticipantType] = Field( - None, - alias="participant", - title="Who should participate in the action", - description="Indicates who should participate in performing the action described.", - # if property is element of this resource. - element_property=True, - ) - - precheckBehavior: fhirtypes.Code = Field( - None, - alias="precheckBehavior", - title="yes | no", - description="Defines whether the action should usually be preselected.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["yes", "no"], - ) - precheckBehavior__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_precheckBehavior", - title="Extension field for ``precheckBehavior``.", - ) - - prefix: fhirtypes.String = Field( - None, - alias="prefix", - title="User-visible prefix for the action (e.g. 1. or A.)", - description="A user-visible prefix for the action.", - # if property is element of this resource. - element_property=True, - ) - prefix__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_prefix", title="Extension field for ``prefix``." - ) - - priority: fhirtypes.Code = Field( - None, - alias="priority", - title="routine | urgent | asap | stat", - description=( - "Indicates how quickly the action should be addressed with respect to " - "other actions." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["routine", "urgent", "asap", "stat"], - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - reason: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reason", - title="Why the action should be performed", - description="A description of why this action is necessary or appropriate.", - # if property is element of this resource. - element_property=True, - ) - - relatedAction: typing.List[fhirtypes.PlanDefinitionActionRelatedActionType] = Field( - None, - alias="relatedAction", - title="Relationship to another action", - description=( - 'A relationship to another action such as "before" or "30-60 minutes ' - 'after start of".' - ), - # if property is element of this resource. - element_property=True, - ) - - requiredBehavior: fhirtypes.Code = Field( - None, - alias="requiredBehavior", - title="must | could | must-unless-documented", - description="Defines the required behavior for the action.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["must", "could", "must-unless-documented"], - ) - requiredBehavior__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_requiredBehavior", - title="Extension field for ``requiredBehavior``.", - ) - - selectionBehavior: fhirtypes.Code = Field( - None, - alias="selectionBehavior", - title="any | all | all-or-none | exactly-one | at-most-one | one-or-more", - description="Defines the selection behavior for the action and its children.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "any", - "all", - "all-or-none", - "exactly-one", - "at-most-one", - "one-or-more", - ], - ) - selectionBehavior__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_selectionBehavior", - title="Extension field for ``selectionBehavior``.", - ) - - subjectCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="subjectCodeableConcept", - title="Type of individual the action is focused on", - description=( - "A code or group definition that describes the intended subject of the " - "action and its children, if any." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - ) - - subjectReference: fhirtypes.ReferenceType = Field( - None, - alias="subjectReference", - title="Type of individual the action is focused on", - description=( - "A code or group definition that describes the intended subject of the " - "action and its children, if any." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Group"], - ) - - textEquivalent: fhirtypes.String = Field( - None, - alias="textEquivalent", - title=( - "Static text equivalent of the action, used if the dynamic aspects " - "cannot be interpreted by the receiving system" - ), - description=( - "A text equivalent of the action to be performed. This provides a " - "human-interpretable description of the action when the definition is " - "consumed by a system that might not be capable of interpreting it " - "dynamically." - ), - # if property is element of this resource. - element_property=True, - ) - textEquivalent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_textEquivalent", title="Extension field for ``textEquivalent``." - ) - - timingAge: fhirtypes.AgeType = Field( - None, - alias="timingAge", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingDateTime: fhirtypes.DateTime = Field( - None, - alias="timingDateTime", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - timingDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timingDateTime", title="Extension field for ``timingDateTime``." - ) - - timingDuration: fhirtypes.DurationType = Field( - None, - alias="timingDuration", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingPeriod: fhirtypes.PeriodType = Field( - None, - alias="timingPeriod", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingRange: fhirtypes.RangeType = Field( - None, - alias="timingRange", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingTiming: fhirtypes.TimingType = Field( - None, - alias="timingTiming", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="User-visible title", - description="The title of the action displayed to a user.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - transform: fhirtypes.Canonical = Field( - None, - alias="transform", - title="Transform to apply the template", - description=( - "A reference to a StructureMap resource that defines a transform that " - "can be executed to produce the intent resource using the " - "ActivityDefinition instance as the input." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureMap"], - ) - transform__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_transform", title="Extension field for ``transform``." - ) - - trigger: typing.List[fhirtypes.TriggerDefinitionType] = Field( - None, - alias="trigger", - title="When the action should be triggered", - description="A description of when the action should be triggered.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="create | update | remove | fire-event", - description="The type of action to perform (create, update, remove).", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PlanDefinitionAction`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "prefix", - "title", - "description", - "textEquivalent", - "priority", - "code", - "reason", - "documentation", - "goalId", - "subjectCodeableConcept", - "subjectReference", - "trigger", - "condition", - "input", - "output", - "relatedAction", - "timingDateTime", - "timingAge", - "timingPeriod", - "timingDuration", - "timingRange", - "timingTiming", - "participant", - "type", - "groupingBehavior", - "selectionBehavior", - "requiredBehavior", - "precheckBehavior", - "cardinalityBehavior", - "definitionCanonical", - "definitionUri", - "transform", - "dynamicValue", - "action", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2224( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "definition": ["definitionCanonical", "definitionUri"], - "subject": ["subjectCodeableConcept", "subjectReference"], - "timing": [ - "timingAge", - "timingDateTime", - "timingDuration", - "timingPeriod", - "timingRange", - "timingTiming", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class PlanDefinitionActionCondition(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Whether or not the action is applicable. - An expression that describes applicability criteria or start/stop - conditions for the action. - """ - - resource_type = Field("PlanDefinitionActionCondition", const=True) - - expression: fhirtypes.ExpressionType = Field( - None, - alias="expression", - title="Boolean-valued expression", - description=( - "An expression that returns true or false, indicating whether the " - "condition is satisfied." - ), - # if property is element of this resource. - element_property=True, - ) - - kind: fhirtypes.Code = Field( - None, - alias="kind", - title="applicability | start | stop", - description="The kind of condition.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["applicability", "start", "stop"], - ) - kind__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_kind", title="Extension field for ``kind``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PlanDefinitionActionCondition`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "kind", "expression"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3159( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("kind", "kind__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class PlanDefinitionActionDynamicValue(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Dynamic aspects of the definition. - Customizations that should be applied to the statically defined resource. - For example, if the dosage of a medication must be computed based on the - patient's weight, a customization would be used to specify an expression - that calculated the weight, and the path on the resource that would contain - the result. - """ - - resource_type = Field("PlanDefinitionActionDynamicValue", const=True) - - expression: fhirtypes.ExpressionType = Field( - None, - alias="expression", - title="An expression that provides the dynamic value for the customization", - description="An expression specifying the value of the customized element.", - # if property is element of this resource. - element_property=True, - ) - - path: fhirtypes.String = Field( - None, - alias="path", - title="The path to the element to be set dynamically", - description=( - "The path to the element to be customized. This is the path on the " - "resource that will hold the result of the calculation defined by the " - "expression. The specified path SHALL be a FHIRPath resolveable on the " - "specified target type of the ActivityDefinition, and SHALL consist " - "only of identifiers, constant indexers, and a restricted subset of " - "functions. The path is allowed to contain qualifiers (.) to traverse " - "sub-elements, as well as indexers ([x]) to traverse multiple-" - "cardinality sub-elements (see the [Simple FHIRPath " - "Profile](fhirpath.html#simple) for full details)." - ), - # if property is element of this resource. - element_property=True, - ) - path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_path", title="Extension field for ``path``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PlanDefinitionActionDynamicValue`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "path", "expression"] - - -class PlanDefinitionActionParticipant(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Who should participate in the action. - Indicates who should participate in performing the action described. - """ - - resource_type = Field("PlanDefinitionActionParticipant", const=True) - - role: fhirtypes.CodeableConceptType = Field( - None, - alias="role", - title="E.g. Nurse, Surgeon, Parent", - description=( - "The role the participant should play in performing the described " - "action." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="patient | practitioner | related-person | device", - description="The type of participant in the action.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["patient", "practitioner", "related-person", "device"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PlanDefinitionActionParticipant`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "role"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3381( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class PlanDefinitionActionRelatedAction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Relationship to another action. - A relationship to another action such as "before" or "30-60 minutes after - start of". - """ - - resource_type = Field("PlanDefinitionActionRelatedAction", const=True) - - actionId: fhirtypes.Id = Field( - None, - alias="actionId", - title="What action is this related to", - description="The element id of the related action.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - actionId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_actionId", title="Extension field for ``actionId``." - ) - - offsetDuration: fhirtypes.DurationType = Field( - None, - alias="offsetDuration", - title="Time offset for the relationship", - description=( - "A duration or range of durations to apply to the relationship. For " - "example, 30-60 minutes before." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e offset[x] - one_of_many="offset", - one_of_many_required=False, - ) - - offsetRange: fhirtypes.RangeType = Field( - None, - alias="offsetRange", - title="Time offset for the relationship", - description=( - "A duration or range of durations to apply to the relationship. For " - "example, 30-60 minutes before." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e offset[x] - one_of_many="offset", - one_of_many_required=False, - ) - - relationship: fhirtypes.Code = Field( - None, - alias="relationship", - title=( - "before-start | before | before-end | concurrent-with-start | " - "concurrent | concurrent-with-end | after-start | after | after-end" - ), - description="The relationship of this action to the related action.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "before-start", - "before", - "before-end", - "concurrent-with-start", - "concurrent", - "concurrent-with-end", - "after-start", - "after", - "after-end", - ], - ) - relationship__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_relationship", title="Extension field for ``relationship``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PlanDefinitionActionRelatedAction`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "actionId", - "relationship", - "offsetDuration", - "offsetRange", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3535( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("actionId", "actionId__ext"), - ("relationship", "relationship__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3535( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"offset": ["offsetDuration", "offsetRange"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class PlanDefinitionGoal(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What the plan is trying to accomplish. - Goals that describe what the activities within the plan are intended to - achieve. For example, weight loss, restoring an activity of daily living, - obtaining herd immunity via immunization, meeting a process improvement - objective, etc. - """ - - resource_type = Field("PlanDefinitionGoal", const=True) - - addresses: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="addresses", - title="What does the goal address", - description=( - "Identifies problems, conditions, issues, or concerns the goal is " - "intended to address." - ), - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="E.g. Treatment, dietary, behavioral", - description="Indicates a category the goal falls within.", - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.CodeableConceptType = Field( - ..., - alias="description", - title="Code or text describing the goal", - description=( - "Human-readable and/or coded description of a specific desired " - 'objective of care, such as "control blood pressure" or "negotiate an ' - 'obstacle course" or "dance with child at wedding".' - ), - # if property is element of this resource. - element_property=True, - ) - - documentation: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="documentation", - title="Supporting documentation for the goal", - description=( - "Didactic or other informational resources associated with the goal " - "that provide further supporting information about the goal. " - "Information resources can include inline text commentary and links to " - "web resources." - ), - # if property is element of this resource. - element_property=True, - ) - - priority: fhirtypes.CodeableConceptType = Field( - None, - alias="priority", - title="high-priority | medium-priority | low-priority", - description=( - "Identifies the expected level of importance associated with " - "reaching/sustaining the defined goal." - ), - # if property is element of this resource. - element_property=True, - ) - - start: fhirtypes.CodeableConceptType = Field( - None, - alias="start", - title="When goal pursuit begins", - description="The event after which the goal should begin being pursued.", - # if property is element of this resource. - element_property=True, - ) - - target: typing.List[fhirtypes.PlanDefinitionGoalTargetType] = Field( - None, - alias="target", - title="Target outcome for the goal", - description="Indicates what should be done and within what timeframe.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PlanDefinitionGoal`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "category", - "description", - "priority", - "start", - "addresses", - "documentation", - "target", - ] - - -class PlanDefinitionGoalTarget(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Target outcome for the goal. - Indicates what should be done and within what timeframe. - """ - - resource_type = Field("PlanDefinitionGoalTarget", const=True) - - detailCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="detailCodeableConcept", - title="The target value to be achieved", - description=( - "The target value of the measure to be achieved to signify fulfillment " - "of the goal, e.g. 150 pounds or 7.0%. Either the high or low or both " - "values of the range can be specified. When a low value is missing, it " - "indicates that the goal is achieved at any value at or below the high " - "value. Similarly, if the high value is missing, it indicates that the " - "goal is achieved at any value at or above the low value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e detail[x] - one_of_many="detail", - one_of_many_required=False, - ) - - detailQuantity: fhirtypes.QuantityType = Field( - None, - alias="detailQuantity", - title="The target value to be achieved", - description=( - "The target value of the measure to be achieved to signify fulfillment " - "of the goal, e.g. 150 pounds or 7.0%. Either the high or low or both " - "values of the range can be specified. When a low value is missing, it " - "indicates that the goal is achieved at any value at or below the high " - "value. Similarly, if the high value is missing, it indicates that the " - "goal is achieved at any value at or above the low value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e detail[x] - one_of_many="detail", - one_of_many_required=False, - ) - - detailRange: fhirtypes.RangeType = Field( - None, - alias="detailRange", - title="The target value to be achieved", - description=( - "The target value of the measure to be achieved to signify fulfillment " - "of the goal, e.g. 150 pounds or 7.0%. Either the high or low or both " - "values of the range can be specified. When a low value is missing, it " - "indicates that the goal is achieved at any value at or below the high " - "value. Similarly, if the high value is missing, it indicates that the " - "goal is achieved at any value at or above the low value." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e detail[x] - one_of_many="detail", - one_of_many_required=False, - ) - - due: fhirtypes.DurationType = Field( - None, - alias="due", - title="Reach goal within", - description=( - "Indicates the timeframe after the start of the goal in which the goal " - "should be met." - ), - # if property is element of this resource. - element_property=True, - ) - - measure: fhirtypes.CodeableConceptType = Field( - None, - alias="measure", - title="The parameter whose value is to be tracked", - description=( - "The parameter whose value is to be tracked, e.g. body weight, blood " - "pressure, or hemoglobin A1c level." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PlanDefinitionGoalTarget`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "measure", - "detailQuantity", - "detailRange", - "detailCodeableConcept", - "due", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2626( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "detail": ["detailCodeableConcept", "detailQuantity", "detailRange"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/population.py b/fhir/resources/population.py deleted file mode 100644 index 2c84e684..00000000 --- a/fhir/resources/population.py +++ /dev/null @@ -1,135 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Population -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, fhirtypes - - -class Population(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A definition of a set of people that apply to some clinically related - context, for example people contraindicated for a certain medication. - A populatioof people with some set of grouping criteria. - """ - - resource_type = Field("Population", const=True) - - ageCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="ageCodeableConcept", - title="The age of the specific population", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e age[x] - one_of_many="age", - one_of_many_required=False, - ) - - ageRange: fhirtypes.RangeType = Field( - None, - alias="ageRange", - title="The age of the specific population", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e age[x] - one_of_many="age", - one_of_many_required=False, - ) - - gender: fhirtypes.CodeableConceptType = Field( - None, - alias="gender", - title="The gender of the specific population", - description=None, - # if property is element of this resource. - element_property=True, - ) - - physiologicalCondition: fhirtypes.CodeableConceptType = Field( - None, - alias="physiologicalCondition", - title=( - "The existing physiological conditions of the specific population to " - "which this applies" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - race: fhirtypes.CodeableConceptType = Field( - None, - alias="race", - title="Race of the specific population", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Population`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "ageRange", - "ageCodeableConcept", - "gender", - "race", - "physiologicalCondition", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1257( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"age": ["ageCodeableConcept", "ageRange"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/practitioner.py b/fhir/resources/practitioner.py deleted file mode 100644 index 53c735b9..00000000 --- a/fhir/resources/practitioner.py +++ /dev/null @@ -1,248 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Practitioner -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class Practitioner(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A person with a formal responsibility in the provisioning of healthcare or - related services. - A person who is directly or indirectly involved in the provisioning of - healthcare. - """ - - resource_type = Field("Practitioner", const=True) - - active: bool = Field( - None, - alias="active", - title="Whether this practitioner's record is in active use", - description=None, - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - address: typing.List[fhirtypes.AddressType] = Field( - None, - alias="address", - title=( - "Address(es) of the practitioner that are not role specific (typically " - "home address)" - ), - description=( - "Address(es) of the practitioner that are not role specific (typically " - "home address). Work addresses are not typically entered in this " - "property as they are usually role dependent." - ), - # if property is element of this resource. - element_property=True, - ) - - birthDate: fhirtypes.Date = Field( - None, - alias="birthDate", - title="The date on which the practitioner was born", - description="The date of birth for the practitioner.", - # if property is element of this resource. - element_property=True, - ) - birthDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_birthDate", title="Extension field for ``birthDate``." - ) - - communication: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="communication", - title="A language the practitioner can use in patient communication", - description=None, - # if property is element of this resource. - element_property=True, - ) - - gender: fhirtypes.Code = Field( - None, - alias="gender", - title="male | female | other | unknown", - description=( - "Administrative Gender - the gender that the person is considered to " - "have for administration and record keeping purposes." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["male", "female", "other", "unknown"], - ) - gender__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_gender", title="Extension field for ``gender``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="An identifier for the person as this agent", - description="An identifier that applies to this person in this role.", - # if property is element of this resource. - element_property=True, - ) - - name: typing.List[fhirtypes.HumanNameType] = Field( - None, - alias="name", - title="The name(s) associated with the practitioner", - description=None, - # if property is element of this resource. - element_property=True, - ) - - photo: typing.List[fhirtypes.AttachmentType] = Field( - None, - alias="photo", - title="Image of the person", - description=None, - # if property is element of this resource. - element_property=True, - ) - - qualification: typing.List[fhirtypes.PractitionerQualificationType] = Field( - None, - alias="qualification", - title=( - "Certification, licenses, or training pertaining to the provision of " - "care" - ), - description=( - "The official certifications, training, and licenses that authorize or " - "otherwise pertain to the provision of care by the practitioner. For " - "example, a medical license issued by a medical board authorizing the " - "practitioner to practice medicine within a certian locality." - ), - # if property is element of this resource. - element_property=True, - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="A contact detail for the practitioner (that apply to all roles)", - description=( - "A contact detail for the practitioner, e.g. a telephone number or an " - "email address." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Practitioner`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "active", - "name", - "telecom", - "address", - "gender", - "birthDate", - "photo", - "qualification", - "communication", - ] - - -class PractitionerQualification(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Certification, licenses, or training pertaining to the provision of care. - The official certifications, training, and licenses that authorize or - otherwise pertain to the provision of care by the practitioner. For - example, a medical license issued by a medical board authorizing the - practitioner to practice medicine within a certian locality. - """ - - resource_type = Field("PractitionerQualification", const=True) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="Coded representation of the qualification", - description=None, - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="An identifier for this qualification for the practitioner", - description=( - "An identifier that applies to this person's qualification in this " "role." - ), - # if property is element of this resource. - element_property=True, - ) - - issuer: fhirtypes.ReferenceType = Field( - None, - alias="issuer", - title="Organization that regulates and issues the qualification", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Period during which the qualification is valid", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PractitionerQualification`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "code", - "period", - "issuer", - ] diff --git a/fhir/resources/practitionerrole.py b/fhir/resources/practitionerrole.py deleted file mode 100644 index b6c5c205..00000000 --- a/fhir/resources/practitionerrole.py +++ /dev/null @@ -1,436 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/PractitionerRole -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class PractitionerRole(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Roles/organizations the practitioner is associated with. - A specific set of Roles/Locations/specialties/services that a practitioner - may perform at an organization for a period of time. - """ - - resource_type = Field("PractitionerRole", const=True) - - active: bool = Field( - None, - alias="active", - title="Whether this practitioner role record is in active use", - description=None, - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - availabilityExceptions: fhirtypes.String = Field( - None, - alias="availabilityExceptions", - title="Description of availability exceptions", - description=( - "A description of site availability exceptions, e.g. public holiday " - "availability. Succinctly describing all possible exceptions to normal " - "site availability as details in the available Times and not available " - "Times." - ), - # if property is element of this resource. - element_property=True, - ) - availabilityExceptions__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_availabilityExceptions", - title="Extension field for ``availabilityExceptions``.", - ) - - availableTime: typing.List[fhirtypes.PractitionerRoleAvailableTimeType] = Field( - None, - alias="availableTime", - title="Times the Service Site is available", - description=( - "A collection of times the practitioner is available or performing this" - " role at the location and/or healthcareservice." - ), - # if property is element of this resource. - element_property=True, - ) - - code: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="code", - title="Roles which this practitioner may perform", - description=( - "Roles which this practitioner is authorized to perform for the " - "organization." - ), - # if property is element of this resource. - element_property=True, - ) - - endpoint: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="endpoint", - title=( - "Technical endpoints providing access to services operated for the " - "practitioner with this role" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Endpoint"], - ) - - healthcareService: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="healthcareService", - title=( - "The list of healthcare services that this worker provides for this " - "role's Organization/Location(s)" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["HealthcareService"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifiers that are specific to a role/location", - description=None, - # if property is element of this resource. - element_property=True, - ) - - location: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="location", - title="The location(s) at which this practitioner provides care", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - notAvailable: typing.List[fhirtypes.PractitionerRoleNotAvailableType] = Field( - None, - alias="notAvailable", - title="Not available during this time due to provided reason", - description=( - "The practitioner is not available or performing this role during this " - "period of time due to the provided reason." - ), - # if property is element of this resource. - element_property=True, - ) - - organization: fhirtypes.ReferenceType = Field( - None, - alias="organization", - title="Organization where the roles are available", - description="The organization where the Practitioner performs the roles associated.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title=( - "The period during which the practitioner is authorized to perform in " - "these role(s)" - ), - description=( - "The period during which the person is authorized to act as a " - "practitioner in these role(s) for the organization." - ), - # if property is element of this resource. - element_property=True, - ) - - practitioner: fhirtypes.ReferenceType = Field( - None, - alias="practitioner", - title=( - "Practitioner that is able to provide the defined services for the " - "organization" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner"], - ) - - specialty: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="specialty", - title="Specific specialty of the practitioner", - description=None, - # if property is element of this resource. - element_property=True, - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="Contact details that are specific to the role/location/service", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PractitionerRole`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "active", - "period", - "practitioner", - "organization", - "code", - "specialty", - "location", - "healthcareService", - "telecom", - "availableTime", - "notAvailable", - "availabilityExceptions", - "endpoint", - ] - - -class PractitionerRoleAvailableTime(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Times the Service Site is available. - A collection of times the practitioner is available or performing this role - at the location and/or healthcareservice. - """ - - resource_type = Field("PractitionerRoleAvailableTime", const=True) - - allDay: bool = Field( - None, - alias="allDay", - title="Always available? e.g. 24 hour service", - description=( - "Is this always available? (hence times are irrelevant) e.g. 24 hour " - "service." - ), - # if property is element of this resource. - element_property=True, - ) - allDay__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_allDay", title="Extension field for ``allDay``." - ) - - availableEndTime: fhirtypes.Time = Field( - None, - alias="availableEndTime", - title="Closing time of day (ignored if allDay = true)", - description=( - "The closing time of day. Note: If the AllDay flag is set, then this " - "time is ignored." - ), - # if property is element of this resource. - element_property=True, - ) - availableEndTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_availableEndTime", - title="Extension field for ``availableEndTime``.", - ) - - availableStartTime: fhirtypes.Time = Field( - None, - alias="availableStartTime", - title="Opening time of day (ignored if allDay = true)", - description=( - "The opening time of day. Note: If the AllDay flag is set, then this " - "time is ignored." - ), - # if property is element of this resource. - element_property=True, - ) - availableStartTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_availableStartTime", - title="Extension field for ``availableStartTime``.", - ) - - daysOfWeek: typing.List[fhirtypes.Code] = Field( - None, - alias="daysOfWeek", - title="mon | tue | wed | thu | fri | sat | sun", - description=( - "Indicates which days of the week are available between the start and " - "end Times." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["mon", "tue", "wed", "thu", "fri", "sat", "sun"], - ) - daysOfWeek__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_daysOfWeek", title="Extension field for ``daysOfWeek``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PractitionerRoleAvailableTime`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "daysOfWeek", - "allDay", - "availableStartTime", - "availableEndTime", - ] - - -class PractitionerRoleNotAvailable(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Not available during this time due to provided reason. - The practitioner is not available or performing this role during this - period of time due to the provided reason. - """ - - resource_type = Field("PractitionerRoleNotAvailable", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Reason presented to the user explaining why time not available", - description=( - "The reason that can be presented to the user as to why this time is " - "not available." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - during: fhirtypes.PeriodType = Field( - None, - alias="during", - title="Service not available from this date", - description=( - "Service is not available (seasonally or for a public holiday) from " - "this date." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``PractitionerRoleNotAvailable`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "description", "during"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3053( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("description", "description__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/procedure.py b/fhir/resources/procedure.py deleted file mode 100644 index 5cdffdb2..00000000 --- a/fhir/resources/procedure.py +++ /dev/null @@ -1,774 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Procedure -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Procedure(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An action that is being or was performed on a patient. - An action that is or was performed on or for a patient. This can be a - physical intervention like an operation, or less invasive like long term - services, counseling, or hypnotherapy. - """ - - resource_type = Field("Procedure", const=True) - - asserter: fhirtypes.ReferenceType = Field( - None, - alias="asserter", - title="Person who asserts this procedure", - description="Individual who is making the procedure statement.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "RelatedPerson", - "Practitioner", - "PractitionerRole", - ], - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="A request for this procedure", - description=( - "A reference to a resource that contains details of the request for " - "this procedure." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CarePlan", "ServiceRequest"], - ) - - bodySite: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="bodySite", - title="Target body sites", - description=( - "Detailed and structured anatomical location information. Multiple " - "locations are allowed - e.g. multiple punch biopsies of a lesion." - ), - # if property is element of this resource. - element_property=True, - ) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="Classification of the procedure", - description=( - "A code that classifies the procedure for searching, sorting and " - 'display purposes (e.g. "Surgical Procedure").' - ), - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Identification of the procedure", - description=( - "The specific procedure that is performed. Use text if the exact nature" - ' of the procedure cannot be coded (e.g. "Laparoscopic Appendectomy").' - ), - # if property is element of this resource. - element_property=True, - ) - - complication: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="complication", - title="Complication following the procedure", - description=( - "Any complications that occurred during the procedure, or in the " - "immediate post-performance period. These are generally tracked " - "separately from the notes, which will typically describe the procedure" - " itself rather than any 'post procedure' issues." - ), - # if property is element of this resource. - element_property=True, - ) - - complicationDetail: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="complicationDetail", - title="A condition that is a result of the procedure", - description=( - "Any complications that occurred during the procedure, or in the " - "immediate post-performance period." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition"], - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter created as part of", - description=( - "The Encounter during which this Procedure was created or performed or " - "to which the creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - focalDevice: typing.List[fhirtypes.ProcedureFocalDeviceType] = Field( - None, - alias="focalDevice", - title="Manipulated, implanted, or removed device", - description=( - "A device that is implanted, removed or otherwise manipulated " - "(calibration, battery replacement, fitting a prosthesis, attaching a " - "wound-vac, etc.) as a focal portion of the Procedure." - ), - # if property is element of this resource. - element_property=True, - ) - - followUp: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="followUp", - title="Instructions for follow up", - description=( - "If the procedure required specific follow up - e.g. removal of " - "sutures. The follow up may be represented as a simple note or could " - "potentially be more complex, in which case the CarePlan resource can " - "be used." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Identifiers for this procedure", - description=( - "Business identifiers assigned to this procedure by the performer or " - "other systems which remain constant as the resource is updated and is " - "propagated from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - instantiatesCanonical: typing.List[fhirtypes.Canonical] = Field( - None, - alias="instantiatesCanonical", - title="Instantiates FHIR protocol or definition", - description=( - "The URL pointing to a FHIR-defined protocol, guideline, order set or " - "other definition that is adhered to in whole or in part by this " - "Procedure." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "PlanDefinition", - "ActivityDefinition", - "Measure", - "OperationDefinition", - "Questionnaire", - ], - ) - instantiatesCanonical__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_instantiatesCanonical", - title="Extension field for ``instantiatesCanonical``.", - ) - - instantiatesUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiatesUri", - title="Instantiates external protocol or definition", - description=( - "The URL pointing to an externally maintained protocol, guideline, " - "order set or other definition that is adhered to in whole or in part " - "by this Procedure." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - location: fhirtypes.ReferenceType = Field( - None, - alias="location", - title="Where the procedure happened", - description=( - "The location where the procedure actually happened. E.g. a newborn at" - " home, a tracheostomy at a restaurant." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Additional information about the procedure", - description="Any other notes and comments about the procedure.", - # if property is element of this resource. - element_property=True, - ) - - outcome: fhirtypes.CodeableConceptType = Field( - None, - alias="outcome", - title="The result of procedure", - description=( - "The outcome of the procedure - did it resolve the reasons for the " - "procedure being performed?" - ), - # if property is element of this resource. - element_property=True, - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Part of referenced event", - description=( - "A larger event of which this particular procedure is a component or " - "step." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Procedure", "Observation", "MedicationAdministration"], - ) - - performedAge: fhirtypes.AgeType = Field( - None, - alias="performedAge", - title="When the procedure was performed", - description=( - "Estimated or actual date, date-time, period, or age when the procedure" - " was performed. Allows a period to support complex procedures that " - "span more than one date, and also allows for the length of the " - "procedure to be captured." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e performed[x] - one_of_many="performed", - one_of_many_required=False, - ) - - performedDateTime: fhirtypes.DateTime = Field( - None, - alias="performedDateTime", - title="When the procedure was performed", - description=( - "Estimated or actual date, date-time, period, or age when the procedure" - " was performed. Allows a period to support complex procedures that " - "span more than one date, and also allows for the length of the " - "procedure to be captured." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e performed[x] - one_of_many="performed", - one_of_many_required=False, - ) - performedDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_performedDateTime", - title="Extension field for ``performedDateTime``.", - ) - - performedPeriod: fhirtypes.PeriodType = Field( - None, - alias="performedPeriod", - title="When the procedure was performed", - description=( - "Estimated or actual date, date-time, period, or age when the procedure" - " was performed. Allows a period to support complex procedures that " - "span more than one date, and also allows for the length of the " - "procedure to be captured." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e performed[x] - one_of_many="performed", - one_of_many_required=False, - ) - - performedRange: fhirtypes.RangeType = Field( - None, - alias="performedRange", - title="When the procedure was performed", - description=( - "Estimated or actual date, date-time, period, or age when the procedure" - " was performed. Allows a period to support complex procedures that " - "span more than one date, and also allows for the length of the " - "procedure to be captured." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e performed[x] - one_of_many="performed", - one_of_many_required=False, - ) - - performedString: fhirtypes.String = Field( - None, - alias="performedString", - title="When the procedure was performed", - description=( - "Estimated or actual date, date-time, period, or age when the procedure" - " was performed. Allows a period to support complex procedures that " - "span more than one date, and also allows for the length of the " - "procedure to be captured." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e performed[x] - one_of_many="performed", - one_of_many_required=False, - ) - performedString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_performedString", title="Extension field for ``performedString``." - ) - - performer: typing.List[fhirtypes.ProcedurePerformerType] = Field( - None, - alias="performer", - title="The people who performed the procedure", - description='Limited to "real" people rather than equipment.', - # if property is element of this resource. - element_property=True, - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Coded reason procedure performed", - description=( - "The coded reason why the procedure was performed. This may be a coded " - "entity of some type, or may simply be present as text." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="The justification that the procedure was performed", - description="The justification of why the procedure was performed.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "Procedure", - "DiagnosticReport", - "DocumentReference", - ], - ) - - recorder: fhirtypes.ReferenceType = Field( - None, - alias="recorder", - title="Who recorded the procedure", - description=( - "Individual who recorded the record and takes responsibility for its " - "content." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "RelatedPerson", - "Practitioner", - "PractitionerRole", - ], - ) - - report: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="report", - title="Any report resulting from the procedure", - description=( - "This could be a histology result, pathology report, surgical report, " - "etc." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DiagnosticReport", "DocumentReference", "Composition"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "preparation | in-progress | not-done | on-hold | stopped | completed |" - " entered-in-error | unknown" - ), - description=( - "A code specifying the state of the procedure. Generally, this will be " - "the in-progress or completed state." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "preparation", - "in-progress", - "not-done", - "on-hold", - "stopped", - "completed", - "entered-in-error", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReason: fhirtypes.CodeableConceptType = Field( - None, - alias="statusReason", - title="Reason for current status", - description="Captures the reason for the current state of the procedure.", - # if property is element of this resource. - element_property=True, - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Who the procedure was performed on", - description="The person, animal or group on which the procedure was performed.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - usedCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="usedCode", - title="Coded items used during the procedure", - description="Identifies coded items that were used as part of the procedure.", - # if property is element of this resource. - element_property=True, - ) - - usedReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="usedReference", - title="Items used during procedure", - description=( - "Identifies medications, devices and any other substance used as part " - "of the procedure." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device", "Medication", "Substance"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Procedure`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "instantiatesCanonical", - "instantiatesUri", - "basedOn", - "partOf", - "status", - "statusReason", - "category", - "code", - "subject", - "encounter", - "performedDateTime", - "performedPeriod", - "performedString", - "performedAge", - "performedRange", - "recorder", - "asserter", - "performer", - "location", - "reasonCode", - "reasonReference", - "bodySite", - "outcome", - "report", - "complication", - "complicationDetail", - "followUp", - "note", - "focalDevice", - "usedReference", - "usedCode", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1118( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1118( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "performed": [ - "performedAge", - "performedDateTime", - "performedPeriod", - "performedRange", - "performedString", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ProcedureFocalDevice(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Manipulated, implanted, or removed device. - A device that is implanted, removed or otherwise manipulated (calibration, - battery replacement, fitting a prosthesis, attaching a wound-vac, etc.) as - a focal portion of the Procedure. - """ - - resource_type = Field("ProcedureFocalDevice", const=True) - - action: fhirtypes.CodeableConceptType = Field( - None, - alias="action", - title="Kind of change to device", - description="The kind of change that happened to the device during the procedure.", - # if property is element of this resource. - element_property=True, - ) - - manipulated: fhirtypes.ReferenceType = Field( - ..., - alias="manipulated", - title="Device that was changed", - description="The device that was manipulated (changed) during the procedure.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ProcedureFocalDevice`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "action", "manipulated"] - - -class ProcedurePerformer(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The people who performed the procedure. - Limited to "real" people rather than equipment. - """ - - resource_type = Field("ProcedurePerformer", const=True) - - actor: fhirtypes.ReferenceType = Field( - ..., - alias="actor", - title="The reference to the practitioner", - description="The practitioner who was involved in the procedure.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Patient", - "RelatedPerson", - "Device", - ], - ) - - function: fhirtypes.CodeableConceptType = Field( - None, - alias="function", - title="Type of performance", - description=( - "Distinguishes the type of involvement of the performer in the " - "procedure. For example, surgeon, anaesthetist, endoscopist." - ), - # if property is element of this resource. - element_property=True, - ) - - onBehalfOf: fhirtypes.ReferenceType = Field( - None, - alias="onBehalfOf", - title="Organization the device or practitioner was acting for", - description="The organization the device or practitioner was acting on behalf of.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ProcedurePerformer`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "function", - "actor", - "onBehalfOf", - ] diff --git a/fhir/resources/prodcharacteristic.py b/fhir/resources/prodcharacteristic.py deleted file mode 100644 index b1e8e409..00000000 --- a/fhir/resources/prodcharacteristic.py +++ /dev/null @@ -1,202 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ProdCharacteristic -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, fhirtypes - - -class ProdCharacteristic(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The marketing status describes the date when a medicinal product is - actually put on the market or the date as of which it is no longer - available. - """ - - resource_type = Field("ProdCharacteristic", const=True) - - color: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="color", - title=( - "Where applicable, the color can be specified An appropriate controlled" - " vocabulary shall be used The term and the term identifier shall be " - "used" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - color__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_color", title="Extension field for ``color``.") - - depth: fhirtypes.QuantityType = Field( - None, - alias="depth", - title=( - "Where applicable, the depth can be specified using a numerical value " - "and its unit of measurement The unit of measurement shall be specified" - " in accordance with ISO 11240 and the resulting terminology The symbol" - " and the symbol identifier shall be used" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - externalDiameter: fhirtypes.QuantityType = Field( - None, - alias="externalDiameter", - title=( - "Where applicable, the external diameter can be specified using a " - "numerical value and its unit of measurement The unit of measurement " - "shall be specified in accordance with ISO 11240 and the resulting " - "terminology The symbol and the symbol identifier shall be used" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - height: fhirtypes.QuantityType = Field( - None, - alias="height", - title=( - "Where applicable, the height can be specified using a numerical value " - "and its unit of measurement The unit of measurement shall be specified" - " in accordance with ISO 11240 and the resulting terminology The symbol" - " and the symbol identifier shall be used" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - image: typing.List[fhirtypes.AttachmentType] = Field( - None, - alias="image", - title=( - "Where applicable, the image can be provided The format of the image " - "attachment shall be specified by regional implementations" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - imprint: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="imprint", - title="Where applicable, the imprint can be specified as text", - description=None, - # if property is element of this resource. - element_property=True, - ) - imprint__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_imprint", title="Extension field for ``imprint``.") - - nominalVolume: fhirtypes.QuantityType = Field( - None, - alias="nominalVolume", - title=( - "Where applicable, the nominal volume can be specified using a " - "numerical value and its unit of measurement The unit of measurement " - "shall be specified in accordance with ISO 11240 and the resulting " - "terminology The symbol and the symbol identifier shall be used" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - scoring: fhirtypes.CodeableConceptType = Field( - None, - alias="scoring", - title=( - "Where applicable, the scoring can be specified An appropriate " - "controlled vocabulary shall be used The term and the term identifier " - "shall be used" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - shape: fhirtypes.String = Field( - None, - alias="shape", - title=( - "Where applicable, the shape can be specified An appropriate controlled" - " vocabulary shall be used The term and the term identifier shall be " - "used" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - shape__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_shape", title="Extension field for ``shape``." - ) - - weight: fhirtypes.QuantityType = Field( - None, - alias="weight", - title=( - "Where applicable, the weight can be specified using a numerical value " - "and its unit of measurement The unit of measurement shall be specified" - " in accordance with ISO 11240 and the resulting terminology The symbol" - " and the symbol identifier shall be used" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - width: fhirtypes.QuantityType = Field( - None, - alias="width", - title=( - "Where applicable, the width can be specified using a numerical value " - "and its unit of measurement The unit of measurement shall be specified" - " in accordance with ISO 11240 and the resulting terminology The symbol" - " and the symbol identifier shall be used" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ProdCharacteristic`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "height", - "width", - "depth", - "weight", - "nominalVolume", - "externalDiameter", - "shape", - "color", - "imprint", - "image", - "scoring", - ] diff --git a/fhir/resources/productshelflife.py b/fhir/resources/productshelflife.py deleted file mode 100644 index 4f111244..00000000 --- a/fhir/resources/productshelflife.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ProductShelfLife -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, fhirtypes - - -class ProductShelfLife(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The shelf-life and storage information for a medicinal product item or - container can be described using this class. - """ - - resource_type = Field("ProductShelfLife", const=True) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Unique identifier for the packaged Medicinal Product", - description=None, - # if property is element of this resource. - element_property=True, - ) - - period: fhirtypes.QuantityType = Field( - ..., - alias="period", - title=( - "The shelf life time period can be specified using a numerical value " - "for the period of time and its unit of time measurement The unit of " - "measurement shall be specified in accordance with ISO 11240 and the " - "resulting terminology The symbol and the symbol identifier shall be " - "used" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - specialPrecautionsForStorage: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="specialPrecautionsForStorage", - title=( - "Special precautions for storage, if any, can be specified using an " - "appropriate controlled vocabulary The controlled term and the " - "controlled term identifier shall be specified" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title=( - "This describes the shelf life, taking into account various scenarios " - "such as shelf life of the packaged Medicinal Product itself, shelf " - "life after transformation where necessary and shelf life after the " - "first opening of a bottle, etc. The shelf life type shall be specified" - " using an appropriate controlled vocabulary The controlled term and " - "the controlled term identifier shall be specified" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ProductShelfLife`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "type", - "period", - "specialPrecautionsForStorage", - ] diff --git a/fhir/resources/provenance.py b/fhir/resources/provenance.py deleted file mode 100644 index f197cdb3..00000000 --- a/fhir/resources/provenance.py +++ /dev/null @@ -1,509 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Provenance -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Provenance(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Who, What, When for a set of resources. - Provenance of a resource is a record that describes entities and processes - involved in producing and delivering or otherwise influencing that - resource. Provenance provides a critical foundation for assessing - authenticity, enabling trust, and allowing reproducibility. Provenance - assertions are a form of contextual metadata and can themselves become - important records with their own provenance. Provenance statement indicates - clinical significance in terms of confidence in authenticity, reliability, - and trustworthiness, integrity, and stage in lifecycle (e.g. Document - Completion - has the artifact been legally authenticated), all of which may - impact security, privacy, and trust policies. - """ - - resource_type = Field("Provenance", const=True) - - activity: fhirtypes.CodeableConceptType = Field( - None, - alias="activity", - title="Activity that occurred", - description=( - "An activity is something that occurs over a period of time and acts " - "upon or with entities; it may include consuming, processing, " - "transforming, modifying, relocating, using, or generating entities." - ), - # if property is element of this resource. - element_property=True, - ) - - agent: typing.List[fhirtypes.ProvenanceAgentType] = Field( - ..., - alias="agent", - title="Actor involved", - description=( - "An actor taking a role in an activity for which it can be assigned " - "some degree of responsibility for the activity taking place." - ), - # if property is element of this resource. - element_property=True, - ) - - entity: typing.List[fhirtypes.ProvenanceEntityType] = Field( - None, - alias="entity", - title="An entity used in this activity", - description=None, - # if property is element of this resource. - element_property=True, - ) - - location: fhirtypes.ReferenceType = Field( - None, - alias="location", - title="Where the activity occurred, if relevant", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - occurredDateTime: fhirtypes.DateTime = Field( - None, - alias="occurredDateTime", - title="When the activity occurred", - description="The period during which the activity occurred.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurred[x] - one_of_many="occurred", - one_of_many_required=False, - ) - occurredDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurredDateTime", - title="Extension field for ``occurredDateTime``.", - ) - - occurredPeriod: fhirtypes.PeriodType = Field( - None, - alias="occurredPeriod", - title="When the activity occurred", - description="The period during which the activity occurred.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurred[x] - one_of_many="occurred", - one_of_many_required=False, - ) - - policy: typing.List[fhirtypes.Uri] = Field( - None, - alias="policy", - title="Policy or plan the activity was defined by", - description=( - "Policy or plan the activity was defined by. Typically, a single " - "activity may have multiple applicable policy documents, such as " - "patient consent, guarantor funding, etc." - ), - # if property is element of this resource. - element_property=True, - ) - policy__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_policy", title="Extension field for ``policy``.") - - reason: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reason", - title="Reason the activity is occurring", - description="The reason that the activity was taking place.", - # if property is element of this resource. - element_property=True, - ) - - recorded: fhirtypes.Instant = Field( - None, - alias="recorded", - title="When the activity was recorded / updated", - description="The instant of time at which the activity was recorded.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - recorded__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_recorded", title="Extension field for ``recorded``." - ) - - signature: typing.List[fhirtypes.SignatureType] = Field( - None, - alias="signature", - title="Signature on target", - description=( - "A digital signature on the target Reference(s). The signer should " - "match a Provenance.agent. The purpose of the signature is indicated." - ), - # if property is element of this resource. - element_property=True, - ) - - target: typing.List[fhirtypes.ReferenceType] = Field( - ..., - alias="target", - title="Target Reference(s) (usually version specific)", - description=( - "The Reference(s) that were generated or updated by the activity " - "described in this resource. A provenance can point to more than one " - "target if multiple resources were created/updated by the same " - "activity." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Provenance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "target", - "occurredPeriod", - "occurredDateTime", - "recorded", - "policy", - "location", - "reason", - "activity", - "agent", - "entity", - "signature", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1222( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("recorded", "recorded__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1222( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"occurred": ["occurredDateTime", "occurredPeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ProvenanceAgent(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Actor involved. - An actor taking a role in an activity for which it can be assigned some - degree of responsibility for the activity taking place. - """ - - resource_type = Field("ProvenanceAgent", const=True) - - onBehalfOf: fhirtypes.ReferenceType = Field( - None, - alias="onBehalfOf", - title="Who the agent is representing", - description="The individual, device, or organization for whom the change was made.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Patient", - "Device", - "Organization", - ], - ) - - role: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="role", - title="What the agents role was", - description=( - "The function of the agent with respect to the activity. The security " - "role enabling the agent with respect to the activity." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="How the agent participated", - description="The participation the agent had with respect to the activity.", - # if property is element of this resource. - element_property=True, - ) - - who: fhirtypes.ReferenceType = Field( - ..., - alias="who", - title="Who participated", - description="The individual, device or organization that participated in the event.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Patient", - "Device", - "Organization", - ], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ProvenanceAgent`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "role", - "who", - "onBehalfOf", - ] - - -class ProvenanceEntity(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An entity used in this activity. - """ - - resource_type = Field("ProvenanceEntity", const=True) - - agent: typing.List[fhirtypes.ProvenanceAgentType] = Field( - None, - alias="agent", - title="Entity is attributed to this agent", - description=( - "The entity is attributed to an agent to express the agent's " - "responsibility for that entity, possibly along with other agents. This" - " description can be understood as shorthand for saying that the agent " - "was responsible for the activity which generated the entity." - ), - # if property is element of this resource. - element_property=True, - ) - - role: fhirtypes.Code = Field( - None, - alias="role", - title="derivation | revision | quotation | source | removal", - description="How the entity was used during the activity.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["derivation", "revision", "quotation", "source", "removal"], - ) - role__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_role", title="Extension field for ``role``." - ) - - what: fhirtypes.ReferenceType = Field( - ..., - alias="what", - title="Identity of entity", - description=( - "Identity of the Entity used. May be a logical or physical uri and " - "maybe absolute or relative." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ProvenanceEntity`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "role", "what", "agent"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1879( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("role", "role__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/quantity.py b/fhir/resources/quantity.py deleted file mode 100644 index 58e1db40..00000000 --- a/fhir/resources/quantity.py +++ /dev/null @@ -1,110 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SimpleQuantity -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import element, fhirtypes - - -class Quantity(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A measured or measurable amount. - A measured amount (or an amount that can potentially be measured). Note - that measured amounts include amounts that are not precisely quantified, - including amounts involving arbitrary units and floating currencies. - """ - - resource_type = Field("Quantity", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Coded form of the unit", - description=( - "A computer processable form of the unit in some unit representation " - "system." - ), - # if property is element of this resource. - element_property=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - comparator: fhirtypes.Code = Field( - None, - alias="comparator", - title="< | <= | >= | > - how to understand the value", - description=( - "How the value should be understood and represented - whether the " - "actual value is greater or less than the stated value due to " - 'measurement issues; e.g. if the comparator is "<" , then the real ' - "value is < stated value." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["\u003c", "\u003c=", "\u003e=", "\u003e"], - ) - comparator__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comparator", title="Extension field for ``comparator``." - ) - - system: fhirtypes.Uri = Field( - None, - alias="system", - title="System that defines coded unit form", - description=( - "The identification of the system that provides the coded form of the " - "unit." - ), - # if property is element of this resource. - element_property=True, - ) - system__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_system", title="Extension field for ``system``." - ) - - unit: fhirtypes.String = Field( - None, - alias="unit", - title="Unit representation", - description="A human-readable form of the unit.", - # if property is element of this resource. - element_property=True, - ) - unit__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_unit", title="Extension field for ``unit``." - ) - - value: fhirtypes.Decimal = Field( - None, - alias="value", - title="Numerical value (with implicit precision)", - description=( - "The value of the measured amount. The value includes an implicit " - "precision in the presentation of the value." - ), - # if property is element of this resource. - element_property=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Quantity`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "value", "comparator", "unit", "system", "code"] diff --git a/fhir/resources/questionnaire.py b/fhir/resources/questionnaire.py deleted file mode 100644 index 16a80bf3..00000000 --- a/fhir/resources/questionnaire.py +++ /dev/null @@ -1,1609 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Questionnaire -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Questionnaire(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A structured set of questions. - A structured set of questions intended to guide the collection of answers - from end-users. Questionnaires provide detailed control over order, - presentation, phraseology and grouping to allow coherent, consistent data - collection. - """ - - resource_type = Field("Questionnaire", const=True) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the questionnaire was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - code: typing.List[fhirtypes.CodingType] = Field( - None, - alias="code", - title="Concept that represents the overall questionnaire", - description=( - "An identifier for this question or group of questions in a particular " - "terminology such as LOINC." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the questionnaire and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the questionnaire." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the questionnaire was published. " - "The date must change when the business version changes and it must " - "change if the status code changes. In addition, it should change when " - "the substantive content of the questionnaire changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - derivedFrom: typing.List[fhirtypes.Canonical] = Field( - None, - alias="derivedFrom", - title="Instantiates protocol or definition", - description="The URL of a Questionnaire that this Questionnaire is based on.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Questionnaire"], - ) - derivedFrom__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_derivedFrom", title="Extension field for ``derivedFrom``.") - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the questionnaire", - description=( - "A free text natural language description of the questionnaire from a " - "consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the questionnaire is expected to be used", - description=( - "The period during which the questionnaire content was or is planned to" - " be in active use." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this questionnaire is authored for " - "testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the questionnaire", - description=( - "A formal identifier that is used to identify this questionnaire when " - "it is represented in other formats, or referenced in a specification, " - "model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - item: typing.List[fhirtypes.QuestionnaireItemType] = Field( - None, - alias="item", - title="Questions and sections within the Questionnaire", - description=( - "A particular question, question grouping or display text that is part " - "of the questionnaire." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for questionnaire (if applicable)", - description=( - "A legal or geographic region in which the questionnaire is intended to" - " be used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the questionnaire was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this questionnaire (computer friendly)", - description=( - "A natural language name identifying the questionnaire. This name " - "should be usable as an identifier for the module by machine processing" - " applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the " - "questionnaire." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this questionnaire is defined", - description=( - "Explanation of why this questionnaire is needed and why it has been " - "designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this questionnaire. Enables tracking the life-cycle of " - "the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subjectType: typing.List[fhirtypes.Code] = Field( - None, - alias="subjectType", - title="Resource that can be subject of QuestionnaireResponse", - description=( - "The types of subjects that can be the subject of responses created for" - " the questionnaire." - ), - # if property is element of this resource. - element_property=True, - ) - subjectType__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_subjectType", title="Extension field for ``subjectType``.") - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this questionnaire (human friendly)", - description="A short, descriptive, user-friendly title for the questionnaire.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this questionnaire, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this questionnaire when it is" - " referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this questionnaire is (or will be) published. This URL can" - " be the target of a canonical reference. It SHALL remain the same when" - " the questionnaire is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate questionnaire instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the questionnaire", - description=( - "The identifier that is used to identify this version of the " - "questionnaire when it is referenced in a specification, model, design " - "or instance. This is an arbitrary value managed by the questionnaire " - "author and is not expected to be globally unique. For example, it " - "might be a timestamp (e.g. yyyymmdd) if a managed version is not " - "available. There is also no expectation that versions can be placed in" - " a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Questionnaire`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "derivedFrom", - "status", - "experimental", - "subjectType", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "code", - "item", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1565( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class QuestionnaireItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Questions and sections within the Questionnaire. - A particular question, question grouping or display text that is part of - the questionnaire. - """ - - resource_type = Field("QuestionnaireItem", const=True) - - answerOption: typing.List[fhirtypes.QuestionnaireItemAnswerOptionType] = Field( - None, - alias="answerOption", - title="Permitted answer", - description='One of the permitted answers for a "choice" or "open-choice" question.', - # if property is element of this resource. - element_property=True, - ) - - answerValueSet: fhirtypes.Canonical = Field( - None, - alias="answerValueSet", - title="Valueset containing permitted answers", - description=( - "A reference to a value set containing a list of codes representing " - 'permitted answers for a "choice" or "open-choice" question.' - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - answerValueSet__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_answerValueSet", title="Extension field for ``answerValueSet``." - ) - - code: typing.List[fhirtypes.CodingType] = Field( - None, - alias="code", - title="Corresponding concept for this item in a terminology", - description=( - "A terminology code that corresponds to this group or question (e.g. a " - "code from LOINC, which defines many questions and answers)." - ), - # if property is element of this resource. - element_property=True, - ) - - definition: fhirtypes.Uri = Field( - None, - alias="definition", - title="ElementDefinition - details for the item", - description=( - "This element is a URI that refers to an " - "[ElementDefinition](elementdefinition.html) that provides information " - "about this item, including information that might otherwise be " - "included in the instance of the Questionnaire resource. A detailed " - "description of the construction of the URI is shown in Comments, " - "below. If this element is present then the following element values " - "MAY be derived from the Element Definition if the corresponding " - "elements of this Questionnaire resource instance have no value: * " - "code (ElementDefinition.code) * type (ElementDefinition.type) * " - "required (ElementDefinition.min) * repeats (ElementDefinition.max) *" - " maxLength (ElementDefinition.maxLength) * answerValueSet " - "(ElementDefinition.binding) * options (ElementDefinition.binding)." - ), - # if property is element of this resource. - element_property=True, - ) - definition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_definition", title="Extension field for ``definition``." - ) - - enableBehavior: fhirtypes.Code = Field( - None, - alias="enableBehavior", - title="all | any", - description=( - "Controls how multiple enableWhen values are interpreted - whether all" - " or any must be true." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["all", "any"], - ) - enableBehavior__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_enableBehavior", title="Extension field for ``enableBehavior``." - ) - - enableWhen: typing.List[fhirtypes.QuestionnaireItemEnableWhenType] = Field( - None, - alias="enableWhen", - title="Only allow data when", - description=( - "A constraint indicating that this item should only be enabled " - "(displayed/allow answers to be captured) when the specified condition " - "is true." - ), - # if property is element of this resource. - element_property=True, - ) - - initial: typing.List[fhirtypes.QuestionnaireItemInitialType] = Field( - None, - alias="initial", - title="Initial value(s) when item is first rendered", - description=( - "One or more values that should be pre-populated in the answer when " - "initially rendering the questionnaire for user input." - ), - # if property is element of this resource. - element_property=True, - ) - - item: typing.List[fhirtypes.QuestionnaireItemType] = Field( - None, - alias="item", - title="Nested questionnaire items", - description=( - "Text, questions and other groups to be nested beneath a question or " - "group." - ), - # if property is element of this resource. - element_property=True, - ) - - linkId: fhirtypes.String = Field( - None, - alias="linkId", - title="Unique id for item in questionnaire", - description=( - "An identifier that is unique within the Questionnaire allowing linkage" - " to the equivalent item in a QuestionnaireResponse resource." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - linkId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_linkId", title="Extension field for ``linkId``." - ) - - maxLength: fhirtypes.Integer = Field( - None, - alias="maxLength", - title="No more than this many characters", - description=( - "The maximum number of characters that are permitted in the answer to " - 'be considered a "valid" QuestionnaireResponse.' - ), - # if property is element of this resource. - element_property=True, - ) - maxLength__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_maxLength", title="Extension field for ``maxLength``." - ) - - prefix: fhirtypes.String = Field( - None, - alias="prefix", - title='E.g. "1(a)", "2.5.3"', - description=( - "A short label for a particular group, question or set of display text " - "within the questionnaire used for reference by the individual " - "completing the questionnaire." - ), - # if property is element of this resource. - element_property=True, - ) - prefix__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_prefix", title="Extension field for ``prefix``." - ) - - readOnly: bool = Field( - None, - alias="readOnly", - title="Don't allow human editing", - description=( - "An indication, when true, that the value cannot be changed by a human " - "respondent to the Questionnaire." - ), - # if property is element of this resource. - element_property=True, - ) - readOnly__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_readOnly", title="Extension field for ``readOnly``." - ) - - repeats: bool = Field( - None, - alias="repeats", - title="Whether the item may repeat", - description=( - "An indication, if true, that the item may occur multiple times in the " - "response, collecting multiple answers for questions or multiple sets " - "of answers for groups." - ), - # if property is element of this resource. - element_property=True, - ) - repeats__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_repeats", title="Extension field for ``repeats``." - ) - - required: bool = Field( - None, - alias="required", - title="Whether the item must be included in data results", - description=( - 'An indication, if true, that the item must be present in a "completed"' - " QuestionnaireResponse. If false, the item may be skipped when " - "answering the questionnaire." - ), - # if property is element of this resource. - element_property=True, - ) - required__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_required", title="Extension field for ``required``." - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Primary text for the item", - description=( - "The name of a section, the text of a question or text content for a " - "display item." - ), - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="group | display | boolean | decimal | integer | date | dateTime +", - description=( - "The type of questionnaire item this is - whether text for display, a " - "grouping of other items or a particular type of data to be captured " - "(string, integer, coded choice, etc.)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "group", - "display", - "boolean", - "decimal", - "integer", - "date", - "dateTime", - "+", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``QuestionnaireItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "linkId", - "definition", - "code", - "prefix", - "text", - "type", - "enableWhen", - "enableBehavior", - "required", - "repeats", - "readOnly", - "maxLength", - "answerValueSet", - "answerOption", - "initial", - "item", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1972( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("linkId", "linkId__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class QuestionnaireItemAnswerOption(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Permitted answer. - One of the permitted answers for a "choice" or "open-choice" question. - """ - - resource_type = Field("QuestionnaireItemAnswerOption", const=True) - - initialSelected: bool = Field( - None, - alias="initialSelected", - title="Whether option is selected by default", - description=( - "Indicates whether the answer value is selected when the list of " - "possible answers is initially shown." - ), - # if property is element of this resource. - element_property=True, - ) - initialSelected__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_initialSelected", title="Extension field for ``initialSelected``." - ) - - valueCoding: fhirtypes.CodingType = Field( - None, - alias="valueCoding", - title="Answer value", - description="A potential answer that's allowed as the answer to this question.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDate: fhirtypes.Date = Field( - None, - alias="valueDate", - title="Answer value", - description="A potential answer that's allowed as the answer to this question.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDate", title="Extension field for ``valueDate``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Answer value", - description="A potential answer that's allowed as the answer to this question.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="Answer value", - description="A potential answer that's allowed as the answer to this question.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Answer value", - description="A potential answer that's allowed as the answer to this question.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - valueTime: fhirtypes.Time = Field( - None, - alias="valueTime", - title="Answer value", - description="A potential answer that's allowed as the answer to this question.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueTime", title="Extension field for ``valueTime``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``QuestionnaireItemAnswerOption`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "valueInteger", - "valueDate", - "valueTime", - "valueString", - "valueCoding", - "valueReference", - "initialSelected", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3230( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueCoding", - "valueDate", - "valueInteger", - "valueReference", - "valueString", - "valueTime", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class QuestionnaireItemEnableWhen(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Only allow data when. - A constraint indicating that this item should only be enabled - (displayed/allow answers to be captured) when the specified condition is - true. - """ - - resource_type = Field("QuestionnaireItemEnableWhen", const=True) - - answerBoolean: bool = Field( - None, - alias="answerBoolean", - title="Value for question comparison based on operator", - description=( - "A value that the referenced question is tested using the specified " - "operator in order for the item to be enabled." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e answer[x] - one_of_many="answer", - one_of_many_required=True, - ) - answerBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_answerBoolean", title="Extension field for ``answerBoolean``." - ) - - answerCoding: fhirtypes.CodingType = Field( - None, - alias="answerCoding", - title="Value for question comparison based on operator", - description=( - "A value that the referenced question is tested using the specified " - "operator in order for the item to be enabled." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e answer[x] - one_of_many="answer", - one_of_many_required=True, - ) - - answerDate: fhirtypes.Date = Field( - None, - alias="answerDate", - title="Value for question comparison based on operator", - description=( - "A value that the referenced question is tested using the specified " - "operator in order for the item to be enabled." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e answer[x] - one_of_many="answer", - one_of_many_required=True, - ) - answerDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_answerDate", title="Extension field for ``answerDate``." - ) - - answerDateTime: fhirtypes.DateTime = Field( - None, - alias="answerDateTime", - title="Value for question comparison based on operator", - description=( - "A value that the referenced question is tested using the specified " - "operator in order for the item to be enabled." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e answer[x] - one_of_many="answer", - one_of_many_required=True, - ) - answerDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_answerDateTime", title="Extension field for ``answerDateTime``." - ) - - answerDecimal: fhirtypes.Decimal = Field( - None, - alias="answerDecimal", - title="Value for question comparison based on operator", - description=( - "A value that the referenced question is tested using the specified " - "operator in order for the item to be enabled." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e answer[x] - one_of_many="answer", - one_of_many_required=True, - ) - answerDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_answerDecimal", title="Extension field for ``answerDecimal``." - ) - - answerInteger: fhirtypes.Integer = Field( - None, - alias="answerInteger", - title="Value for question comparison based on operator", - description=( - "A value that the referenced question is tested using the specified " - "operator in order for the item to be enabled." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e answer[x] - one_of_many="answer", - one_of_many_required=True, - ) - answerInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_answerInteger", title="Extension field for ``answerInteger``." - ) - - answerQuantity: fhirtypes.QuantityType = Field( - None, - alias="answerQuantity", - title="Value for question comparison based on operator", - description=( - "A value that the referenced question is tested using the specified " - "operator in order for the item to be enabled." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e answer[x] - one_of_many="answer", - one_of_many_required=True, - ) - - answerReference: fhirtypes.ReferenceType = Field( - None, - alias="answerReference", - title="Value for question comparison based on operator", - description=( - "A value that the referenced question is tested using the specified " - "operator in order for the item to be enabled." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e answer[x] - one_of_many="answer", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - answerString: fhirtypes.String = Field( - None, - alias="answerString", - title="Value for question comparison based on operator", - description=( - "A value that the referenced question is tested using the specified " - "operator in order for the item to be enabled." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e answer[x] - one_of_many="answer", - one_of_many_required=True, - ) - answerString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_answerString", title="Extension field for ``answerString``." - ) - - answerTime: fhirtypes.Time = Field( - None, - alias="answerTime", - title="Value for question comparison based on operator", - description=( - "A value that the referenced question is tested using the specified " - "operator in order for the item to be enabled." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e answer[x] - one_of_many="answer", - one_of_many_required=True, - ) - answerTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_answerTime", title="Extension field for ``answerTime``." - ) - - operator: fhirtypes.Code = Field( - None, - alias="operator", - title="exists | = | != | > | < | >= | <=", - description="Specifies the criteria by which the question is enabled.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["exists", "=", "!=", "\u003e", "\u003c", "\u003e=", "\u003c="], - ) - operator__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_operator", title="Extension field for ``operator``." - ) - - question: fhirtypes.String = Field( - None, - alias="question", - title="Question that determines whether item is enabled", - description=( - "The linkId for the question whose answer (or lack of answer) governs " - "whether this item is enabled." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - question__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_question", title="Extension field for ``question``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``QuestionnaireItemEnableWhen`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "question", - "operator", - "answerBoolean", - "answerDecimal", - "answerInteger", - "answerDate", - "answerDateTime", - "answerTime", - "answerString", - "answerCoding", - "answerQuantity", - "answerReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2958( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("operator", "operator__ext"), ("question", "question__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2958( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "answer": [ - "answerBoolean", - "answerCoding", - "answerDate", - "answerDateTime", - "answerDecimal", - "answerInteger", - "answerQuantity", - "answerReference", - "answerString", - "answerTime", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class QuestionnaireItemInitial(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Initial value(s) when item is first rendered. - One or more values that should be pre-populated in the answer when - initially rendering the questionnaire for user input. - """ - - resource_type = Field("QuestionnaireItemInitial", const=True) - - valueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="valueAttachment", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCoding: fhirtypes.CodingType = Field( - None, - alias="valueCoding", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDate: fhirtypes.Date = Field( - None, - alias="valueDate", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDate", title="Extension field for ``valueDate``." - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueDecimal: fhirtypes.Decimal = Field( - None, - alias="valueDecimal", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDecimal", title="Extension field for ``valueDecimal``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - valueTime: fhirtypes.Time = Field( - None, - alias="valueTime", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueTime", title="Extension field for ``valueTime``." - ) - - valueUri: fhirtypes.Uri = Field( - None, - alias="valueUri", - title="Actual value for initializing the question", - description="The actual value to for an initial answer.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUri", title="Extension field for ``valueUri``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``QuestionnaireItemInitial`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "valueBoolean", - "valueDecimal", - "valueInteger", - "valueDate", - "valueDateTime", - "valueTime", - "valueString", - "valueUri", - "valueAttachment", - "valueCoding", - "valueQuantity", - "valueReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2685( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueAttachment", - "valueBoolean", - "valueCoding", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueInteger", - "valueQuantity", - "valueReference", - "valueString", - "valueTime", - "valueUri", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/questionnaireresponse.py b/fhir/resources/questionnaireresponse.py deleted file mode 100644 index 9a342526..00000000 --- a/fhir/resources/questionnaireresponse.py +++ /dev/null @@ -1,749 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class QuestionnaireResponse(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A structured set of questions and their answers. - A structured set of questions and their answers. The questions are ordered - and grouped into coherent subsets, corresponding to the structure of the - grouping of the questionnaire being responded to. - """ - - resource_type = Field("QuestionnaireResponse", const=True) - - author: fhirtypes.ReferenceType = Field( - None, - alias="author", - title="Person who received and recorded the answers", - description=( - "Person who received the answers to the questions in the " - "QuestionnaireResponse and recorded them in the system." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Device", - "Practitioner", - "PractitionerRole", - "Patient", - "RelatedPerson", - "Organization", - ], - ) - - authored: fhirtypes.DateTime = Field( - None, - alias="authored", - title="Date the answers were gathered", - description="The date and/or time that this set of answers were last changed.", - # if property is element of this resource. - element_property=True, - ) - authored__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_authored", title="Extension field for ``authored``." - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Request fulfilled by this QuestionnaireResponse", - description=( - "The order, proposal or plan that is fulfilled in whole or in part by " - "this QuestionnaireResponse. For example, a ServiceRequest seeking an " - "intake assessment or a decision support recommendation to assess for " - "post-partum depression." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CarePlan", "ServiceRequest"], - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter created as part of", - description=( - "The Encounter during which this questionnaire response was created or " - "to which the creation of this record is tightly associated." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Unique id for this set of answers", - description=( - "A business identifier assigned to a particular completed (or partially" - " completed) questionnaire." - ), - # if property is element of this resource. - element_property=True, - ) - - item: typing.List[fhirtypes.QuestionnaireResponseItemType] = Field( - None, - alias="item", - title="Groups and questions", - description=( - "A group or question item from the original questionnaire for which " - "answers are provided." - ), - # if property is element of this resource. - element_property=True, - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Part of this action", - description=( - "A procedure or observation that this questionnaire was performed as " - "part of the execution of. For example, the surgery a checklist was " - "executed as part of." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Observation", "Procedure"], - ) - - questionnaire: fhirtypes.Canonical = Field( - None, - alias="questionnaire", - title="Form being answered", - description=( - "The Questionnaire that defines and organizes the questions for which " - "answers are being provided." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Questionnaire"], - ) - questionnaire__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_questionnaire", title="Extension field for ``questionnaire``." - ) - - source: fhirtypes.ReferenceType = Field( - None, - alias="source", - title="The person who answered the questions", - description="The person who answered the questions about the subject.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - ], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="in-progress | completed | amended | entered-in-error | stopped", - description=( - "The position of the questionnaire response within its overall " - "lifecycle." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "in-progress", - "completed", - "amended", - "entered-in-error", - "stopped", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="The subject of the questions", - description=( - "The subject of the questionnaire response. This could be a patient, " - "organization, practitioner, device, etc. This is who/what the answers" - " apply to, but is not necessarily the source of information." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``QuestionnaireResponse`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "basedOn", - "partOf", - "questionnaire", - "status", - "subject", - "encounter", - "authored", - "author", - "source", - "item", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2412( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class QuestionnaireResponseItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Groups and questions. - A group or question item from the original questionnaire for which answers - are provided. - """ - - resource_type = Field("QuestionnaireResponseItem", const=True) - - answer: typing.List[fhirtypes.QuestionnaireResponseItemAnswerType] = Field( - None, - alias="answer", - title="The response(s) to the question", - description="The respondent's answer(s) to the question.", - # if property is element of this resource. - element_property=True, - ) - - definition: fhirtypes.Uri = Field( - None, - alias="definition", - title="ElementDefinition - details for the item", - description=( - "A reference to an [ElementDefinition](elementdefinition.html) that " - "provides the details for the item." - ), - # if property is element of this resource. - element_property=True, - ) - definition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_definition", title="Extension field for ``definition``." - ) - - item: typing.List[fhirtypes.QuestionnaireResponseItemType] = Field( - None, - alias="item", - title="Nested questionnaire response items", - description="Questions or sub-groups nested beneath a question or group.", - # if property is element of this resource. - element_property=True, - ) - - linkId: fhirtypes.String = Field( - None, - alias="linkId", - title="Pointer to specific item from Questionnaire", - description=( - "The item from the Questionnaire that corresponds to this item in the " - "QuestionnaireResponse resource." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - linkId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_linkId", title="Extension field for ``linkId``." - ) - - text: fhirtypes.String = Field( - None, - alias="text", - title="Name for group or question text", - description=( - "Text that is displayed above the contents of the group or as the text " - "of the question being answered." - ), - # if property is element of this resource. - element_property=True, - ) - text__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_text", title="Extension field for ``text``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``QuestionnaireResponseItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "linkId", - "definition", - "text", - "answer", - "item", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2819( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("linkId", "linkId__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class QuestionnaireResponseItemAnswer(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The response(s) to the question. - The respondent's answer(s) to the question. - """ - - resource_type = Field("QuestionnaireResponseItemAnswer", const=True) - - item: typing.List[fhirtypes.QuestionnaireResponseItemType] = Field( - None, - alias="item", - title="Nested groups and questions", - description="Nested groups and/or questions found within this particular answer.", - # if property is element of this resource. - element_property=True, - ) - - valueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="valueAttachment", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCoding: fhirtypes.CodingType = Field( - None, - alias="valueCoding", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueDate: fhirtypes.Date = Field( - None, - alias="valueDate", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDate", title="Extension field for ``valueDate``." - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueDecimal: fhirtypes.Decimal = Field( - None, - alias="valueDecimal", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDecimal", title="Extension field for ``valueDecimal``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - valueTime: fhirtypes.Time = Field( - None, - alias="valueTime", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueTime", title="Extension field for ``valueTime``." - ) - - valueUri: fhirtypes.Uri = Field( - None, - alias="valueUri", - title="Single-valued answer to the question", - description=( - "The answer (or one of the answers) provided by the respondent to the " - "question." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUri", title="Extension field for ``valueUri``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``QuestionnaireResponseItemAnswer`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "valueBoolean", - "valueDecimal", - "valueInteger", - "valueDate", - "valueDateTime", - "valueTime", - "valueString", - "valueUri", - "valueAttachment", - "valueCoding", - "valueQuantity", - "valueReference", - "item", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3448( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueAttachment", - "valueBoolean", - "valueCoding", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueInteger", - "valueQuantity", - "valueReference", - "valueString", - "valueTime", - "valueUri", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/range.py b/fhir/resources/range.py deleted file mode 100644 index 1eccf5e1..00000000 --- a/fhir/resources/range.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Range -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import element, fhirtypes - - -class Range(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Set of values bounded by low and high. - A set of ordered Quantities defined by a low and high limit. - """ - - resource_type = Field("Range", const=True) - - high: fhirtypes.QuantityType = Field( - None, - alias="high", - title="High limit", - description="The high limit. The boundary is inclusive.", - # if property is element of this resource. - element_property=True, - ) - - low: fhirtypes.QuantityType = Field( - None, - alias="low", - title="Low limit", - description="The low limit. The boundary is inclusive.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Range`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "low", "high"] diff --git a/fhir/resources/ratio.py b/fhir/resources/ratio.py deleted file mode 100644 index a8b2bd4d..00000000 --- a/fhir/resources/ratio.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Ratio -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import element, fhirtypes - - -class Ratio(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A ratio of two Quantity values - a numerator and a denominator. - A relationship of two Quantity values - expressed as a numerator and a - denominator. - """ - - resource_type = Field("Ratio", const=True) - - denominator: fhirtypes.QuantityType = Field( - None, - alias="denominator", - title="Denominator value", - description="The value of the denominator.", - # if property is element of this resource. - element_property=True, - ) - - numerator: fhirtypes.QuantityType = Field( - None, - alias="numerator", - title="Numerator value", - description="The value of the numerator.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Ratio`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "numerator", "denominator"] diff --git a/fhir/resources/reference.py b/fhir/resources/reference.py deleted file mode 100644 index 9a65fb08..00000000 --- a/fhir/resources/reference.py +++ /dev/null @@ -1,106 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Reference -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import element, fhirtypes - - -class Reference(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A reference from one resource to another. - """ - - resource_type = Field("Reference", const=True) - - display: fhirtypes.String = Field( - None, - alias="display", - title="Text alternative for the resource", - description=( - "Plain text narrative that identifies the resource in addition to the " - "resource reference." - ), - # if property is element of this resource. - element_property=True, - ) - display__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_display", title="Extension field for ``display``." - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Logical reference, when literal reference is not known", - description=( - "An identifier for the target resource. This is used when there is no " - "way to reference the other resource directly, either because the " - "entity it represents is not available through a FHIR server, or " - "because there is no way for the author of the resource to convert a " - "known identifier to an actual location. There is no requirement that a" - " Reference.identifier point to something that is actually exposed as a" - " FHIR instance, but it SHALL point to a business concept that would be" - " expected to be exposed as a FHIR instance, and that instance would " - "need to be of a FHIR resource type allowed by the reference." - ), - # if property is element of this resource. - element_property=True, - ) - - reference: fhirtypes.String = Field( - None, - alias="reference", - title="Literal reference, Relative, internal or absolute URL", - description=( - "A reference to a location at which the other resource is found. The " - "reference may be a relative reference, in which case it is relative to" - " the service base URL, or an absolute URL that resolves to the " - "location where the resource is found. The reference may be version " - "specific or not. If the reference is not to a FHIR RESTful server, " - "then it should be assumed to be version specific. Internal fragment " - "references (start with '#') refer to contained resources." - ), - # if property is element of this resource. - element_property=True, - ) - reference__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_reference", title="Extension field for ``reference``." - ) - - type: fhirtypes.Uri = Field( - None, - alias="type", - title='Type the reference refers to (e.g. "Patient")', - description=( - "The expected type of the target of the reference. If both " - "Reference.type and Reference.reference are populated and " - "Reference.reference is a FHIR URL, both SHALL be consistent. The type" - " is the Canonical URL of Resource Definition that is the type this " - "reference refers to. References are URLs that are relative to " - 'http://hl7.org/fhir/StructureDefinition/ e.g. "Patient" is a reference' - " to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are" - " only allowed for logical models (and can only be used in references " - "in logical models, not resources)." - ), - # if property is element of this resource. - element_property=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Reference`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "reference", "type", "identifier", "display"] diff --git a/fhir/resources/relatedartifact.py b/fhir/resources/relatedartifact.py deleted file mode 100644 index 3e3e7ca9..00000000 --- a/fhir/resources/relatedartifact.py +++ /dev/null @@ -1,222 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/RelatedArtifact -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import element, fhirtypes - - -class RelatedArtifact(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Related artifacts for a knowledge resource. - Related artifacts such as additional documentation, justification, or - bibliographic references. - """ - - resource_type = Field("RelatedArtifact", const=True) - - citation: fhirtypes.Markdown = Field( - None, - alias="citation", - title="Bibliographic citation for the artifact", - description=( - "A bibliographic citation for the related artifact. This text SHOULD be" - " formatted according to an accepted citation format." - ), - # if property is element of this resource. - element_property=True, - ) - citation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_citation", title="Extension field for ``citation``." - ) - - display: fhirtypes.String = Field( - None, - alias="display", - title="Brief description of the related artifact", - description=( - "A brief description of the document or knowledge resource being " - "referenced, suitable for display to a consumer." - ), - # if property is element of this resource. - element_property=True, - ) - display__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_display", title="Extension field for ``display``." - ) - - document: fhirtypes.AttachmentType = Field( - None, - alias="document", - title="What document is being referenced", - description=( - "The document being referenced, represented as an attachment. This is " - "exclusive with the resource element." - ), - # if property is element of this resource. - element_property=True, - ) - - label: fhirtypes.String = Field( - None, - alias="label", - title="Short label", - description=( - "A short label that can be used to reference the citation from " - "elsewhere in the containing artifact, such as a footnote index." - ), - # if property is element of this resource. - element_property=True, - ) - label__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_label", title="Extension field for ``label``." - ) - - resource: fhirtypes.Canonical = Field( - None, - alias="resource", - title="What resource is being referenced", - description=( - "The related resource, such as a library, value set, profile, or other " - "knowledge resource." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - resource__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_resource", title="Extension field for ``resource``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title=( - "documentation | justification | citation | predecessor | successor | " - "derived-from | depends-on | composed-of" - ), - description="The type of relationship to the related artifact.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "documentation", - "justification", - "citation", - "predecessor", - "successor", - "derived-from", - "depends-on", - "composed-of", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - url: fhirtypes.Url = Field( - None, - alias="url", - title="Where the artifact can be accessed", - description=( - "A url for the artifact that can be followed to access the actual " - "content." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RelatedArtifact`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "type", - "label", - "display", - "citation", - "url", - "document", - "resource", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1717( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/relatedperson.py b/fhir/resources/relatedperson.py deleted file mode 100644 index 37676186..00000000 --- a/fhir/resources/relatedperson.py +++ /dev/null @@ -1,245 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/RelatedPerson -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class RelatedPerson(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A person that is related to a patient, but who is not a direct target of - care. - Information about a person that is involved in the care for a patient, but - who is not the target of healthcare, nor has a formal responsibility in the - care process. - """ - - resource_type = Field("RelatedPerson", const=True) - - active: bool = Field( - None, - alias="active", - title="Whether this related person's record is in active use", - description="Whether this related person record is in active use.", - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - address: typing.List[fhirtypes.AddressType] = Field( - None, - alias="address", - title="Address where the related person can be contacted or visited", - description=None, - # if property is element of this resource. - element_property=True, - ) - - birthDate: fhirtypes.Date = Field( - None, - alias="birthDate", - title="The date on which the related person was born", - description=None, - # if property is element of this resource. - element_property=True, - ) - birthDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_birthDate", title="Extension field for ``birthDate``." - ) - - communication: typing.List[fhirtypes.RelatedPersonCommunicationType] = Field( - None, - alias="communication", - title=( - "A language which may be used to communicate with about the patient's " - "health" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - gender: fhirtypes.Code = Field( - None, - alias="gender", - title="male | female | other | unknown", - description=( - "Administrative Gender - the gender that the person is considered to " - "have for administration and record keeping purposes." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["male", "female", "other", "unknown"], - ) - gender__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_gender", title="Extension field for ``gender``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="A human identifier for this person", - description="Identifier for a person within a particular scope.", - # if property is element of this resource. - element_property=True, - ) - - name: typing.List[fhirtypes.HumanNameType] = Field( - None, - alias="name", - title="A name associated with the person", - description=None, - # if property is element of this resource. - element_property=True, - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="The patient this person is related to", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Period of time that this relationship is considered valid", - description=( - "The period of time during which this relationship is or was active. If" - " there are no dates defined, then the interval is unknown." - ), - # if property is element of this resource. - element_property=True, - ) - - photo: typing.List[fhirtypes.AttachmentType] = Field( - None, - alias="photo", - title="Image of the person", - description=None, - # if property is element of this resource. - element_property=True, - ) - - relationship: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="relationship", - title="The nature of the relationship", - description=( - "The nature of the relationship between a patient and the related " - "person." - ), - # if property is element of this resource. - element_property=True, - ) - - telecom: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="telecom", - title="A contact detail for the person", - description=( - "A contact detail for the person, e.g. a telephone number or an email " - "address." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RelatedPerson`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "active", - "patient", - "relationship", - "name", - "telecom", - "gender", - "birthDate", - "address", - "photo", - "period", - "communication", - ] - - -class RelatedPersonCommunication(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A language which may be used to communicate with about the patient's health. - """ - - resource_type = Field("RelatedPersonCommunication", const=True) - - language: fhirtypes.CodeableConceptType = Field( - ..., - alias="language", - title=( - "The language which can be used to communicate with the patient about " - "his or her health" - ), - description=( - "The ISO-639-1 alpha 2 code in lower case for the language, optionally " - "followed by a hyphen and the ISO-3166-1 alpha 2 code for the region in" - ' upper case; e.g. "en" for English, or "en-US" for American English ' - 'versus "en-EN" for England English.' - ), - # if property is element of this resource. - element_property=True, - ) - - preferred: bool = Field( - None, - alias="preferred", - title="Language preference indicator", - description=( - "Indicates whether or not the patient prefers this language (over other" - " languages he masters up a certain level)." - ), - # if property is element of this resource. - element_property=True, - ) - preferred__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_preferred", title="Extension field for ``preferred``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RelatedPersonCommunication`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "language", "preferred"] diff --git a/fhir/resources/requestgroup.py b/fhir/resources/requestgroup.py deleted file mode 100644 index 129265b8..00000000 --- a/fhir/resources/requestgroup.py +++ /dev/null @@ -1,1143 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/RequestGroup -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class RequestGroup(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A group of related requests. - A group of related requests that can be used to capture intended activities - that have inter-dependencies such as "give this medication after that one". - """ - - resource_type = Field("RequestGroup", const=True) - - action: typing.List[fhirtypes.RequestGroupActionType] = Field( - None, - alias="action", - title="Proposed actions, if any", - description="The actions, if any, produced by the evaluation of the artifact.", - # if property is element of this resource. - element_property=True, - ) - - author: fhirtypes.ReferenceType = Field( - None, - alias="author", - title="Device or practitioner that authored the request group", - description="Provides a reference to the author of the request group.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Device", "Practitioner", "PractitionerRole"], - ) - - authoredOn: fhirtypes.DateTime = Field( - None, - alias="authoredOn", - title="When the request group was authored", - description="Indicates when the request group was created.", - # if property is element of this resource. - element_property=True, - ) - authoredOn__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_authoredOn", title="Extension field for ``authoredOn``." - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Fulfills plan, proposal, or order", - description=( - "A plan, proposal or order that is fulfilled in whole or in part by " - "this request." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="What's being requested/ordered", - description="A code that identifies what the overall request group is.", - # if property is element of this resource. - element_property=True, - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Created as part of", - description="Describes the context of the request group, if any.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - groupIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="groupIdentifier", - title="Composite request this is part of", - description=( - "A shared identifier common to all requests that were authorized more " - "or less simultaneously by a single author, representing the identifier" - " of the requisition, prescription or similar form." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business identifier", - description=( - "Allows a service to provide a unique, business identifier for the " - "request." - ), - # if property is element of this resource. - element_property=True, - ) - - instantiatesCanonical: typing.List[fhirtypes.Canonical] = Field( - None, - alias="instantiatesCanonical", - title="Instantiates FHIR protocol or definition", - description=( - "A canonical URL referencing a FHIR-defined protocol, guideline, " - "orderset or other definition that is adhered to in whole or in part by" - " this request." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesCanonical__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_instantiatesCanonical", - title="Extension field for ``instantiatesCanonical``.", - ) - - instantiatesUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiatesUri", - title="Instantiates external protocol or definition", - description=( - "A URL referencing an externally defined protocol, guideline, orderset " - "or other definition that is adhered to in whole or in part by this " - "request." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - intent: fhirtypes.Code = Field( - None, - alias="intent", - title=( - "proposal | plan | directive | order | original-order | reflex-order | " - "filler-order | instance-order | option" - ), - description=( - "Indicates the level of authority/intentionality associated with the " - "request and where the request fits into the workflow chain." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "proposal", - "plan", - "directive", - "order", - "original-order", - "reflex-order", - "filler-order", - "instance-order", - "option", - ], - ) - intent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_intent", title="Extension field for ``intent``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Additional notes about the response", - description=( - "Provides a mechanism to communicate additional information about the " - "response." - ), - # if property is element of this resource. - element_property=True, - ) - - priority: fhirtypes.Code = Field( - None, - alias="priority", - title="routine | urgent | asap | stat", - description=( - "Indicates how quickly the request should be addressed with respect to " - "other requests." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["routine", "urgent", "asap", "stat"], - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why the request group is needed", - description="Describes the reason for the request group in coded or textual form.", - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why the request group is needed", - description=( - "Indicates another resource whose existence justifies this request " - "group." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "DiagnosticReport", - "DocumentReference", - ], - ) - - replaces: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="replaces", - title="Request(s) replaced by this request", - description=( - "Completed or terminated request(s) whose function is taken by this new" - " request." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "draft | active | on-hold | revoked | completed | entered-in-error | " - "unknown" - ), - description=( - "The current state of the request. For request groups, the status " - "reflects the status of all the requests in the group." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "draft", - "active", - "on-hold", - "revoked", - "completed", - "entered-in-error", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title="Who the request group is about", - description="The subject for which the request group was created.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RequestGroup`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "instantiatesCanonical", - "instantiatesUri", - "basedOn", - "replaces", - "groupIdentifier", - "status", - "intent", - "priority", - "code", - "subject", - "encounter", - "authoredOn", - "author", - "reasonCode", - "reasonReference", - "note", - "action", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1464( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("intent", "intent__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class RequestGroupAction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Proposed actions, if any. - The actions, if any, produced by the evaluation of the artifact. - """ - - resource_type = Field("RequestGroupAction", const=True) - - action: typing.List[fhirtypes.RequestGroupActionType] = Field( - None, - alias="action", - title="Sub action", - description="Sub actions.", - # if property is element of this resource. - element_property=True, - ) - - cardinalityBehavior: fhirtypes.Code = Field( - None, - alias="cardinalityBehavior", - title="single | multiple", - description="Defines whether the action can be selected multiple times.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["single", "multiple"], - ) - cardinalityBehavior__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_cardinalityBehavior", - title="Extension field for ``cardinalityBehavior``.", - ) - - code: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="code", - title="Code representing the meaning of the action or sub-actions", - description=( - "A code that provides meaning for the action or action group. For " - "example, a section may have a LOINC code for a section of a " - "documentation template." - ), - # if property is element of this resource. - element_property=True, - ) - - condition: typing.List[fhirtypes.RequestGroupActionConditionType] = Field( - None, - alias="condition", - title="Whether or not the action is applicable", - description=( - "An expression that describes applicability criteria, or start/stop " - "conditions for the action." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Short description of the action", - description=( - "A short description of the action used to provide a summary to display" - " to the user." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - documentation: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="documentation", - title="Supporting documentation for the intended performer of the action", - description=( - "Didactic or other informational resources associated with the action " - "that can be provided to the CDS recipient. Information resources can " - "include inline text commentary and links to web resources." - ), - # if property is element of this resource. - element_property=True, - ) - - groupingBehavior: fhirtypes.Code = Field( - None, - alias="groupingBehavior", - title="visual-group | logical-group | sentence-group", - description="Defines the grouping behavior for the action and its children.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["visual-group", "logical-group", "sentence-group"], - ) - groupingBehavior__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_groupingBehavior", - title="Extension field for ``groupingBehavior``.", - ) - - participant: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="participant", - title="Who should perform the action", - description="The participant that should perform or be responsible for this action.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Device", - ], - ) - - precheckBehavior: fhirtypes.Code = Field( - None, - alias="precheckBehavior", - title="yes | no", - description="Defines whether the action should usually be preselected.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["yes", "no"], - ) - precheckBehavior__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_precheckBehavior", - title="Extension field for ``precheckBehavior``.", - ) - - prefix: fhirtypes.String = Field( - None, - alias="prefix", - title="User-visible prefix for the action (e.g. 1. or A.)", - description="A user-visible prefix for the action.", - # if property is element of this resource. - element_property=True, - ) - prefix__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_prefix", title="Extension field for ``prefix``." - ) - - priority: fhirtypes.Code = Field( - None, - alias="priority", - title="routine | urgent | asap | stat", - description=( - "Indicates how quickly the action should be addressed with respect to " - "other actions." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["routine", "urgent", "asap", "stat"], - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - relatedAction: typing.List[fhirtypes.RequestGroupActionRelatedActionType] = Field( - None, - alias="relatedAction", - title="Relationship to another action", - description=( - 'A relationship to another action such as "before" or "30-60 minutes ' - 'after start of".' - ), - # if property is element of this resource. - element_property=True, - ) - - requiredBehavior: fhirtypes.Code = Field( - None, - alias="requiredBehavior", - title="must | could | must-unless-documented", - description="Defines expectations around whether an action is required.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["must", "could", "must-unless-documented"], - ) - requiredBehavior__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_requiredBehavior", - title="Extension field for ``requiredBehavior``.", - ) - - resource: fhirtypes.ReferenceType = Field( - None, - alias="resource", - title="The target of the action", - description=( - "The resource that is the target of the action (e.g. " - "CommunicationRequest)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - selectionBehavior: fhirtypes.Code = Field( - None, - alias="selectionBehavior", - title="any | all | all-or-none | exactly-one | at-most-one | one-or-more", - description="Defines the selection behavior for the action and its children.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "any", - "all", - "all-or-none", - "exactly-one", - "at-most-one", - "one-or-more", - ], - ) - selectionBehavior__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_selectionBehavior", - title="Extension field for ``selectionBehavior``.", - ) - - textEquivalent: fhirtypes.String = Field( - None, - alias="textEquivalent", - title=( - "Static text equivalent of the action, used if the dynamic aspects " - "cannot be interpreted by the receiving system" - ), - description=( - "A text equivalent of the action to be performed. This provides a " - "human-interpretable description of the action when the definition is " - "consumed by a system that might not be capable of interpreting it " - "dynamically." - ), - # if property is element of this resource. - element_property=True, - ) - textEquivalent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_textEquivalent", title="Extension field for ``textEquivalent``." - ) - - timingAge: fhirtypes.AgeType = Field( - None, - alias="timingAge", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingDateTime: fhirtypes.DateTime = Field( - None, - alias="timingDateTime", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - timingDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timingDateTime", title="Extension field for ``timingDateTime``." - ) - - timingDuration: fhirtypes.DurationType = Field( - None, - alias="timingDuration", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingPeriod: fhirtypes.PeriodType = Field( - None, - alias="timingPeriod", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingRange: fhirtypes.RangeType = Field( - None, - alias="timingRange", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - timingTiming: fhirtypes.TimingType = Field( - None, - alias="timingTiming", - title="When the action should take place", - description="An optional value describing when the action should be performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="User-visible title", - description="The title of the action displayed to a user.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="create | update | remove | fire-event", - description="The type of action to perform (create, update, remove).", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RequestGroupAction`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "prefix", - "title", - "description", - "textEquivalent", - "priority", - "code", - "documentation", - "condition", - "relatedAction", - "timingDateTime", - "timingAge", - "timingPeriod", - "timingDuration", - "timingRange", - "timingTiming", - "participant", - "type", - "groupingBehavior", - "selectionBehavior", - "requiredBehavior", - "precheckBehavior", - "cardinalityBehavior", - "resource", - "action", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2068( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "timing": [ - "timingAge", - "timingDateTime", - "timingDuration", - "timingPeriod", - "timingRange", - "timingTiming", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class RequestGroupActionCondition(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Whether or not the action is applicable. - An expression that describes applicability criteria, or start/stop - conditions for the action. - """ - - resource_type = Field("RequestGroupActionCondition", const=True) - - expression: fhirtypes.ExpressionType = Field( - None, - alias="expression", - title="Boolean-valued expression", - description=( - "An expression that returns true or false, indicating whether or not " - "the condition is satisfied." - ), - # if property is element of this resource. - element_property=True, - ) - - kind: fhirtypes.Code = Field( - None, - alias="kind", - title="applicability | start | stop", - description="The kind of condition.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["applicability", "start", "stop"], - ) - kind__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_kind", title="Extension field for ``kind``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RequestGroupActionCondition`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "kind", "expression"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3003( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("kind", "kind__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class RequestGroupActionRelatedAction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Relationship to another action. - A relationship to another action such as "before" or "30-60 minutes after - start of". - """ - - resource_type = Field("RequestGroupActionRelatedAction", const=True) - - actionId: fhirtypes.Id = Field( - None, - alias="actionId", - title="What action this is related to", - description="The element id of the action this is related to.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - actionId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_actionId", title="Extension field for ``actionId``." - ) - - offsetDuration: fhirtypes.DurationType = Field( - None, - alias="offsetDuration", - title="Time offset for the relationship", - description=( - "A duration or range of durations to apply to the relationship. For " - "example, 30-60 minutes before." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e offset[x] - one_of_many="offset", - one_of_many_required=False, - ) - - offsetRange: fhirtypes.RangeType = Field( - None, - alias="offsetRange", - title="Time offset for the relationship", - description=( - "A duration or range of durations to apply to the relationship. For " - "example, 30-60 minutes before." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e offset[x] - one_of_many="offset", - one_of_many_required=False, - ) - - relationship: fhirtypes.Code = Field( - None, - alias="relationship", - title=( - "before-start | before | before-end | concurrent-with-start | " - "concurrent | concurrent-with-end | after-start | after | after-end" - ), - description="The relationship of this action to the related action.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "before-start", - "before", - "before-end", - "concurrent-with-start", - "concurrent", - "concurrent-with-end", - "after-start", - "after", - "after-end", - ], - ) - relationship__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_relationship", title="Extension field for ``relationship``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RequestGroupActionRelatedAction`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "actionId", - "relationship", - "offsetDuration", - "offsetRange", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3379( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("actionId", "actionId__ext"), - ("relationship", "relationship__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3379( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"offset": ["offsetDuration", "offsetRange"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/researchdefinition.py b/fhir/resources/researchdefinition.py deleted file mode 100644 index 43d61c8b..00000000 --- a/fhir/resources/researchdefinition.py +++ /dev/null @@ -1,714 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ResearchDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class ResearchDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A research context or question. - The ResearchDefinition resource describes the conditional state (population - and any exposures being compared within the population) and outcome (if - specified) that the knowledge (evidence, assertion, recommendation) is - about. - """ - - resource_type = Field("ResearchDefinition", const=True) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the research definition was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - author: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="author", - title="Who authored the content", - description=( - "An individiual or organization primarily involved in the creation and " - "maintenance of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - comment: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="comment", - title="Used for footnotes or explanatory notes", - description=( - "A human-readable string to clarify or explain concepts about the " - "resource." - ), - # if property is element of this resource. - element_property=True, - ) - comment__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_comment", title="Extension field for ``comment``.") - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the research definition and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the research definition." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the research definition was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the research definition " - "changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the research definition", - description=( - "A free text natural language description of the research definition " - "from a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - editor: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="editor", - title="Who edited the content", - description=( - "An individual or organization primarily responsible for internal " - "coherence of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the research definition is expected to be used", - description=( - "The period during which the research definition content was or is " - "planned to be in active use." - ), - # if property is element of this resource. - element_property=True, - ) - - endorser: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="endorser", - title="Who endorsed the content", - description=( - "An individual or organization responsible for officially endorsing the" - " content for use in some setting." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this research definition is authored " - "for testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - exposure: fhirtypes.ReferenceType = Field( - None, - alias="exposure", - title="What exposure?", - description=( - "A reference to a ResearchElementDefinition resource that defines the " - "exposure for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ResearchElementDefinition"], - ) - - exposureAlternative: fhirtypes.ReferenceType = Field( - None, - alias="exposureAlternative", - title="What alternative exposure state?", - description=( - "A reference to a ResearchElementDefinition resource that defines the " - "exposureAlternative for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ResearchElementDefinition"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the research definition", - description=( - "A formal identifier that is used to identify this research definition " - "when it is represented in other formats, or referenced in a " - "specification, model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for research definition (if applicable)", - description=( - "A legal or geographic region in which the research definition is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the research definition was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - library: typing.List[fhirtypes.Canonical] = Field( - None, - alias="library", - title="Logic used by the ResearchDefinition", - description=( - "A reference to a Library resource containing the formal logic used by " - "the ResearchDefinition." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Library"], - ) - library__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_library", title="Extension field for ``library``.") - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this research definition (computer friendly)", - description=( - "A natural language name identifying the research definition. This name" - " should be usable as an identifier for the module by machine " - "processing applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - outcome: fhirtypes.ReferenceType = Field( - None, - alias="outcome", - title="What outcome?", - description=( - "A reference to a ResearchElementDefinition resomece that defines the " - "outcome for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ResearchElementDefinition"], - ) - - population: fhirtypes.ReferenceType = Field( - ..., - alias="population", - title="What population?", - description=( - "A reference to a ResearchElementDefinition resource that defines the " - "population for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ResearchElementDefinition"], - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the research" - " definition." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this research definition is defined", - description=( - "Explanation of why this research definition is needed and why it has " - "been designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="Additional documentation, citations, etc.", - description=( - "Related artifacts such as additional documentation, justification, or " - "bibliographic references." - ), - # if property is element of this resource. - element_property=True, - ) - - reviewer: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="reviewer", - title="Who reviewed the content", - description=( - "An individual or organization primarily responsible for review of some" - " aspect of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - shortTitle: fhirtypes.String = Field( - None, - alias="shortTitle", - title="Title for use in informal contexts", - description=( - "The short title provides an alternate title for use in informal " - "descriptive contexts where the full, formal title is not necessary." - ), - # if property is element of this resource. - element_property=True, - ) - shortTitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_shortTitle", title="Extension field for ``shortTitle``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this research definition. Enables tracking the life-" - "cycle of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subjectCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="subjectCodeableConcept", - title=( - "E.g. Patient, Practitioner, RelatedPerson, Organization, Location, " - "Device" - ), - description=( - "The intended subjects for the ResearchDefinition. If this element is " - "not provided, a Patient subject is assumed, but the subject of the " - "ResearchDefinition can be anything." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - ) - - subjectReference: fhirtypes.ReferenceType = Field( - None, - alias="subjectReference", - title=( - "E.g. Patient, Practitioner, RelatedPerson, Organization, Location, " - "Device" - ), - description=( - "The intended subjects for the ResearchDefinition. If this element is " - "not provided, a Patient subject is assumed, but the subject of the " - "ResearchDefinition can be anything." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Group"], - ) - - subtitle: fhirtypes.String = Field( - None, - alias="subtitle", - title="Subordinate title of the ResearchDefinition", - description=( - "An explanatory or alternate title for the ResearchDefinition giving " - "additional information about its content." - ), - # if property is element of this resource. - element_property=True, - ) - subtitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subtitle", title="Extension field for ``subtitle``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this research definition (human friendly)", - description="A short, descriptive, user-friendly title for the research definition.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="topic", - title=( - "The category of the ResearchDefinition, such as Education, Treatment, " - "Assessment, etc." - ), - description=( - "Descriptive topics related to the content of the ResearchDefinition. " - "Topics provide a high-level categorization grouping types of " - "ResearchDefinitions that can be useful for filtering and searching." - ), - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this research definition, represented as a " - "URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this research definition when" - " it is referenced in a specification, model, design or an instance; " - "also called its canonical identifier. This SHOULD be globally unique " - "and SHOULD be a literal address at which at which an authoritative " - "instance of this research definition is (or will be) published. This " - "URL can be the target of a canonical reference. It SHALL remain the " - "same when the research definition is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - usage: fhirtypes.String = Field( - None, - alias="usage", - title="Describes the clinical usage of the ResearchDefinition", - description=( - "A detailed description, from a clinical perspective, of how the " - "ResearchDefinition is used." - ), - # if property is element of this resource. - element_property=True, - ) - usage__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_usage", title="Extension field for ``usage``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate research definition instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the research definition", - description=( - "The identifier that is used to identify this version of the research " - "definition when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the research " - "definition author and is not expected to be globally unique. For " - "example, it might be a timestamp (e.g. yyyymmdd) if a managed version " - "is not available. There is also no expectation that versions can be " - "placed in a lexicographical sequence. To provide a version consistent " - "with the Decision Support Service specification, use the format " - "Major.Minor.Revision (e.g. 1.0.0). For more information on versioning " - "knowledge assets, refer to the Decision Support Service specification." - " Note that a version is required for non-experimental active " - "artifacts." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ResearchDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "shortTitle", - "subtitle", - "status", - "experimental", - "subjectCodeableConcept", - "subjectReference", - "date", - "publisher", - "contact", - "description", - "comment", - "useContext", - "jurisdiction", - "purpose", - "usage", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "topic", - "author", - "editor", - "reviewer", - "endorser", - "relatedArtifact", - "library", - "population", - "exposure", - "exposureAlternative", - "outcome", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2038( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2038( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"subject": ["subjectCodeableConcept", "subjectReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/researchelementdefinition.py b/fhir/resources/researchelementdefinition.py deleted file mode 100644 index c9ced0cc..00000000 --- a/fhir/resources/researchelementdefinition.py +++ /dev/null @@ -1,1137 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ResearchElementDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ResearchElementDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A population, intervention, or exposure definition. - The ResearchElementDefinition resource describes a "PICO" element that - knowledge (evidence, assertion, recommendation) is about. - """ - - resource_type = Field("ResearchElementDefinition", const=True) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the research element definition was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - author: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="author", - title="Who authored the content", - description=( - "An individiual or organization primarily involved in the creation and " - "maintenance of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - characteristic: typing.List[ - fhirtypes.ResearchElementDefinitionCharacteristicType - ] = Field( - ..., - alias="characteristic", - title="What defines the members of the research element", - description=( - "A characteristic that defines the members of the research element. " - 'Multiple characteristics are applied with "and" semantics.' - ), - # if property is element of this resource. - element_property=True, - ) - - comment: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="comment", - title="Used for footnotes or explanatory notes", - description=( - "A human-readable string to clarify or explain concepts about the " - "resource." - ), - # if property is element of this resource. - element_property=True, - ) - comment__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_comment", title="Extension field for ``comment``.") - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the research element definition " - "and/or its contents. Copyright statements are generally legal " - "restrictions on the use and publishing of the research element " - "definition." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the research element definition " - "was published. The date must change when the business version changes " - "and it must change if the status code changes. In addition, it should " - "change when the substantive content of the research element definition" - " changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the research element definition", - description=( - "A free text natural language description of the research element " - "definition from a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - editor: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="editor", - title="Who edited the content", - description=( - "An individual or organization primarily responsible for internal " - "coherence of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the research element definition is expected to be used", - description=( - "The period during which the research element definition content was or" - " is planned to be in active use." - ), - # if property is element of this resource. - element_property=True, - ) - - endorser: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="endorser", - title="Who endorsed the content", - description=( - "An individual or organization responsible for officially endorsing the" - " content for use in some setting." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this research element definition is " - "authored for testing purposes (or education/evaluation/marketing) and " - "is not intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the research element definition", - description=( - "A formal identifier that is used to identify this research element " - "definition when it is represented in other formats, or referenced in a" - " specification, model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for research element definition (if applicable)", - description=( - "A legal or geographic region in which the research element definition " - "is intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the research element definition was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - library: typing.List[fhirtypes.Canonical] = Field( - None, - alias="library", - title="Logic used by the ResearchElementDefinition", - description=( - "A reference to a Library resource containing the formal logic used by " - "the ResearchElementDefinition." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Library"], - ) - library__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_library", title="Extension field for ``library``.") - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this research element definition (computer friendly)", - description=( - "A natural language name identifying the research element definition. " - "This name should be usable as an identifier for the module by machine " - "processing applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the research" - " element definition." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this research element definition is defined", - description=( - "Explanation of why this research element definition is needed and why " - "it has been designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="Additional documentation, citations, etc.", - description=( - "Related artifacts such as additional documentation, justification, or " - "bibliographic references." - ), - # if property is element of this resource. - element_property=True, - ) - - reviewer: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="reviewer", - title="Who reviewed the content", - description=( - "An individual or organization primarily responsible for review of some" - " aspect of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - shortTitle: fhirtypes.String = Field( - None, - alias="shortTitle", - title="Title for use in informal contexts", - description=( - "The short title provides an alternate title for use in informal " - "descriptive contexts where the full, formal title is not necessary." - ), - # if property is element of this resource. - element_property=True, - ) - shortTitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_shortTitle", title="Extension field for ``shortTitle``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this research element definition. Enables tracking the " - "life-cycle of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subjectCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="subjectCodeableConcept", - title=( - "E.g. Patient, Practitioner, RelatedPerson, Organization, Location, " - "Device" - ), - description=( - "The intended subjects for the ResearchElementDefinition. If this " - "element is not provided, a Patient subject is assumed, but the subject" - " of the ResearchElementDefinition can be anything." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - ) - - subjectReference: fhirtypes.ReferenceType = Field( - None, - alias="subjectReference", - title=( - "E.g. Patient, Practitioner, RelatedPerson, Organization, Location, " - "Device" - ), - description=( - "The intended subjects for the ResearchElementDefinition. If this " - "element is not provided, a Patient subject is assumed, but the subject" - " of the ResearchElementDefinition can be anything." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e subject[x] - one_of_many="subject", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Group"], - ) - - subtitle: fhirtypes.String = Field( - None, - alias="subtitle", - title="Subordinate title of the ResearchElementDefinition", - description=( - "An explanatory or alternate title for the ResearchElementDefinition " - "giving additional information about its content." - ), - # if property is element of this resource. - element_property=True, - ) - subtitle__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subtitle", title="Extension field for ``subtitle``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this research element definition (human friendly)", - description=( - "A short, descriptive, user-friendly title for the research element " - "definition." - ), - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="topic", - title=( - "The category of the ResearchElementDefinition, such as Education, " - "Treatment, Assessment, etc." - ), - description=( - "Descriptive topics related to the content of the " - "ResearchElementDefinition. Topics provide a high-level categorization " - "grouping types of ResearchElementDefinitions that can be useful for " - "filtering and searching." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="population | exposure | outcome", - description=( - "The type of research element, a population, an exposure, or an " "outcome." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["population", "exposure", "outcome"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this research element definition, represented" - " as a URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this research element " - "definition when it is referenced in a specification, model, design or " - "an instance; also called its canonical identifier. This SHOULD be " - "globally unique and SHOULD be a literal address at which at which an " - "authoritative instance of this research element definition is (or will" - " be) published. This URL can be the target of a canonical reference. " - "It SHALL remain the same when the research element definition is " - "stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - usage: fhirtypes.String = Field( - None, - alias="usage", - title="Describes the clinical usage of the ResearchElementDefinition", - description=( - "A detailed description, from a clinical perspective, of how the " - "ResearchElementDefinition is used." - ), - # if property is element of this resource. - element_property=True, - ) - usage__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_usage", title="Extension field for ``usage``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate research element definition " - "instances." - ), - # if property is element of this resource. - element_property=True, - ) - - variableType: fhirtypes.Code = Field( - None, - alias="variableType", - title="dichotomous | continuous | descriptive", - description=( - "The type of the outcome (e.g. Dichotomous, Continuous, or " "Descriptive)." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["dichotomous", "continuous", "descriptive"], - ) - variableType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_variableType", title="Extension field for ``variableType``." - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the research element definition", - description=( - "The identifier that is used to identify this version of the research " - "element definition when it is referenced in a specification, model, " - "design or instance. This is an arbitrary value managed by the research" - " element definition author and is not expected to be globally unique. " - "For example, it might be a timestamp (e.g. yyyymmdd) if a managed " - "version is not available. There is also no expectation that versions " - "can be placed in a lexicographical sequence. To provide a version " - "consistent with the Decision Support Service specification, use the " - "format Major.Minor.Revision (e.g. 1.0.0). For more information on " - "versioning knowledge assets, refer to the Decision Support Service " - "specification. Note that a version is required for non-experimental " - "active artifacts." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ResearchElementDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "shortTitle", - "subtitle", - "status", - "experimental", - "subjectCodeableConcept", - "subjectReference", - "date", - "publisher", - "contact", - "description", - "comment", - "useContext", - "jurisdiction", - "purpose", - "usage", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "topic", - "author", - "editor", - "reviewer", - "endorser", - "relatedArtifact", - "library", - "type", - "variableType", - "characteristic", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2752( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2752( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"subject": ["subjectCodeableConcept", "subjectReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class ResearchElementDefinitionCharacteristic(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What defines the members of the research element. - A characteristic that defines the members of the research element. Multiple - characteristics are applied with "and" semantics. - """ - - resource_type = Field("ResearchElementDefinitionCharacteristic", const=True) - - definitionCanonical: fhirtypes.Canonical = Field( - None, - alias="definitionCanonical", - title="What code or expression defines members?", - description=( - "Define members of the research element using Codes (such as condition," - " medication, or observation), Expressions ( using an expression " - "language such as FHIRPath or CQL) or DataRequirements (such as " - "Diabetes diagnosis onset in the last year)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - definitionCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_definitionCanonical", - title="Extension field for ``definitionCanonical``.", - ) - - definitionCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="definitionCodeableConcept", - title="What code or expression defines members?", - description=( - "Define members of the research element using Codes (such as condition," - " medication, or observation), Expressions ( using an expression " - "language such as FHIRPath or CQL) or DataRequirements (such as " - "Diabetes diagnosis onset in the last year)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=True, - ) - - definitionDataRequirement: fhirtypes.DataRequirementType = Field( - None, - alias="definitionDataRequirement", - title="What code or expression defines members?", - description=( - "Define members of the research element using Codes (such as condition," - " medication, or observation), Expressions ( using an expression " - "language such as FHIRPath or CQL) or DataRequirements (such as " - "Diabetes diagnosis onset in the last year)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=True, - ) - - definitionExpression: fhirtypes.ExpressionType = Field( - None, - alias="definitionExpression", - title="What code or expression defines members?", - description=( - "Define members of the research element using Codes (such as condition," - " medication, or observation), Expressions ( using an expression " - "language such as FHIRPath or CQL) or DataRequirements (such as " - "Diabetes diagnosis onset in the last year)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definition[x] - one_of_many="definition", - one_of_many_required=True, - ) - - exclude: bool = Field( - None, - alias="exclude", - title="Whether the characteristic includes or excludes members", - description=( - "When true, members with this characteristic are excluded from the " - "element." - ), - # if property is element of this resource. - element_property=True, - ) - exclude__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_exclude", title="Extension field for ``exclude``." - ) - - participantEffectiveDateTime: fhirtypes.DateTime = Field( - None, - alias="participantEffectiveDateTime", - title="What time period do participants cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e participantEffective[x] - one_of_many="participantEffective", - one_of_many_required=False, - ) - participantEffectiveDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_participantEffectiveDateTime", - title="Extension field for ``participantEffectiveDateTime``.", - ) - - participantEffectiveDescription: fhirtypes.String = Field( - None, - alias="participantEffectiveDescription", - title="What time period do participants cover", - description="A narrative description of the time period the study covers.", - # if property is element of this resource. - element_property=True, - ) - participantEffectiveDescription__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_participantEffectiveDescription", - title="Extension field for ``participantEffectiveDescription``.", - ) - - participantEffectiveDuration: fhirtypes.DurationType = Field( - None, - alias="participantEffectiveDuration", - title="What time period do participants cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e participantEffective[x] - one_of_many="participantEffective", - one_of_many_required=False, - ) - - participantEffectiveGroupMeasure: fhirtypes.Code = Field( - None, - alias="participantEffectiveGroupMeasure", - title=( - "mean | median | mean-of-mean | mean-of-median | median-of-mean | " - "median-of-median" - ), - description=( - "Indicates how elements are aggregated within the study effective " - "period." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "mean", - "median", - "mean-of-mean", - "mean-of-median", - "median-of-mean", - "median-of-median", - ], - ) - participantEffectiveGroupMeasure__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_participantEffectiveGroupMeasure", - title="Extension field for ``participantEffectiveGroupMeasure``.", - ) - - participantEffectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="participantEffectivePeriod", - title="What time period do participants cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e participantEffective[x] - one_of_many="participantEffective", - one_of_many_required=False, - ) - - participantEffectiveTimeFromStart: fhirtypes.DurationType = Field( - None, - alias="participantEffectiveTimeFromStart", - title="Observation time from study start", - description="Indicates duration from the participant's study entry.", - # if property is element of this resource. - element_property=True, - ) - - participantEffectiveTiming: fhirtypes.TimingType = Field( - None, - alias="participantEffectiveTiming", - title="What time period do participants cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e participantEffective[x] - one_of_many="participantEffective", - one_of_many_required=False, - ) - - studyEffectiveDateTime: fhirtypes.DateTime = Field( - None, - alias="studyEffectiveDateTime", - title="What time period does the study cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e studyEffective[x] - one_of_many="studyEffective", - one_of_many_required=False, - ) - studyEffectiveDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_studyEffectiveDateTime", - title="Extension field for ``studyEffectiveDateTime``.", - ) - - studyEffectiveDescription: fhirtypes.String = Field( - None, - alias="studyEffectiveDescription", - title="What time period does the study cover", - description="A narrative description of the time period the study covers.", - # if property is element of this resource. - element_property=True, - ) - studyEffectiveDescription__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_studyEffectiveDescription", - title="Extension field for ``studyEffectiveDescription``.", - ) - - studyEffectiveDuration: fhirtypes.DurationType = Field( - None, - alias="studyEffectiveDuration", - title="What time period does the study cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e studyEffective[x] - one_of_many="studyEffective", - one_of_many_required=False, - ) - - studyEffectiveGroupMeasure: fhirtypes.Code = Field( - None, - alias="studyEffectiveGroupMeasure", - title=( - "mean | median | mean-of-mean | mean-of-median | median-of-mean | " - "median-of-median" - ), - description=( - "Indicates how elements are aggregated within the study effective " - "period." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "mean", - "median", - "mean-of-mean", - "mean-of-median", - "median-of-mean", - "median-of-median", - ], - ) - studyEffectiveGroupMeasure__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_studyEffectiveGroupMeasure", - title="Extension field for ``studyEffectiveGroupMeasure``.", - ) - - studyEffectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="studyEffectivePeriod", - title="What time period does the study cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e studyEffective[x] - one_of_many="studyEffective", - one_of_many_required=False, - ) - - studyEffectiveTimeFromStart: fhirtypes.DurationType = Field( - None, - alias="studyEffectiveTimeFromStart", - title="Observation time from study start", - description="Indicates duration from the study initiation.", - # if property is element of this resource. - element_property=True, - ) - - studyEffectiveTiming: fhirtypes.TimingType = Field( - None, - alias="studyEffectiveTiming", - title="What time period does the study cover", - description="Indicates what effective period the study covers.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e studyEffective[x] - one_of_many="studyEffective", - one_of_many_required=False, - ) - - unitOfMeasure: fhirtypes.CodeableConceptType = Field( - None, - alias="unitOfMeasure", - title="What unit is the outcome described in?", - description="Specifies the UCUM unit for the outcome.", - # if property is element of this resource. - element_property=True, - ) - - usageContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="usageContext", - title="What code/value pairs define members?", - description=( - "Use UsageContext to define the members of the population, such as Age " - "Ranges, Genders, Settings." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ResearchElementDefinitionCharacteristic`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "definitionCodeableConcept", - "definitionCanonical", - "definitionExpression", - "definitionDataRequirement", - "usageContext", - "exclude", - "unitOfMeasure", - "studyEffectiveDescription", - "studyEffectiveDateTime", - "studyEffectivePeriod", - "studyEffectiveDuration", - "studyEffectiveTiming", - "studyEffectiveTimeFromStart", - "studyEffectiveGroupMeasure", - "participantEffectiveDescription", - "participantEffectiveDateTime", - "participantEffectivePeriod", - "participantEffectiveDuration", - "participantEffectiveTiming", - "participantEffectiveTimeFromStart", - "participantEffectiveGroupMeasure", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4190( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "definition": [ - "definitionCanonical", - "definitionCodeableConcept", - "definitionDataRequirement", - "definitionExpression", - ], - "participantEffective": [ - "participantEffectiveDateTime", - "participantEffectiveDuration", - "participantEffectivePeriod", - "participantEffectiveTiming", - ], - "studyEffective": [ - "studyEffectiveDateTime", - "studyEffectiveDuration", - "studyEffectivePeriod", - "studyEffectiveTiming", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/researchstudy.py b/fhir/resources/researchstudy.py deleted file mode 100644 index 8124bccd..00000000 --- a/fhir/resources/researchstudy.py +++ /dev/null @@ -1,625 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ResearchStudy -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ResearchStudy(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Investigation to increase healthcare-related patient-independent knowledge. - A process where a researcher or organization plans and then executes a - series of steps intended to increase the field of healthcare-related - knowledge. This includes studies of safety, efficacy, comparative - effectiveness and other information about medications, devices, therapies - and other interventional and investigative techniques. A ResearchStudy - involves the gathering of information about human or animal subjects. - """ - - resource_type = Field("ResearchStudy", const=True) - - arm: typing.List[fhirtypes.ResearchStudyArmType] = Field( - None, - alias="arm", - title="Defined path through the study for a subject", - description=( - "Describes an expected sequence of events for one of the participants " - "of a study. E.g. Exposure to drug A, wash-out, exposure to drug B, " - "wash-out, follow-up." - ), - # if property is element of this resource. - element_property=True, - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Classifications for the study", - description=( - "Codes categorizing the type of study such as investigational vs. " - "observational, type of blinding, type of randomization, safety vs. " - "efficacy, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - condition: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="condition", - title="Condition being studied", - description=( - "The condition that is the focus of the study. For example, In a study" - " to examine risk factors for Lupus, might have as an inclusion " - 'criterion "healthy volunteer", but the target condition code would be ' - "a Lupus SNOMED code." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the study", - description=( - "Contact details to assist a user in learning more about or engaging " - "with the study." - ), - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="What this is study doing", - description="A full description of how the study is being conducted.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - enrollment: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="enrollment", - title="Inclusion & exclusion criteria", - description=( - "Reference to a Group that defines the criteria for and quantity of " - 'subjects participating in the study. E.g. " 200 female Europeans ' - 'between the ages of 20 and 45 with early onset diabetes".' - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Group"], - ) - - focus: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="focus", - title="Drugs, devices, etc. under study", - description=( - "The medication(s), food(s), therapy(ies), device(s) or other concerns " - "or interventions that the study is seeking to gain more information " - "about." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for study", - description=( - "Identifiers assigned to this research study by the sponsor or other " - "systems." - ), - # if property is element of this resource. - element_property=True, - ) - - keyword: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="keyword", - title="Used to search for the study", - description="Key terms to aid in searching for or filtering the study.", - # if property is element of this resource. - element_property=True, - ) - - location: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="location", - title="Geographic region(s) for study", - description=( - "Indicates a country, state or other region where the study is taking " - "place." - ), - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments made about the study", - description=( - "Comments made about the study by the performer, subject or other " - "participants." - ), - # if property is element of this resource. - element_property=True, - ) - - objective: typing.List[fhirtypes.ResearchStudyObjectiveType] = Field( - None, - alias="objective", - title="A goal for the study", - description=( - "A goal that the study is aiming to achieve in terms of a scientific " - "question to be answered by the analysis of data collected during the " - "study." - ), - # if property is element of this resource. - element_property=True, - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Part of larger study", - description=( - "A larger research study of which this particular study is a component " - "or step." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ResearchStudy"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="When the study began and ended", - description=( - "Identifies the start date and the expected (or actual, depending on " - "status) end date for the study." - ), - # if property is element of this resource. - element_property=True, - ) - - phase: fhirtypes.CodeableConceptType = Field( - None, - alias="phase", - title=( - "n-a | early-phase-1 | phase-1 | phase-1-phase-2 | phase-2 | " - "phase-2-phase-3 | phase-3 | phase-4" - ), - description=( - "The stage in the progression of a therapy from initial experimental " - "use in humans in clinical trials to post-market evaluation." - ), - # if property is element of this resource. - element_property=True, - ) - - primaryPurposeType: fhirtypes.CodeableConceptType = Field( - None, - alias="primaryPurposeType", - title=( - "treatment | prevention | diagnostic | supportive-care | screening | " - "health-services-research | basic-science | device-feasibility" - ), - description=( - "The type of study based upon the intent of the study's activities. A " - "classification of the intent of the study." - ), - # if property is element of this resource. - element_property=True, - ) - - principalInvestigator: fhirtypes.ReferenceType = Field( - None, - alias="principalInvestigator", - title="Researcher who oversees multiple aspects of the study", - description=( - "A researcher in a study who oversees multiple aspects of the study, " - "such as concept development, protocol writing, protocol submission for" - " IRB approval, participant recruitment, informed consent, data " - "collection, analysis, interpretation and presentation." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - protocol: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="protocol", - title="Steps followed in executing study", - description=( - "The set of steps expected to be performed as part of the execution of " - "the study." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["PlanDefinition"], - ) - - reasonStopped: fhirtypes.CodeableConceptType = Field( - None, - alias="reasonStopped", - title=( - "accrual-goal-met | closed-due-to-toxicity | closed-due-to-lack-of-" - "study-progress | temporarily-closed-per-study-design" - ), - description=( - "A description and/or code explaining the premature termination of the " - "study." - ), - # if property is element of this resource. - element_property=True, - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="References and dependencies", - description="Citations, references and other related documents.", - # if property is element of this resource. - element_property=True, - ) - - site: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="site", - title="Facility where study activities are conducted", - description="A facility in which study activities are conducted.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - sponsor: fhirtypes.ReferenceType = Field( - None, - alias="sponsor", - title="Organization that initiates and is legally responsible for the study", - description=( - "An organization that initiates the investigation and is legally " - "responsible for the study." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "active | administratively-completed | approved | closed-to-accrual | " - "closed-to-accrual-and-intervention | completed | disapproved | in-" - "review | temporarily-closed-to-accrual | temporarily-closed-to-" - "accrual-and-intervention | withdrawn" - ), - description="The current state of the study.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "active", - "administratively-completed", - "approved", - "closed-to-accrual", - "closed-to-accrual-and-intervention", - "completed", - "disapproved", - "in-review", - "temporarily-closed-to-accrual", - "temporarily-closed-to-accrual-and-intervention", - "withdrawn", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this study", - description="A short, descriptive user-friendly label for the study.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ResearchStudy`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "title", - "protocol", - "partOf", - "status", - "primaryPurposeType", - "phase", - "category", - "focus", - "condition", - "contact", - "relatedArtifact", - "keyword", - "location", - "description", - "enrollment", - "period", - "sponsor", - "principalInvestigator", - "site", - "reasonStopped", - "note", - "arm", - "objective", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1553( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ResearchStudyArm(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Defined path through the study for a subject. - Describes an expected sequence of events for one of the participants of a - study. E.g. Exposure to drug A, wash-out, exposure to drug B, wash-out, - follow-up. - """ - - resource_type = Field("ResearchStudyArm", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Short explanation of study path", - description=( - "A succinct description of the path through the study that would be " - "followed by a subject adhering to this arm." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Label for study arm", - description="Unique, human-readable label for this arm of the study.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Categorization of study arm", - description=( - "Categorization of study arm, e.g. experimental, active comparator, " - "placebo comparater." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ResearchStudyArm`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "name", "type", "description"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1829( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ResearchStudyObjective(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A goal for the study. - A goal that the study is aiming to achieve in terms of a scientific - question to be answered by the analysis of data collected during the study. - """ - - resource_type = Field("ResearchStudyObjective", const=True) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Label for the objective", - description="Unique, human-readable label for this objective of the study.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="primary | secondary | exploratory", - description="The kind of study objective.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ResearchStudyObjective`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "name", "type"] diff --git a/fhir/resources/researchsubject.py b/fhir/resources/researchsubject.py deleted file mode 100644 index 3ea957a0..00000000 --- a/fhir/resources/researchsubject.py +++ /dev/null @@ -1,232 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ResearchSubject -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class ResearchSubject(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Physical entity which is the primary unit of interest in the study. - A physical entity which is the primary unit of operational and/or - administrative interest in a study. - """ - - resource_type = Field("ResearchSubject", const=True) - - actualArm: fhirtypes.String = Field( - None, - alias="actualArm", - title="What path was followed", - description=( - "The name of the arm in the study the subject actually followed as part" - " of this study." - ), - # if property is element of this resource. - element_property=True, - ) - actualArm__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_actualArm", title="Extension field for ``actualArm``." - ) - - assignedArm: fhirtypes.String = Field( - None, - alias="assignedArm", - title="What path should be followed", - description=( - "The name of the arm in the study the subject is expected to follow as " - "part of this study." - ), - # if property is element of this resource. - element_property=True, - ) - assignedArm__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_assignedArm", title="Extension field for ``assignedArm``." - ) - - consent: fhirtypes.ReferenceType = Field( - None, - alias="consent", - title="Agreement to participate in study", - description=( - "A record of the patient's informed agreement to participate in the " - "study." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Consent"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for research subject in a study", - description="Identifiers assigned to this research subject for a study.", - # if property is element of this resource. - element_property=True, - ) - - individual: fhirtypes.ReferenceType = Field( - ..., - alias="individual", - title="Who is part of study", - description="The record of the person or animal who is involved in the study.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="Start and end of participation", - description=( - "The dates the subject began and ended their participation in the " "study." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "candidate | eligible | follow-up | ineligible | not-registered | off-" - "study | on-study | on-study-intervention | on-study-observation | " - "pending-on-study | potential-candidate | screening | withdrawn" - ), - description="The current state of the subject.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "candidate", - "eligible", - "follow-up", - "ineligible", - "not-registered", - "off-study", - "on-study", - "on-study-intervention", - "on-study-observation", - "pending-on-study", - "potential-candidate", - "screening", - "withdrawn", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - study: fhirtypes.ReferenceType = Field( - ..., - alias="study", - title="Study subject is part of", - description="Reference to the study the subject is participating in.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ResearchStudy"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ResearchSubject`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "period", - "study", - "individual", - "assignedArm", - "actualArm", - "consent", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1731( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/resource.py b/fhir/resources/resource.py deleted file mode 100644 index 35bfbb03..00000000 --- a/fhir/resources/resource.py +++ /dev/null @@ -1,85 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Resource -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic import Field - -from . import fhirresourcemodel, fhirtypes - - -class Resource(fhirresourcemodel.FHIRResourceModel): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Base Resource. - This is the base resource type for everything. - """ - - resource_type = Field("Resource", const=True) - - id: fhirtypes.Id = Field( - None, - alias="id", - title="Logical id of this artifact", - description=( - "The logical id of the resource, as used in the URL for the resource. " - "Once assigned, this value never changes." - ), - # if property is element of this resource. - element_property=True, - ) - - implicitRules: fhirtypes.Uri = Field( - None, - alias="implicitRules", - title="A set of rules under which this content was created", - description=( - "A reference to a set of rules that were followed when the resource was" - " constructed, and which must be understood when processing the " - "content. Often, this is a reference to an implementation guide that " - "defines the special rules along with other profiles etc." - ), - # if property is element of this resource. - element_property=True, - ) - implicitRules__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_implicitRules", title="Extension field for ``implicitRules``." - ) - - language: fhirtypes.Code = Field( - None, - alias="language", - title="Language of the resource content", - description="The base language in which the resource is written.", - # if property is element of this resource. - element_property=True, - ) - language__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_language", title="Extension field for ``language``." - ) - - meta: fhirtypes.MetaType = Field( - None, - alias="meta", - title="Metadata about the resource", - description=( - "The metadata about the resource. This is content that is maintained by" - " the infrastructure. Changes to the content might not always be " - "associated with version changes to the resource." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Resource`` according specification, - with preserving original sequence order. - """ - return ["id", "meta", "implicitRules", "language"] diff --git a/fhir/resources/riskassessment.py b/fhir/resources/riskassessment.py deleted file mode 100644 index 4d129cb4..00000000 --- a/fhir/resources/riskassessment.py +++ /dev/null @@ -1,564 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/RiskAssessment -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class RiskAssessment(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Potential outcomes for a subject with likelihood. - An assessment of the likely outcome(s) for a patient or other subject as - well as the likelihood of each outcome. - """ - - resource_type = Field("RiskAssessment", const=True) - - basedOn: fhirtypes.ReferenceType = Field( - None, - alias="basedOn", - title="Request fulfilled by this assessment", - description="A reference to the request that is fulfilled by this risk assessment.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - basis: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basis", - title="Information used in assessment", - description=( - "Indicates the source data considered as part of the assessment (for " - "example, FamilyHistory, Observations, Procedures, Conditions, etc.)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Type of assessment", - description="The type of the risk assessment performed.", - # if property is element of this resource. - element_property=True, - ) - - condition: fhirtypes.ReferenceType = Field( - None, - alias="condition", - title="Condition assessed", - description=( - "For assessments or prognosis specific to a particular condition, " - "indicates the condition being assessed." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Condition"], - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Where was assessment performed?", - description="The encounter where the assessment was performed.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Unique identifier for the assessment", - description="Business identifier assigned to the risk assessment.", - # if property is element of this resource. - element_property=True, - ) - - method: fhirtypes.CodeableConceptType = Field( - None, - alias="method", - title="Evaluation mechanism", - description="The algorithm, process or mechanism used to evaluate the risk.", - # if property is element of this resource. - element_property=True, - ) - - mitigation: fhirtypes.String = Field( - None, - alias="mitigation", - title="How to reduce risk", - description=( - "A description of the steps that might be taken to reduce the " - "identified risk(s)." - ), - # if property is element of this resource. - element_property=True, - ) - mitigation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mitigation", title="Extension field for ``mitigation``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments on the risk assessment", - description="Additional comments about the risk assessment.", - # if property is element of this resource. - element_property=True, - ) - - occurrenceDateTime: fhirtypes.DateTime = Field( - None, - alias="occurrenceDateTime", - title="When was assessment made?", - description="The date (and possibly time) the risk assessment was performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - occurrenceDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurrenceDateTime", - title="Extension field for ``occurrenceDateTime``.", - ) - - occurrencePeriod: fhirtypes.PeriodType = Field( - None, - alias="occurrencePeriod", - title="When was assessment made?", - description="The date (and possibly time) the risk assessment was performed.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - parent: fhirtypes.ReferenceType = Field( - None, - alias="parent", - title="Part of this occurrence", - description=( - "A reference to a resource that this risk assessment is part of, such " - "as a Procedure." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - performer: fhirtypes.ReferenceType = Field( - None, - alias="performer", - title="Who did assessment?", - description="The provider or software application that performed the assessment.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Device"], - ) - - prediction: typing.List[fhirtypes.RiskAssessmentPredictionType] = Field( - None, - alias="prediction", - title="Outcome predicted", - description="Describes the expected outcome for the subject.", - # if property is element of this resource. - element_property=True, - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Why the assessment was necessary?", - description="The reason the risk assessment was performed.", - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Why the assessment was necessary?", - description="Resources supporting the reason the risk assessment was performed.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "DiagnosticReport", - "DocumentReference", - ], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="registered | preliminary | final | amended +", - description=( - "The status of the RiskAssessment, using the same statuses as an " - "Observation." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["registered", "preliminary", "final", "amended", "+"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Who/what does assessment apply to?", - description="The patient or group the risk assessment applies to.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RiskAssessment`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "basedOn", - "parent", - "status", - "method", - "code", - "subject", - "encounter", - "occurrenceDateTime", - "occurrencePeriod", - "condition", - "performer", - "reasonCode", - "reasonReference", - "basis", - "prediction", - "mitigation", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1669( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1669( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"occurrence": ["occurrenceDateTime", "occurrencePeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class RiskAssessmentPrediction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Outcome predicted. - Describes the expected outcome for the subject. - """ - - resource_type = Field("RiskAssessmentPrediction", const=True) - - outcome: fhirtypes.CodeableConceptType = Field( - None, - alias="outcome", - title="Possible outcome for the subject", - description=( - "One of the potential outcomes for the patient (e.g. remission, death," - " a particular condition)." - ), - # if property is element of this resource. - element_property=True, - ) - - probabilityDecimal: fhirtypes.Decimal = Field( - None, - alias="probabilityDecimal", - title="Likelihood of specified outcome", - description="Indicates how likely the outcome is (in the specified timeframe).", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e probability[x] - one_of_many="probability", - one_of_many_required=False, - ) - probabilityDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_probabilityDecimal", - title="Extension field for ``probabilityDecimal``.", - ) - - probabilityRange: fhirtypes.RangeType = Field( - None, - alias="probabilityRange", - title="Likelihood of specified outcome", - description="Indicates how likely the outcome is (in the specified timeframe).", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e probability[x] - one_of_many="probability", - one_of_many_required=False, - ) - - qualitativeRisk: fhirtypes.CodeableConceptType = Field( - None, - alias="qualitativeRisk", - title="Likelihood of specified outcome as a qualitative value", - description=( - "Indicates how likely the outcome is (in the specified timeframe), " - "expressed as a qualitative value (e.g. low, medium, or high)." - ), - # if property is element of this resource. - element_property=True, - ) - - rationale: fhirtypes.String = Field( - None, - alias="rationale", - title="Explanation of prediction", - description="Additional information explaining the basis for the prediction.", - # if property is element of this resource. - element_property=True, - ) - rationale__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_rationale", title="Extension field for ``rationale``." - ) - - relativeRisk: fhirtypes.Decimal = Field( - None, - alias="relativeRisk", - title="Relative likelihood", - description=( - "Indicates the risk for this particular subject (with their specific " - "characteristics) divided by the risk of the population in general. " - "(Numbers greater than 1 = higher risk than the population, numbers " - "less than 1 = lower risk.)." - ), - # if property is element of this resource. - element_property=True, - ) - relativeRisk__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_relativeRisk", title="Extension field for ``relativeRisk``." - ) - - whenPeriod: fhirtypes.PeriodType = Field( - None, - alias="whenPeriod", - title="Timeframe or age range", - description=( - "Indicates the period of time or age range of the subject to which the " - "specified probability applies." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e when[x] - one_of_many="when", - one_of_many_required=False, - ) - - whenRange: fhirtypes.RangeType = Field( - None, - alias="whenRange", - title="Timeframe or age range", - description=( - "Indicates the period of time or age range of the subject to which the " - "specified probability applies." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e when[x] - one_of_many="when", - one_of_many_required=False, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RiskAssessmentPrediction`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "outcome", - "probabilityDecimal", - "probabilityRange", - "qualitativeRisk", - "relativeRisk", - "whenPeriod", - "whenRange", - "rationale", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2704( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "probability": ["probabilityDecimal", "probabilityRange"], - "when": ["whenPeriod", "whenRange"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/riskevidencesynthesis.py b/fhir/resources/riskevidencesynthesis.py deleted file mode 100644 index ee7dbcb0..00000000 --- a/fhir/resources/riskevidencesynthesis.py +++ /dev/null @@ -1,926 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/RiskEvidenceSynthesis -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class RiskEvidenceSynthesis(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A quantified estimate of risk based on a body of evidence. - The RiskEvidenceSynthesis resource describes the likelihood of an outcome - in a population plus exposure state where the risk estimate is derived from - a combination of research studies. - """ - - resource_type = Field("RiskEvidenceSynthesis", const=True) - - approvalDate: fhirtypes.Date = Field( - None, - alias="approvalDate", - title="When the risk evidence synthesis was approved by publisher", - description=( - "The date on which the resource content was approved by the publisher. " - "Approval happens once when the content is officially approved for " - "usage." - ), - # if property is element of this resource. - element_property=True, - ) - approvalDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_approvalDate", title="Extension field for ``approvalDate``." - ) - - author: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="author", - title="Who authored the content", - description=( - "An individiual or organization primarily involved in the creation and " - "maintenance of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - certainty: typing.List[fhirtypes.RiskEvidenceSynthesisCertaintyType] = Field( - None, - alias="certainty", - title="How certain is the risk", - description="A description of the certainty of the risk estimate.", - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the risk evidence synthesis and/or " - "its contents. Copyright statements are generally legal restrictions on" - " the use and publishing of the risk evidence synthesis." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the risk evidence synthesis was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the risk evidence synthesis " - "changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the risk evidence synthesis", - description=( - "A free text natural language description of the risk evidence " - "synthesis from a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - editor: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="editor", - title="Who edited the content", - description=( - "An individual or organization primarily responsible for internal " - "coherence of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - effectivePeriod: fhirtypes.PeriodType = Field( - None, - alias="effectivePeriod", - title="When the risk evidence synthesis is expected to be used", - description=( - "The period during which the risk evidence synthesis content was or is " - "planned to be in active use." - ), - # if property is element of this resource. - element_property=True, - ) - - endorser: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="endorser", - title="Who endorsed the content", - description=( - "An individual or organization responsible for officially endorsing the" - " content for use in some setting." - ), - # if property is element of this resource. - element_property=True, - ) - - exposure: fhirtypes.ReferenceType = Field( - None, - alias="exposure", - title="What exposure?", - description=( - "A reference to a EvidenceVariable resource that defines the exposure " - "for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EvidenceVariable"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the risk evidence synthesis", - description=( - "A formal identifier that is used to identify this risk evidence " - "synthesis when it is represented in other formats, or referenced in a " - "specification, model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for risk evidence synthesis (if applicable)", - description=( - "A legal or geographic region in which the risk evidence synthesis is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - lastReviewDate: fhirtypes.Date = Field( - None, - alias="lastReviewDate", - title="When the risk evidence synthesis was last reviewed", - description=( - "The date on which the resource content was last reviewed. Review " - "happens periodically after approval but does not change the original " - "approval date." - ), - # if property is element of this resource. - element_property=True, - ) - lastReviewDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastReviewDate", title="Extension field for ``lastReviewDate``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this risk evidence synthesis (computer friendly)", - description=( - "A natural language name identifying the risk evidence synthesis. This " - "name should be usable as an identifier for the module by machine " - "processing applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Used for footnotes or explanatory notes", - description=( - "A human-readable string to clarify or explain concepts about the " - "resource." - ), - # if property is element of this resource. - element_property=True, - ) - - outcome: fhirtypes.ReferenceType = Field( - ..., - alias="outcome", - title="What outcome?", - description=( - "A reference to a EvidenceVariable resomece that defines the outcome " - "for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EvidenceVariable"], - ) - - population: fhirtypes.ReferenceType = Field( - ..., - alias="population", - title="What population?", - description=( - "A reference to a EvidenceVariable resource that defines the population" - " for the research." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["EvidenceVariable"], - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the risk " - "evidence synthesis." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - relatedArtifact: typing.List[fhirtypes.RelatedArtifactType] = Field( - None, - alias="relatedArtifact", - title="Additional documentation, citations, etc.", - description=( - "Related artifacts such as additional documentation, justification, or " - "bibliographic references." - ), - # if property is element of this resource. - element_property=True, - ) - - reviewer: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="reviewer", - title="Who reviewed the content", - description=( - "An individual or organization primarily responsible for review of some" - " aspect of the content." - ), - # if property is element of this resource. - element_property=True, - ) - - riskEstimate: fhirtypes.RiskEvidenceSynthesisRiskEstimateType = Field( - None, - alias="riskEstimate", - title="What was the estimated risk", - description="The estimated risk of the outcome.", - # if property is element of this resource. - element_property=True, - ) - - sampleSize: fhirtypes.RiskEvidenceSynthesisSampleSizeType = Field( - None, - alias="sampleSize", - title="What sample size was involved?", - description="A description of the size of the sample involved in the synthesis.", - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this risk evidence synthesis. Enables tracking the life-" - "cycle of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - studyType: fhirtypes.CodeableConceptType = Field( - None, - alias="studyType", - title="Type of study", - description="Type of study eg randomized trial.", - # if property is element of this resource. - element_property=True, - ) - - synthesisType: fhirtypes.CodeableConceptType = Field( - None, - alias="synthesisType", - title="Type of synthesis", - description="Type of synthesis eg meta-analysis.", - # if property is element of this resource. - element_property=True, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this risk evidence synthesis (human friendly)", - description=( - "A short, descriptive, user-friendly title for the risk evidence " - "synthesis." - ), - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - topic: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="topic", - title=( - "The category of the EffectEvidenceSynthesis, such as Education, " - "Treatment, Assessment, etc." - ), - description=( - "Descriptive topics related to the content of the " - "RiskEvidenceSynthesis. Topics provide a high-level categorization " - "grouping types of EffectEvidenceSynthesiss that can be useful for " - "filtering and searching." - ), - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this risk evidence synthesis, represented as " - "a URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this risk evidence synthesis " - "when it is referenced in a specification, model, design or an " - "instance; also called its canonical identifier. This SHOULD be " - "globally unique and SHOULD be a literal address at which at which an " - "authoritative instance of this risk evidence synthesis is (or will be)" - " published. This URL can be the target of a canonical reference. It " - "SHALL remain the same when the risk evidence synthesis is stored on " - "different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate risk evidence synthesis " - "instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the risk evidence synthesis", - description=( - "The identifier that is used to identify this version of the risk " - "evidence synthesis when it is referenced in a specification, model, " - "design or instance. This is an arbitrary value managed by the risk " - "evidence synthesis author and is not expected to be globally unique. " - "For example, it might be a timestamp (e.g. yyyymmdd) if a managed " - "version is not available. There is also no expectation that versions " - "can be placed in a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RiskEvidenceSynthesis`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "status", - "date", - "publisher", - "contact", - "description", - "note", - "useContext", - "jurisdiction", - "copyright", - "approvalDate", - "lastReviewDate", - "effectivePeriod", - "topic", - "author", - "editor", - "reviewer", - "endorser", - "relatedArtifact", - "synthesisType", - "studyType", - "population", - "exposure", - "outcome", - "sampleSize", - "riskEstimate", - "certainty", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2379( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class RiskEvidenceSynthesisCertainty(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - How certain is the risk. - A description of the certainty of the risk estimate. - """ - - resource_type = Field("RiskEvidenceSynthesisCertainty", const=True) - - certaintySubcomponent: typing.List[ - fhirtypes.RiskEvidenceSynthesisCertaintyCertaintySubcomponentType - ] = Field( - None, - alias="certaintySubcomponent", - title="A component that contributes to the overall certainty", - description="A description of a component of the overall certainty.", - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Used for footnotes or explanatory notes", - description=( - "A human-readable string to clarify or explain concepts about the " - "resource." - ), - # if property is element of this resource. - element_property=True, - ) - - rating: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="rating", - title="Certainty rating", - description="A rating of the certainty of the effect estimate.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RiskEvidenceSynthesisCertainty`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "rating", - "note", - "certaintySubcomponent", - ] - - -class RiskEvidenceSynthesisCertaintyCertaintySubcomponent( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A component that contributes to the overall certainty. - A description of a component of the overall certainty. - """ - - resource_type = Field( - "RiskEvidenceSynthesisCertaintyCertaintySubcomponent", const=True - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Used for footnotes or explanatory notes", - description=( - "A human-readable string to clarify or explain concepts about the " - "resource." - ), - # if property is element of this resource. - element_property=True, - ) - - rating: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="rating", - title="Subcomponent certainty rating", - description="A rating of a subcomponent of rating certainty.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of subcomponent of certainty rating", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RiskEvidenceSynthesisCertaintyCertaintySubcomponent`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "rating", "note"] - - -class RiskEvidenceSynthesisRiskEstimate(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What was the estimated risk. - The estimated risk of the outcome. - """ - - resource_type = Field("RiskEvidenceSynthesisRiskEstimate", const=True) - - denominatorCount: fhirtypes.Integer = Field( - None, - alias="denominatorCount", - title="Sample size for group measured", - description=( - "The sample size for the group that was measured for this risk " "estimate." - ), - # if property is element of this resource. - element_property=True, - ) - denominatorCount__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_denominatorCount", - title="Extension field for ``denominatorCount``.", - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Description of risk estimate", - description="Human-readable summary of risk estimate.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - numeratorCount: fhirtypes.Integer = Field( - None, - alias="numeratorCount", - title="Number with the outcome", - description="The number of group members with the outcome of interest.", - # if property is element of this resource. - element_property=True, - ) - numeratorCount__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_numeratorCount", title="Extension field for ``numeratorCount``." - ) - - precisionEstimate: typing.List[ - fhirtypes.RiskEvidenceSynthesisRiskEstimatePrecisionEstimateType - ] = Field( - None, - alias="precisionEstimate", - title="How precise the estimate is", - description="A description of the precision of the estimate for the effect.", - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of risk estimate", - description="Examples include proportion and mean.", - # if property is element of this resource. - element_property=True, - ) - - unitOfMeasure: fhirtypes.CodeableConceptType = Field( - None, - alias="unitOfMeasure", - title="What unit is the outcome described in?", - description="Specifies the UCUM unit for the outcome.", - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.Decimal = Field( - None, - alias="value", - title="Point estimate", - description="The point estimate of the risk estimate.", - # if property is element of this resource. - element_property=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RiskEvidenceSynthesisRiskEstimate`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "type", - "value", - "unitOfMeasure", - "denominatorCount", - "numeratorCount", - "precisionEstimate", - ] - - -class RiskEvidenceSynthesisRiskEstimatePrecisionEstimate( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - How precise the estimate is. - A description of the precision of the estimate for the effect. - """ - - resource_type = Field( - "RiskEvidenceSynthesisRiskEstimatePrecisionEstimate", const=True - ) - - from_fhir: fhirtypes.Decimal = Field( - None, - alias="from", - title="Lower bound", - description="Lower bound of confidence interval.", - # if property is element of this resource. - element_property=True, - ) - from__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_from", title="Extension field for ``from_fhir``." - ) - - level: fhirtypes.Decimal = Field( - None, - alias="level", - title="Level of confidence interval", - description="Use 95 for a 95% confidence interval.", - # if property is element of this resource. - element_property=True, - ) - level__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_level", title="Extension field for ``level``." - ) - - to: fhirtypes.Decimal = Field( - None, - alias="to", - title="Upper bound", - description="Upper bound of confidence interval.", - # if property is element of this resource. - element_property=True, - ) - to__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_to", title="Extension field for ``to``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of precision estimate", - description="Examples include confidence interval and interquartile range.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RiskEvidenceSynthesisRiskEstimatePrecisionEstimate`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "level", "from", "to"] - - -class RiskEvidenceSynthesisSampleSize(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - What sample size was involved?. - A description of the size of the sample involved in the synthesis. - """ - - resource_type = Field("RiskEvidenceSynthesisSampleSize", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Description of sample size", - description="Human-readable summary of sample size.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - numberOfParticipants: fhirtypes.Integer = Field( - None, - alias="numberOfParticipants", - title="How many participants?", - description="Number of participants included in this evidence synthesis.", - # if property is element of this resource. - element_property=True, - ) - numberOfParticipants__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_numberOfParticipants", - title="Extension field for ``numberOfParticipants``.", - ) - - numberOfStudies: fhirtypes.Integer = Field( - None, - alias="numberOfStudies", - title="How many studies?", - description="Number of studies included in this evidence synthesis.", - # if property is element of this resource. - element_property=True, - ) - numberOfStudies__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_numberOfStudies", title="Extension field for ``numberOfStudies``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``RiskEvidenceSynthesisSampleSize`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "numberOfStudies", - "numberOfParticipants", - ] diff --git a/fhir/resources/sampleddata.py b/fhir/resources/sampleddata.py deleted file mode 100644 index 5570bf19..00000000 --- a/fhir/resources/sampleddata.py +++ /dev/null @@ -1,211 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SampledData -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import element, fhirtypes - - -class SampledData(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A series of measurements taken by a device. - A series of measurements taken by a device, with upper and lower limits. - There may be more than one dimension in the data. - """ - - resource_type = Field("SampledData", const=True) - - data: fhirtypes.String = Field( - None, - alias="data", - title='Decimal values with spaces, or "E" | "U" | "L"', - description=( - "A series of data points which are decimal values separated by a single" - ' space (character u20). The special values "E" (error), "L" (below ' - 'detection limit) and "U" (above detection limit) can also be used in ' - "place of a decimal value." - ), - # if property is element of this resource. - element_property=True, - ) - data__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_data", title="Extension field for ``data``." - ) - - dimensions: fhirtypes.PositiveInt = Field( - None, - alias="dimensions", - title="Number of sample points at each time point", - description=( - "The number of sample points at each time point. If this value is " - "greater than one, then the dimensions will be interlaced - all the " - "sample points for a point in time will be recorded at once." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - dimensions__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_dimensions", title="Extension field for ``dimensions``." - ) - - factor: fhirtypes.Decimal = Field( - None, - alias="factor", - title="Multiply data by this before adding to origin", - description=( - "A correction factor that is applied to the sampled data points before " - "they are added to the origin." - ), - # if property is element of this resource. - element_property=True, - ) - factor__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_factor", title="Extension field for ``factor``." - ) - - lowerLimit: fhirtypes.Decimal = Field( - None, - alias="lowerLimit", - title="Lower limit of detection", - description=( - "The lower limit of detection of the measured points. This is needed if" - ' any of the data points have the value "L" (lower than detection ' - "limit)." - ), - # if property is element of this resource. - element_property=True, - ) - lowerLimit__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lowerLimit", title="Extension field for ``lowerLimit``." - ) - - origin: fhirtypes.QuantityType = Field( - ..., - alias="origin", - title="Zero value and units", - description=( - "The base quantity that a measured value of zero represents. In " - "addition, this provides the units of the entire measurement series." - ), - # if property is element of this resource. - element_property=True, - ) - - period: fhirtypes.Decimal = Field( - None, - alias="period", - title="Number of milliseconds between samples", - description="The length of time between sampling times, measured in milliseconds.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - period__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_period", title="Extension field for ``period``." - ) - - upperLimit: fhirtypes.Decimal = Field( - None, - alias="upperLimit", - title="Upper limit of detection", - description=( - "The upper limit of detection of the measured points. This is needed if" - ' any of the data points have the value "U" (higher than detection ' - "limit)." - ), - # if property is element of this resource. - element_property=True, - ) - upperLimit__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_upperLimit", title="Extension field for ``upperLimit``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SampledData`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "origin", - "period", - "factor", - "lowerLimit", - "upperLimit", - "dimensions", - "data", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1268( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("dimensions", "dimensions__ext"), ("period", "period__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/schedule.py b/fhir/resources/schedule.py deleted file mode 100644 index 84fad556..00000000 --- a/fhir/resources/schedule.py +++ /dev/null @@ -1,159 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Schedule -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import domainresource, fhirtypes - - -class Schedule(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A container for slots of time that may be available for booking - appointments. - """ - - resource_type = Field("Schedule", const=True) - - active: bool = Field( - None, - alias="active", - title="Whether this schedule is in active use", - description=( - "Whether this schedule record is in active use or should not be used " - "(such as was entered in error)." - ), - # if property is element of this resource. - element_property=True, - ) - active__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_active", title="Extension field for ``active``." - ) - - actor: typing.List[fhirtypes.ReferenceType] = Field( - ..., - alias="actor", - title="Resource(s) that availability information is being provided for", - description=( - "Slots that reference this schedule resource provide the availability " - "details to these referenced resource(s)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Device", - "HealthcareService", - "Location", - ], - ) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Comments on availability", - description=( - "Comments on the availability to describe any extended information. " - "Such as custom constraints on the slots that may be associated." - ), - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Ids for this item", - description=None, - # if property is element of this resource. - element_property=True, - ) - - planningHorizon: fhirtypes.PeriodType = Field( - None, - alias="planningHorizon", - title="Period of time covered by schedule", - description=( - "The period of time that the slots that reference this Schedule " - "resource cover (even if none exist). These cover the amount of time " - "that an organization's planning horizon; the interval for which they " - "are currently accepting appointments. This does not define a " - '"template" for planning outside these dates.' - ), - # if property is element of this resource. - element_property=True, - ) - - serviceCategory: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="serviceCategory", - title="High-level category", - description=( - "A broad categorization of the service that is to be performed during " - "this appointment." - ), - # if property is element of this resource. - element_property=True, - ) - - serviceType: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="serviceType", - title="Specific service", - description="The specific service that is to be performed during this appointment.", - # if property is element of this resource. - element_property=True, - ) - - specialty: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="specialty", - title="Type of specialty needed", - description=( - "The specialty of a practitioner that would be required to perform the " - "service requested in this appointment." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Schedule`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "active", - "serviceCategory", - "serviceType", - "specialty", - "actor", - "planningHorizon", - "comment", - ] diff --git a/fhir/resources/searchparameter.py b/fhir/resources/searchparameter.py deleted file mode 100644 index 741b0c07..00000000 --- a/fhir/resources/searchparameter.py +++ /dev/null @@ -1,696 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SearchParameter -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class SearchParameter(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Search parameter for a resource. - A search parameter that defines a named search item that can be used to - search/filter on a resource. - """ - - resource_type = Field("SearchParameter", const=True) - - base: typing.List[fhirtypes.Code] = Field( - None, - alias="base", - title="The resource type(s) this search parameter applies to", - description=( - "The base resource type(s) that this search parameter can be used " - "against." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - base__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_base", title="Extension field for ``base``.") - - chain: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="chain", - title="Chained names supported", - description=( - "Contains the names of any search parameters which may be chained to " - "the containing search parameter. Chained parameters may be added to " - "search parameters of type reference and specify that resources will " - "only be returned if they contain a reference to a resource which " - "matches the chained parameter value. Values for this field should be " - "drawn from SearchParameter.code for a parameter on the target resource" - " type." - ), - # if property is element of this resource. - element_property=True, - ) - chain__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_chain", title="Extension field for ``chain``.") - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Code used in URL", - description=( - "The code used in the URL or the parameter name in a parameters " - "resource for this search parameter." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - comparator: typing.List[fhirtypes.Code] = Field( - None, - alias="comparator", - title="eq | ne | gt | lt | ge | le | sa | eb | ap", - description="Comparators supported for the search parameter.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["eq", "ne", "gt", "lt", "ge", "le", "sa", "eb", "ap"], - ) - comparator__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_comparator", title="Extension field for ``comparator``.") - - component: typing.List[fhirtypes.SearchParameterComponentType] = Field( - None, - alias="component", - title="For Composite resources to define the parts", - description="Used to define the parts of a composite search parameter.", - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the search parameter was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the search parameter changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - derivedFrom: fhirtypes.Canonical = Field( - None, - alias="derivedFrom", - title="Original definition for the search parameter", - description=( - "Where this search parameter is originally defined. If a derivedFrom is" - " provided, then the details in the search parameter must be consistent" - " with the definition from which it is defined. i.e. the parameter " - "should have the same meaning, and (usually) the functionality should " - "be a proper subset of the underlying search parameter." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SearchParameter"], - ) - derivedFrom__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_derivedFrom", title="Extension field for ``derivedFrom``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the search parameter", - description="And how it used.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this search parameter is authored for" - " testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - expression: fhirtypes.String = Field( - None, - alias="expression", - title="FHIRPath expression that extracts the values", - description=( - "A FHIRPath expression that returns a set of elements for the search " - "parameter." - ), - # if property is element of this resource. - element_property=True, - ) - expression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expression", title="Extension field for ``expression``." - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for search parameter (if applicable)", - description=( - "A legal or geographic region in which the search parameter is intended" - " to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - modifier: typing.List[fhirtypes.Code] = Field( - None, - alias="modifier", - title=( - "missing | exact | contains | not | text | in | not-in | below | above " - "| type | identifier | ofType" - ), - description="A modifier supported for the search parameter.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "missing", - "exact", - "contains", - "not", - "text", - "in", - "not-in", - "below", - "above", - "type", - "identifier", - "ofType", - ], - ) - modifier__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_modifier", title="Extension field for ``modifier``.") - - multipleAnd: bool = Field( - None, - alias="multipleAnd", - title="Allow multiple parameters (and)", - description=( - "Whether multiple parameters are allowed - e.g. more than one parameter" - " with the same name. The search matches if all the parameters match." - ), - # if property is element of this resource. - element_property=True, - ) - multipleAnd__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_multipleAnd", title="Extension field for ``multipleAnd``." - ) - - multipleOr: bool = Field( - None, - alias="multipleOr", - title="Allow multiple values per parameter (or)", - description=( - "Whether multiple values are allowed for each time the parameter " - "exists. Values are separated by commas, and the parameter matches if " - "any of the values match." - ), - # if property is element of this resource. - element_property=True, - ) - multipleOr__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_multipleOr", title="Extension field for ``multipleOr``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this search parameter (computer friendly)", - description=( - "A natural language name identifying the search parameter. This name " - "should be usable as an identifier for the module by machine processing" - " applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the search " - "parameter." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this search parameter is defined", - description=( - "Explanation of why this search parameter is needed and why it has been" - " designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this search parameter. Enables tracking the life-cycle " - "of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - target: typing.List[fhirtypes.Code] = Field( - None, - alias="target", - title="Types of resource (if a resource reference)", - description="Types of resource (if a resource is referenced).", - # if property is element of this resource. - element_property=True, - ) - target__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_target", title="Extension field for ``target``.") - - type: fhirtypes.Code = Field( - None, - alias="type", - title=( - "number | date | string | token | reference | composite | quantity | " - "uri | special" - ), - description=( - "The type of value that a search parameter may contain, and how the " - "content is interpreted." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "number", - "date", - "string", - "token", - "reference", - "composite", - "quantity", - "uri", - "special", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this search parameter, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this search parameter when it" - " is referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this search parameter is (or will be) published. This URL " - "can be the target of a canonical reference. It SHALL remain the same " - "when the search parameter is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate search parameter instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the search parameter", - description=( - "The identifier that is used to identify this version of the search " - "parameter when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the search parameter " - "author and is not expected to be globally unique. For example, it " - "might be a timestamp (e.g. yyyymmdd) if a managed version is not " - "available. There is also no expectation that versions can be placed in" - " a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - xpath: fhirtypes.String = Field( - None, - alias="xpath", - title="XPath that extracts the values", - description=( - "An XPath expression that returns a set of elements for the search " - "parameter." - ), - # if property is element of this resource. - element_property=True, - ) - xpath__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_xpath", title="Extension field for ``xpath``." - ) - - xpathUsage: fhirtypes.Code = Field( - None, - alias="xpathUsage", - title="normal | phonetic | nearby | distance | other", - description=( - "How the search parameter relates to the set of elements returned by " - "evaluating the xpath query." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["normal", "phonetic", "nearby", "distance", "other"], - ) - xpathUsage__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_xpathUsage", title="Extension field for ``xpathUsage``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SearchParameter`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "version", - "name", - "derivedFrom", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "code", - "base", - "type", - "expression", - "xpath", - "xpathUsage", - "target", - "multipleOr", - "multipleAnd", - "comparator", - "modifier", - "chain", - "component", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1724( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("base", "base__ext"), - ("code", "code__ext"), - ("description", "description__ext"), - ("name", "name__ext"), - ("status", "status__ext"), - ("type", "type__ext"), - ("url", "url__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class SearchParameterComponent(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - For Composite resources to define the parts. - Used to define the parts of a composite search parameter. - """ - - resource_type = Field("SearchParameterComponent", const=True) - - definition: fhirtypes.Canonical = Field( - None, - alias="definition", - title="Defines how the part works", - description="The definition of the search parameter that describes this part.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SearchParameter"], - ) - definition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_definition", title="Extension field for ``definition``." - ) - - expression: fhirtypes.String = Field( - None, - alias="expression", - title="Subexpression relative to main expression", - description=( - "A sub-expression that defines how to extract values for this component" - " from the output of the main SearchParameter.expression." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - expression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expression", title="Extension field for ``expression``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SearchParameterComponent`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "definition", "expression"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2673( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("definition", "definition__ext"), - ("expression", "expression__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/servicerequest.py b/fhir/resources/servicerequest.py deleted file mode 100644 index 8f23124f..00000000 --- a/fhir/resources/servicerequest.py +++ /dev/null @@ -1,782 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ServiceRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class ServiceRequest(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A request for a service to be performed. - A record of a request for service such as diagnostic investigations, - treatments, or operations to be performed. - """ - - resource_type = Field("ServiceRequest", const=True) - - asNeededBoolean: bool = Field( - None, - alias="asNeededBoolean", - title="Preconditions for service", - description=( - "If a CodeableConcept is present, it indicates the pre-condition for " - 'performing the service. For example "pain", "on flare-up", etc.' - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e asNeeded[x] - one_of_many="asNeeded", - one_of_many_required=False, - ) - asNeededBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_asNeededBoolean", title="Extension field for ``asNeededBoolean``." - ) - - asNeededCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="asNeededCodeableConcept", - title="Preconditions for service", - description=( - "If a CodeableConcept is present, it indicates the pre-condition for " - 'performing the service. For example "pain", "on flare-up", etc.' - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e asNeeded[x] - one_of_many="asNeeded", - one_of_many_required=False, - ) - - authoredOn: fhirtypes.DateTime = Field( - None, - alias="authoredOn", - title="Date request signed", - description="When the request transitioned to being actionable.", - # if property is element of this resource. - element_property=True, - ) - authoredOn__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_authoredOn", title="Extension field for ``authoredOn``." - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="What request fulfills", - description="Plan/proposal/order fulfilled by this request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CarePlan", "ServiceRequest", "MedicationRequest"], - ) - - bodySite: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="bodySite", - title="Location on Body", - description=( - "Anatomic location where the procedure should be performed. This is the" - " target site." - ), - # if property is element of this resource. - element_property=True, - ) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="Classification of service", - description=( - "A code that classifies the service for searching, sorting and display " - 'purposes (e.g. "Surgical Procedure").' - ), - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="What is being requested/ordered", - description=( - "A code that identifies a particular service (i.e., procedure, " - "diagnostic investigation, or panel of investigations) that have been " - "requested." - ), - # if property is element of this resource. - element_property=True, - ) - - doNotPerform: bool = Field( - None, - alias="doNotPerform", - title="True if service/procedure should not be performed", - description=( - "Set this to true if the record is saying that the service/procedure " - "should NOT be performed." - ), - # if property is element of this resource. - element_property=True, - ) - doNotPerform__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_doNotPerform", title="Extension field for ``doNotPerform``." - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Encounter in which the request was created", - description=( - "An encounter that provides additional information about the healthcare" - " context in which this request is made." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Identifiers assigned to this order", - description=( - "Identifiers assigned to this order instance by the orderer and/or the " - "receiver and/or order fulfiller." - ), - # if property is element of this resource. - element_property=True, - ) - - instantiatesCanonical: typing.List[fhirtypes.Canonical] = Field( - None, - alias="instantiatesCanonical", - title="Instantiates FHIR protocol or definition", - description=( - "The URL pointing to a FHIR-defined protocol, guideline, orderset or " - "other definition that is adhered to in whole or in part by this " - "ServiceRequest." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ActivityDefinition", "PlanDefinition"], - ) - instantiatesCanonical__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_instantiatesCanonical", - title="Extension field for ``instantiatesCanonical``.", - ) - - instantiatesUri: typing.List[fhirtypes.Uri] = Field( - None, - alias="instantiatesUri", - title="Instantiates external protocol or definition", - description=( - "The URL pointing to an externally maintained protocol, guideline, " - "orderset or other definition that is adhered to in whole or in part by" - " this ServiceRequest." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - insurance: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="insurance", - title="Associated insurance coverage", - description=( - "Insurance plans, coverage extensions, pre-authorizations and/or pre-" - "determinations that may be needed for delivering the requested " - "service." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Coverage", "ClaimResponse"], - ) - - intent: fhirtypes.Code = Field( - None, - alias="intent", - title=( - "proposal | plan | directive | order | original-order | reflex-order | " - "filler-order | instance-order | option" - ), - description=( - "Whether the request is a proposal, plan, an original order or a reflex" - " order." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "proposal", - "plan", - "directive", - "order", - "original-order", - "reflex-order", - "filler-order", - "instance-order", - "option", - ], - ) - intent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_intent", title="Extension field for ``intent``." - ) - - locationCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="locationCode", - title="Requested location", - description=( - "The preferred location(s) where the procedure should actually happen " - "in coded or free text form. E.g. at home or nursing day care center." - ), - # if property is element of this resource. - element_property=True, - ) - - locationReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="locationReference", - title="Requested location", - description=( - "A reference to the the preferred location(s) where the procedure " - "should actually happen. E.g. at home or nursing day care center." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments", - description=( - "Any other notes and comments made about the service request. For " - "example, internal billing notes." - ), - # if property is element of this resource. - element_property=True, - ) - - occurrenceDateTime: fhirtypes.DateTime = Field( - None, - alias="occurrenceDateTime", - title="When service should occur", - description="The date/time at which the requested service should occur.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - occurrenceDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurrenceDateTime", - title="Extension field for ``occurrenceDateTime``.", - ) - - occurrencePeriod: fhirtypes.PeriodType = Field( - None, - alias="occurrencePeriod", - title="When service should occur", - description="The date/time at which the requested service should occur.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - occurrenceTiming: fhirtypes.TimingType = Field( - None, - alias="occurrenceTiming", - title="When service should occur", - description="The date/time at which the requested service should occur.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - orderDetail: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="orderDetail", - title="Additional order information", - description=( - "Additional details and instructions about the how the services are to " - "be delivered. For example, and order for a urinary catheter may have" - " an order detail for an external or indwelling catheter, or an order " - "for a bandage may require additional instructions specifying how the " - "bandage should be applied." - ), - # if property is element of this resource. - element_property=True, - ) - - patientInstruction: fhirtypes.String = Field( - None, - alias="patientInstruction", - title="Patient or consumer-oriented instructions", - description="Instructions in terms that are understood by the patient or consumer.", - # if property is element of this resource. - element_property=True, - ) - patientInstruction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_patientInstruction", - title="Extension field for ``patientInstruction``.", - ) - - performer: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="performer", - title="Requested performer", - description=( - "The desired performer for doing the requested service. For example, " - "the surgeon, dermatopathologist, endoscopist, etc." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "CareTeam", - "HealthcareService", - "Patient", - "Device", - "RelatedPerson", - ], - ) - - performerType: fhirtypes.CodeableConceptType = Field( - None, - alias="performerType", - title="Performer role", - description="Desired type of performer for doing the requested service.", - # if property is element of this resource. - element_property=True, - ) - - priority: fhirtypes.Code = Field( - None, - alias="priority", - title="routine | urgent | asap | stat", - description=( - "Indicates how quickly the ServiceRequest should be addressed with " - "respect to other requests." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["routine", "urgent", "asap", "stat"], - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - quantityQuantity: fhirtypes.QuantityType = Field( - None, - alias="quantityQuantity", - title="Service amount", - description=( - "An amount of service being requested which can be a quantity ( for " - "example $1,500 home modification), a ratio ( for example, 20 half day " - "visits per month), or a range (2.0 to 1.8 Gy per fraction)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e quantity[x] - one_of_many="quantity", - one_of_many_required=False, - ) - - quantityRange: fhirtypes.RangeType = Field( - None, - alias="quantityRange", - title="Service amount", - description=( - "An amount of service being requested which can be a quantity ( for " - "example $1,500 home modification), a ratio ( for example, 20 half day " - "visits per month), or a range (2.0 to 1.8 Gy per fraction)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e quantity[x] - one_of_many="quantity", - one_of_many_required=False, - ) - - quantityRatio: fhirtypes.RatioType = Field( - None, - alias="quantityRatio", - title="Service amount", - description=( - "An amount of service being requested which can be a quantity ( for " - "example $1,500 home modification), a ratio ( for example, 20 half day " - "visits per month), or a range (2.0 to 1.8 Gy per fraction)." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e quantity[x] - one_of_many="quantity", - one_of_many_required=False, - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="Explanation/Justification for procedure or service", - description=( - "An explanation or justification for why this service is being " - "requested in coded or textual form. This is often for billing " - "purposes. May relate to the resources referred to in " - "`supportingInfo`." - ), - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="Explanation/Justification for service or service", - description=( - "Indicates another resource that provides a justification for why this " - "service is being requested. May relate to the resources referred to " - "in `supportingInfo`." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "DiagnosticReport", - "DocumentReference", - ], - ) - - relevantHistory: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="relevantHistory", - title="Request provenance", - description="Key events in the history of the request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Provenance"], - ) - - replaces: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="replaces", - title="What request replaces", - description=( - "The request takes the place of the referenced completed or terminated " - "request(s)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ServiceRequest"], - ) - - requester: fhirtypes.ReferenceType = Field( - None, - alias="requester", - title="Who/what is requesting service", - description=( - "The individual who initiated the request and has responsibility for " - "its activation." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Patient", - "RelatedPerson", - "Device", - ], - ) - - requisition: fhirtypes.IdentifierType = Field( - None, - alias="requisition", - title="Composite Request ID", - description=( - "A shared identifier common to all service requests that were " - "authorized more or less simultaneously by a single author, " - "representing the composite or group identifier." - ), - # if property is element of this resource. - element_property=True, - ) - - specimen: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="specimen", - title="Procedure Samples", - description="One or more specimens that the laboratory procedure will use.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Specimen"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "draft | active | on-hold | revoked | completed | entered-in-error | " - "unknown" - ), - description="The status of the order.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "draft", - "active", - "on-hold", - "revoked", - "completed", - "entered-in-error", - "unknown", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - ..., - alias="subject", - title="Individual or Entity the service is ordered for", - description=( - "On whom or what the service is to be performed. This is usually a " - "human patient, but can also be requested on animals, groups of humans " - "or animals, devices such as dialysis machines, or even locations " - "(typically for environmental scans)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group", "Location", "Device"], - ) - - supportingInfo: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supportingInfo", - title="Additional clinical information", - description=( - "Additional clinical information about the patient or specimen that may" - " influence the services or their interpretations. This information" - " includes diagnosis, clinical findings and other observations. In " - 'laboratory ordering these are typically referred to as "ask at order ' - 'entry questions (AOEs)". This includes observations explicitly ' - "requested by the producer (filler) to provide context or supporting " - "information needed to complete the order. For example, reporting the " - "amount of inspired oxygen for blood gas measurements." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ServiceRequest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "instantiatesCanonical", - "instantiatesUri", - "basedOn", - "replaces", - "requisition", - "status", - "intent", - "category", - "priority", - "doNotPerform", - "code", - "orderDetail", - "quantityQuantity", - "quantityRatio", - "quantityRange", - "subject", - "encounter", - "occurrenceDateTime", - "occurrencePeriod", - "occurrenceTiming", - "asNeededBoolean", - "asNeededCodeableConcept", - "authoredOn", - "requester", - "performerType", - "performer", - "locationCode", - "locationReference", - "reasonCode", - "reasonReference", - "insurance", - "supportingInfo", - "specimen", - "bodySite", - "note", - "patientInstruction", - "relevantHistory", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1665( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("intent", "intent__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1665( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "asNeeded": ["asNeededBoolean", "asNeededCodeableConcept"], - "occurrence": [ - "occurrenceDateTime", - "occurrencePeriod", - "occurrenceTiming", - ], - "quantity": ["quantityQuantity", "quantityRange", "quantityRatio"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/signature.py b/fhir/resources/signature.py deleted file mode 100644 index d9c42e3f..00000000 --- a/fhir/resources/signature.py +++ /dev/null @@ -1,224 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Signature -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import element, fhirtypes - - -class Signature(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A Signature - XML DigSig, JWS, Graphical image of signature, etc.. - A signature along with supporting context. The signature may be a digital - signature that is cryptographic in nature, or some other signature - acceptable to the domain. This other signature may be as simple as a - graphical image representing a hand-written signature, or a signature - ceremony Different signature approaches have different utilities. - """ - - resource_type = Field("Signature", const=True) - - data: fhirtypes.Base64Binary = Field( - None, - alias="data", - title="The actual signature content (XML DigSig. JWS, picture, etc.)", - description=( - "The base64 encoding of the Signature content. When signature is not " - "recorded electronically this element would be empty." - ), - # if property is element of this resource. - element_property=True, - ) - data__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_data", title="Extension field for ``data``." - ) - - onBehalfOf: fhirtypes.ReferenceType = Field( - None, - alias="onBehalfOf", - title="The party represented", - description=( - "A reference to an application-usable description of the identity that " - "is represented by the signature." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Patient", - "Device", - "Organization", - ], - ) - - sigFormat: fhirtypes.Code = Field( - None, - alias="sigFormat", - title="The technical format of the signature", - description=( - "A mime type that indicates the technical format of the signature. " - "Important mime types are application/signature+xml for X ML DigSig, " - "application/jose for JWS, and image/* for a graphical image of a " - "signature, etc." - ), - # if property is element of this resource. - element_property=True, - ) - sigFormat__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sigFormat", title="Extension field for ``sigFormat``." - ) - - targetFormat: fhirtypes.Code = Field( - None, - alias="targetFormat", - title="The technical format of the signed resources", - description=( - "A mime type that indicates the technical format of the target " - "resources signed by the signature." - ), - # if property is element of this resource. - element_property=True, - ) - targetFormat__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_targetFormat", title="Extension field for ``targetFormat``." - ) - - type: typing.List[fhirtypes.CodingType] = Field( - ..., - alias="type", - title="Indication of the reason the entity signed the object(s)", - description=( - "An indication of the reason that the entity signed this document. This" - " may be explicitly included as part of the signature information and " - "can be used when determining accountability for various actions " - "concerning the document." - ), - # if property is element of this resource. - element_property=True, - ) - - when: fhirtypes.Instant = Field( - None, - alias="when", - title="When the signature was created", - description="When the digital signature was signed.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - when__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_when", title="Extension field for ``when``." - ) - - who: fhirtypes.ReferenceType = Field( - ..., - alias="who", - title="Who signed", - description=( - "A reference to an application-usable description of the identity that " - "signed (e.g. the signature used their private key)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Patient", - "Device", - "Organization", - ], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Signature`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "type", - "when", - "who", - "onBehalfOf", - "targetFormat", - "sigFormat", - "data", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1130( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("when", "when__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/slot.py b/fhir/resources/slot.py deleted file mode 100644 index 4a7e88ae..00000000 --- a/fhir/resources/slot.py +++ /dev/null @@ -1,268 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Slot -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import domainresource, fhirtypes - - -class Slot(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A slot of time on a schedule that may be available for booking appointments. - """ - - resource_type = Field("Slot", const=True) - - appointmentType: fhirtypes.CodeableConceptType = Field( - None, - alias="appointmentType", - title=( - "The style of appointment or patient that may be booked in the slot " - "(not service type)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title=( - "Comments on the slot to describe any extended information. Such as " - "custom constraints on the slot" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - end: fhirtypes.Instant = Field( - None, - alias="end", - title="Date/Time that the slot is to conclude", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - end__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_end", title="Extension field for ``end``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Ids for this item", - description=None, - # if property is element of this resource. - element_property=True, - ) - - overbooked: bool = Field( - None, - alias="overbooked", - title=( - "This slot has already been overbooked, appointments are unlikely to be" - " accepted for this time" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - overbooked__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_overbooked", title="Extension field for ``overbooked``." - ) - - schedule: fhirtypes.ReferenceType = Field( - ..., - alias="schedule", - title=( - "The schedule resource that this slot defines an interval of status " - "information" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Schedule"], - ) - - serviceCategory: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="serviceCategory", - title=( - "A broad categorization of the service that is to be performed during " - "this appointment" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - serviceType: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="serviceType", - title=( - "The type of appointments that can be booked into this slot (ideally " - "this would be an identifiable service - which is at a location, rather" - " than the location itself). If provided then this overrides the value " - "provided on the availability resource" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - specialty: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="specialty", - title=( - "The specialty of a practitioner that would be required to perform the " - "service requested in this appointment" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - start: fhirtypes.Instant = Field( - None, - alias="start", - title="Date/Time that the slot is to begin", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - start__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_start", title="Extension field for ``start``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="busy | free | busy-unavailable | busy-tentative | entered-in-error", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "busy", - "free", - "busy-unavailable", - "busy-tentative", - "entered-in-error", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Slot`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "serviceCategory", - "serviceType", - "specialty", - "appointmentType", - "schedule", - "status", - "start", - "end", - "overbooked", - "comment", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_617( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("end", "end__ext"), - ("start", "start__ext"), - ("status", "status__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/specimen.py b/fhir/resources/specimen.py deleted file mode 100644 index 99f51ff5..00000000 --- a/fhir/resources/specimen.py +++ /dev/null @@ -1,700 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Specimen -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class Specimen(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Sample for analysis. - A sample to be used for analysis. - """ - - resource_type = Field("Specimen", const=True) - - accessionIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="accessionIdentifier", - title="Identifier assigned by the lab", - description=( - "The identifier assigned by the lab when accessioning specimen(s). This" - " is not necessarily the same as the specimen identifier, depending on " - "local lab procedures." - ), - # if property is element of this resource. - element_property=True, - ) - - collection: fhirtypes.SpecimenCollectionType = Field( - None, - alias="collection", - title="Collection details", - description="Details concerning the specimen collection.", - # if property is element of this resource. - element_property=True, - ) - - condition: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="condition", - title="State of the specimen", - description="A mode or state of being that describes the nature of the specimen.", - # if property is element of this resource. - element_property=True, - ) - - container: typing.List[fhirtypes.SpecimenContainerType] = Field( - None, - alias="container", - title="Direct container of specimen (tube/slide, etc.)", - description=( - "The container holding the specimen. The recursive nature of " - "containers; i.e. blood in tube in tray in rack is not addressed here." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External Identifier", - description="Id for specimen.", - # if property is element of this resource. - element_property=True, - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments", - description=( - "To communicate any details or issues about the specimen or during the " - "specimen collection. (for example: broken vial, sent with patient, " - "frozen)." - ), - # if property is element of this resource. - element_property=True, - ) - - parent: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="parent", - title="Specimen from which this specimen originated", - description=( - "Reference to the parent (source) specimen which is used when the " - "specimen was either derived from or a component of another specimen." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Specimen"], - ) - - processing: typing.List[fhirtypes.SpecimenProcessingType] = Field( - None, - alias="processing", - title="Processing and processing step details", - description="Details concerning processing and processing steps for the specimen.", - # if property is element of this resource. - element_property=True, - ) - - receivedTime: fhirtypes.DateTime = Field( - None, - alias="receivedTime", - title="The time when specimen was received for processing", - description="Time when specimen was received for processing or testing.", - # if property is element of this resource. - element_property=True, - ) - receivedTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_receivedTime", title="Extension field for ``receivedTime``." - ) - - request: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="request", - title="Why the specimen was collected", - description=( - "Details concerning a service request that required a specimen to be " - "collected." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ServiceRequest"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="available | unavailable | unsatisfactory | entered-in-error", - description="The availability of the specimen.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["available", "unavailable", "unsatisfactory", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - subject: fhirtypes.ReferenceType = Field( - None, - alias="subject", - title=( - "Where the specimen came from. This may be from patient(s), from a " - "location (e.g., the source of an environmental sample), or a sampling " - "of a substance or a device" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient", "Group", "Device", "Substance", "Location"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Kind of material that forms the specimen", - description="The kind of material that forms the specimen.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Specimen`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "accessionIdentifier", - "status", - "type", - "subject", - "receivedTime", - "parent", - "request", - "collection", - "processing", - "container", - "condition", - "note", - ] - - -class SpecimenCollection(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Collection details. - Details concerning the specimen collection. - """ - - resource_type = Field("SpecimenCollection", const=True) - - bodySite: fhirtypes.CodeableConceptType = Field( - None, - alias="bodySite", - title="Anatomical collection site", - description=( - "Anatomical location from which the specimen was collected (if subject " - "is a patient). This is the target site. This element is not used for " - "environmental specimens." - ), - # if property is element of this resource. - element_property=True, - ) - - collectedDateTime: fhirtypes.DateTime = Field( - None, - alias="collectedDateTime", - title="Collection time", - description=( - "Time when specimen was collected from subject - the physiologically " - "relevant time." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e collected[x] - one_of_many="collected", - one_of_many_required=False, - ) - collectedDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_collectedDateTime", - title="Extension field for ``collectedDateTime``.", - ) - - collectedPeriod: fhirtypes.PeriodType = Field( - None, - alias="collectedPeriod", - title="Collection time", - description=( - "Time when specimen was collected from subject - the physiologically " - "relevant time." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e collected[x] - one_of_many="collected", - one_of_many_required=False, - ) - - collector: fhirtypes.ReferenceType = Field( - None, - alias="collector", - title="Who collected the specimen", - description="Person who collected the specimen.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - duration: fhirtypes.DurationType = Field( - None, - alias="duration", - title="How long it took to collect specimen", - description="The span of time over which the collection of a specimen occurred.", - # if property is element of this resource. - element_property=True, - ) - - fastingStatusCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="fastingStatusCodeableConcept", - title="Whether or how long patient abstained from food and/or drink", - description=( - "Abstinence or reduction from some or all food, drink, or both, for a " - "period of time prior to sample collection." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fastingStatus[x] - one_of_many="fastingStatus", - one_of_many_required=False, - ) - - fastingStatusDuration: fhirtypes.DurationType = Field( - None, - alias="fastingStatusDuration", - title="Whether or how long patient abstained from food and/or drink", - description=( - "Abstinence or reduction from some or all food, drink, or both, for a " - "period of time prior to sample collection." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e fastingStatus[x] - one_of_many="fastingStatus", - one_of_many_required=False, - ) - - method: fhirtypes.CodeableConceptType = Field( - None, - alias="method", - title="Technique used to perform collection", - description=( - "A coded value specifying the technique that is used to perform the " - "procedure." - ), - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="The quantity of specimen collected", - description=( - "The quantity of specimen collected; for instance the volume of a blood" - " sample, or the physical measurement of an anatomic pathology sample." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SpecimenCollection`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "collector", - "collectedDateTime", - "collectedPeriod", - "duration", - "quantity", - "method", - "bodySite", - "fastingStatusCodeableConcept", - "fastingStatusDuration", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2049( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "collected": ["collectedDateTime", "collectedPeriod"], - "fastingStatus": ["fastingStatusCodeableConcept", "fastingStatusDuration"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class SpecimenContainer(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Direct container of specimen (tube/slide, etc.). - The container holding the specimen. The recursive nature of containers; - i.e. blood in tube in tray in rack is not addressed here. - """ - - resource_type = Field("SpecimenContainer", const=True) - - additiveCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="additiveCodeableConcept", - title="Additive associated with container", - description=( - "Introduced substance to preserve, maintain or enhance the specimen. " - "Examples: Formalin, Citrate, EDTA." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e additive[x] - one_of_many="additive", - one_of_many_required=False, - ) - - additiveReference: fhirtypes.ReferenceType = Field( - None, - alias="additiveReference", - title="Additive associated with container", - description=( - "Introduced substance to preserve, maintain or enhance the specimen. " - "Examples: Formalin, Citrate, EDTA." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e additive[x] - one_of_many="additive", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Substance"], - ) - - capacity: fhirtypes.QuantityType = Field( - None, - alias="capacity", - title="Container volume or size", - description="The capacity (volume or other measure) the container may contain.", - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Textual description of the container", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Id for the container", - description=( - "Id for container. There may be multiple; a manufacturer's bar code, " - "lab assigned identifier, etc. The container ID may differ from the " - "specimen id in some circumstances." - ), - # if property is element of this resource. - element_property=True, - ) - - specimenQuantity: fhirtypes.QuantityType = Field( - None, - alias="specimenQuantity", - title="Quantity of specimen within container", - description=( - "The quantity of specimen in the container; may be volume, dimensions, " - "or other appropriate measurements, depending on the specimen type." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Kind of container directly associated with specimen", - description=( - "The type of container associated with the specimen (e.g. slide, " - "aliquot, etc.)." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SpecimenContainer`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "description", - "type", - "capacity", - "specimenQuantity", - "additiveCodeableConcept", - "additiveReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1948( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "additive": ["additiveCodeableConcept", "additiveReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class SpecimenProcessing(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Processing and processing step details. - Details concerning processing and processing steps for the specimen. - """ - - resource_type = Field("SpecimenProcessing", const=True) - - additive: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="additive", - title="Material used in the processing step", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Substance"], - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Textual description of procedure", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - procedure: fhirtypes.CodeableConceptType = Field( - None, - alias="procedure", - title="Indicates the treatment step applied to the specimen", - description="A coded value specifying the procedure used to process the specimen.", - # if property is element of this resource. - element_property=True, - ) - - timeDateTime: fhirtypes.DateTime = Field( - None, - alias="timeDateTime", - title="Date and time of specimen processing", - description=( - "A record of the time or period when the specimen processing occurred." - " For example the time of sample fixation or the period of time the " - "sample was in formalin." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e time[x] - one_of_many="time", - one_of_many_required=False, - ) - timeDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timeDateTime", title="Extension field for ``timeDateTime``." - ) - - timePeriod: fhirtypes.PeriodType = Field( - None, - alias="timePeriod", - title="Date and time of specimen processing", - description=( - "A record of the time or period when the specimen processing occurred." - " For example the time of sample fixation or the period of time the " - "sample was in formalin." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e time[x] - one_of_many="time", - one_of_many_required=False, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SpecimenProcessing`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "description", - "procedure", - "additive", - "timeDateTime", - "timePeriod", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2059( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"time": ["timeDateTime", "timePeriod"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/specimendefinition.py b/fhir/resources/specimendefinition.py deleted file mode 100644 index ee6a5614..00000000 --- a/fhir/resources/specimendefinition.py +++ /dev/null @@ -1,653 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SpecimenDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class SpecimenDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Kind of specimen. - A kind of specimen with associated set of requirements. - """ - - resource_type = Field("SpecimenDefinition", const=True) - - collection: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="collection", - title="Specimen collection procedure", - description="The action to be performed for collecting the specimen.", - # if property is element of this resource. - element_property=True, - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Business identifier of a kind of specimen", - description="A business identifier associated with the kind of specimen.", - # if property is element of this resource. - element_property=True, - ) - - patientPreparation: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="patientPreparation", - title="Patient preparation for collection", - description="Preparation of the patient for specimen collection.", - # if property is element of this resource. - element_property=True, - ) - - timeAspect: fhirtypes.String = Field( - None, - alias="timeAspect", - title="Time aspect for collection", - description="Time aspect of specimen collection (duration or offset).", - # if property is element of this resource. - element_property=True, - ) - timeAspect__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timeAspect", title="Extension field for ``timeAspect``." - ) - - typeCollected: fhirtypes.CodeableConceptType = Field( - None, - alias="typeCollected", - title="Kind of material to collect", - description="The kind of material to be collected.", - # if property is element of this resource. - element_property=True, - ) - - typeTested: typing.List[fhirtypes.SpecimenDefinitionTypeTestedType] = Field( - None, - alias="typeTested", - title="Specimen in container intended for testing by lab", - description=( - "Specimen conditioned in a container as expected by the testing " - "laboratory." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SpecimenDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "typeCollected", - "patientPreparation", - "timeAspect", - "collection", - "typeTested", - ] - - -class SpecimenDefinitionTypeTested(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Specimen in container intended for testing by lab. - Specimen conditioned in a container as expected by the testing laboratory. - """ - - resource_type = Field("SpecimenDefinitionTypeTested", const=True) - - container: fhirtypes.SpecimenDefinitionTypeTestedContainerType = Field( - None, - alias="container", - title="The specimen's container", - description=None, - # if property is element of this resource. - element_property=True, - ) - - handling: typing.List[fhirtypes.SpecimenDefinitionTypeTestedHandlingType] = Field( - None, - alias="handling", - title="Specimen handling before testing", - description=( - "Set of instructions for preservation/transport of the specimen at a " - "defined temperature interval, prior the testing process." - ), - # if property is element of this resource. - element_property=True, - ) - - isDerived: bool = Field( - None, - alias="isDerived", - title="Primary or secondary specimen", - description="Primary of secondary specimen.", - # if property is element of this resource. - element_property=True, - ) - isDerived__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_isDerived", title="Extension field for ``isDerived``." - ) - - preference: fhirtypes.Code = Field( - None, - alias="preference", - title="preferred | alternate", - description="The preference for this type of conditioned specimen.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["preferred", "alternate"], - ) - preference__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_preference", title="Extension field for ``preference``." - ) - - rejectionCriterion: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="rejectionCriterion", - title="Rejection criterion", - description=( - "Criterion for rejection of the specimen in its container by the " - "laboratory." - ), - # if property is element of this resource. - element_property=True, - ) - - requirement: fhirtypes.String = Field( - None, - alias="requirement", - title="Specimen requirements", - description=( - "Requirements for delivery and special handling of this kind of " - "conditioned specimen." - ), - # if property is element of this resource. - element_property=True, - ) - requirement__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_requirement", title="Extension field for ``requirement``." - ) - - retentionTime: fhirtypes.DurationType = Field( - None, - alias="retentionTime", - title="Specimen retention time", - description=( - "The usual time that a specimen of this kind is retained after the " - "ordered tests are completed, for the purpose of additional testing." - ), - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Type of intended specimen", - description="The kind of specimen conditioned for testing expected by lab.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SpecimenDefinitionTypeTested`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "isDerived", - "type", - "preference", - "container", - "requirement", - "retentionTime", - "rejectionCriterion", - "handling", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3071( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("preference", "preference__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class SpecimenDefinitionTypeTestedContainer(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The specimen's container. - """ - - resource_type = Field("SpecimenDefinitionTypeTestedContainer", const=True) - - additive: typing.List[ - fhirtypes.SpecimenDefinitionTypeTestedContainerAdditiveType - ] = Field( - None, - alias="additive", - title="Additive associated with container", - description=( - "Substance introduced in the kind of container to preserve, maintain or" - " enhance the specimen. Examples: Formalin, Citrate, EDTA." - ), - # if property is element of this resource. - element_property=True, - ) - - cap: fhirtypes.CodeableConceptType = Field( - None, - alias="cap", - title="Color of container cap", - description=None, - # if property is element of this resource. - element_property=True, - ) - - capacity: fhirtypes.QuantityType = Field( - None, - alias="capacity", - title="Container capacity", - description="The capacity (volume or other measure) of this kind of container.", - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Container description", - description="The textual description of the kind of container.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - material: fhirtypes.CodeableConceptType = Field( - None, - alias="material", - title="Container material", - description="The type of material of the container.", - # if property is element of this resource. - element_property=True, - ) - - minimumVolumeQuantity: fhirtypes.QuantityType = Field( - None, - alias="minimumVolumeQuantity", - title="Minimum volume", - description="The minimum volume to be conditioned in the container.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e minimumVolume[x] - one_of_many="minimumVolume", - one_of_many_required=False, - ) - - minimumVolumeString: fhirtypes.String = Field( - None, - alias="minimumVolumeString", - title="Minimum volume", - description="The minimum volume to be conditioned in the container.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e minimumVolume[x] - one_of_many="minimumVolume", - one_of_many_required=False, - ) - minimumVolumeString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_minimumVolumeString", - title="Extension field for ``minimumVolumeString``.", - ) - - preparation: fhirtypes.String = Field( - None, - alias="preparation", - title="Specimen container preparation", - description=( - "Special processing that should be applied to the container for this " - "kind of specimen." - ), - # if property is element of this resource. - element_property=True, - ) - preparation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_preparation", title="Extension field for ``preparation``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Kind of container associated with the kind of specimen", - description="The type of container used to contain this kind of specimen.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SpecimenDefinitionTypeTestedContainer`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "material", - "type", - "cap", - "description", - "capacity", - "minimumVolumeQuantity", - "minimumVolumeString", - "additive", - "preparation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4016( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "minimumVolume": ["minimumVolumeQuantity", "minimumVolumeString"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class SpecimenDefinitionTypeTestedContainerAdditive(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Additive associated with container. - Substance introduced in the kind of container to preserve, maintain or - enhance the specimen. Examples: Formalin, Citrate, EDTA. - """ - - resource_type = Field("SpecimenDefinitionTypeTestedContainerAdditive", const=True) - - additiveCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="additiveCodeableConcept", - title="Additive associated with container", - description=( - "Substance introduced in the kind of container to preserve, maintain or" - " enhance the specimen. Examples: Formalin, Citrate, EDTA." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e additive[x] - one_of_many="additive", - one_of_many_required=True, - ) - - additiveReference: fhirtypes.ReferenceType = Field( - None, - alias="additiveReference", - title="Additive associated with container", - description=( - "Substance introduced in the kind of container to preserve, maintain or" - " enhance the specimen. Examples: Formalin, Citrate, EDTA." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e additive[x] - one_of_many="additive", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Substance"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SpecimenDefinitionTypeTestedContainerAdditive`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "additiveCodeableConcept", - "additiveReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_4813( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "additive": ["additiveCodeableConcept", "additiveReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class SpecimenDefinitionTypeTestedHandling(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Specimen handling before testing. - Set of instructions for preservation/transport of the specimen at a defined - temperature interval, prior the testing process. - """ - - resource_type = Field("SpecimenDefinitionTypeTestedHandling", const=True) - - instruction: fhirtypes.String = Field( - None, - alias="instruction", - title="Preservation instruction", - description=( - "Additional textual instructions for the preservation or transport of " - "the specimen. For instance, 'Protect from light exposure'." - ), - # if property is element of this resource. - element_property=True, - ) - instruction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_instruction", title="Extension field for ``instruction``." - ) - - maxDuration: fhirtypes.DurationType = Field( - None, - alias="maxDuration", - title="Maximum preservation time", - description=( - "The maximum time interval of preservation of the specimen with these " - "conditions." - ), - # if property is element of this resource. - element_property=True, - ) - - temperatureQualifier: fhirtypes.CodeableConceptType = Field( - None, - alias="temperatureQualifier", - title="Temperature qualifier", - description=( - "It qualifies the interval of temperature, which characterizes an " - "occurrence of handling. Conditions that are not related to temperature" - " may be handled in the instruction element." - ), - # if property is element of this resource. - element_property=True, - ) - - temperatureRange: fhirtypes.RangeType = Field( - None, - alias="temperatureRange", - title="Temperature range", - description="The temperature interval for this set of handling instructions.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SpecimenDefinitionTypeTestedHandling`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "temperatureQualifier", - "temperatureRange", - "maxDuration", - "instruction", - ] diff --git a/fhir/resources/structuredefinition.py b/fhir/resources/structuredefinition.py deleted file mode 100644 index ce022d4d..00000000 --- a/fhir/resources/structuredefinition.py +++ /dev/null @@ -1,884 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/StructureDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class StructureDefinition(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Structural Definition. - A definition of a FHIR structure. This resource is used to describe the - underlying resources, data types defined in FHIR, and also for describing - extensions and constraints on resources and data types. - """ - - resource_type = Field("StructureDefinition", const=True) - - abstract: bool = Field( - None, - alias="abstract", - title="Whether the structure is abstract", - description=( - "Whether structure this definition describes is abstract or not - that" - " is, whether the structure is not intended to be instantiated. For " - "Resources and Data types, abstract types will never be exchanged " - "between systems." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - abstract__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_abstract", title="Extension field for ``abstract``." - ) - - baseDefinition: fhirtypes.Canonical = Field( - None, - alias="baseDefinition", - title="Definition that this type is constrained/specialized from", - description=( - "An absolute URI that is the base structure from which this type is " - "derived, either by specialization or constraint." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - baseDefinition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_baseDefinition", title="Extension field for ``baseDefinition``." - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - context: typing.List[fhirtypes.StructureDefinitionContextType] = Field( - None, - alias="context", - title="If an extension, where it can be used in instances", - description=( - "Identifies the types of resource or data type elements to which the " - "extension can be applied." - ), - # if property is element of this resource. - element_property=True, - ) - - contextInvariant: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="contextInvariant", - title="FHIRPath invariants - when the extension can be used", - description=( - "A set of rules as FHIRPath Invariants about when the extension can be " - "used (e.g. co-occurrence variants for the extension). All the rules " - "must be true." - ), - # if property is element of this resource. - element_property=True, - ) - contextInvariant__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_contextInvariant", - title="Extension field for ``contextInvariant``.", - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the structure definition and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the structure definition." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the structure definition was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the structure definition " - "changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - derivation: fhirtypes.Code = Field( - None, - alias="derivation", - title="specialization | constraint - How relates to base definition", - description="How the type relates to the baseDefinition.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["specialization", "constraint"], - ) - derivation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_derivation", title="Extension field for ``derivation``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the structure definition", - description=( - "A free text natural language description of the structure definition " - "from a consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - differential: fhirtypes.StructureDefinitionDifferentialType = Field( - None, - alias="differential", - title="Differential view of the structure", - description=( - "A differential view is expressed relative to the base " - "StructureDefinition - a statement of differences that it applies." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this structure definition is authored" - " for testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - fhirVersion: fhirtypes.Code = Field( - None, - alias="fhirVersion", - title="FHIR Version this StructureDefinition targets", - description=( - "The version of the FHIR specification on which this " - "StructureDefinition is based - this is the formal version of the " - "specification, without the revision number, e.g. " - "[publication].[major].[minor], which is 4.0.1. for this version." - ), - # if property is element of this resource. - element_property=True, - ) - fhirVersion__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fhirVersion", title="Extension field for ``fhirVersion``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the structure definition", - description=( - "A formal identifier that is used to identify this structure definition" - " when it is represented in other formats, or referenced in a " - "specification, model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for structure definition (if applicable)", - description=( - "A legal or geographic region in which the structure definition is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - keyword: typing.List[fhirtypes.CodingType] = Field( - None, - alias="keyword", - title="Assist with indexing and finding", - description=( - "A set of key words or terms from external terminologies that may be " - "used to assist with indexing and searching of templates nby describing" - " the use of this structure definition, or the content it describes." - ), - # if property is element of this resource. - element_property=True, - ) - - kind: fhirtypes.Code = Field( - None, - alias="kind", - title="primitive-type | complex-type | resource | logical", - description="Defines the kind of structure that this definition is describing.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["primitive-type", "complex-type", "resource", "logical"], - ) - kind__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_kind", title="Extension field for ``kind``." - ) - - mapping: typing.List[fhirtypes.StructureDefinitionMappingType] = Field( - None, - alias="mapping", - title="External specification that the content is mapped to", - description="An external specification that the content is mapped to.", - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this structure definition (computer friendly)", - description=( - "A natural language name identifying the structure definition. This " - "name should be usable as an identifier for the module by machine " - "processing applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the " - "structure definition." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this structure definition is defined", - description=( - "Explanation of why this structure definition is needed and why it has " - "been designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - snapshot: fhirtypes.StructureDefinitionSnapshotType = Field( - None, - alias="snapshot", - title="Snapshot view of the structure", - description=( - "A snapshot view is expressed in a standalone form that can be used and" - " interpreted without considering the base StructureDefinition." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this structure definition. Enables tracking the life-" - "cycle of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this structure definition (human friendly)", - description=( - "A short, descriptive, user-friendly title for the structure " "definition." - ), - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - type: fhirtypes.Uri = Field( - None, - alias="type", - title="Type defined or constrained by this structure", - description=( - "The type this structure describes. If the derivation kind is " - "'specialization' then this is the master definition for a type, and " - "there is always one of these (a data type, an extension, a resource, " - "including abstract ones). Otherwise the structure definition is a " - "constraint on the stated type (and in this case, the type cannot be an" - " abstract type). References are URLs that are relative to " - 'http://hl7.org/fhir/StructureDefinition e.g. "string" is a reference ' - "to http://hl7.org/fhir/StructureDefinition/string. Absolute URLs are " - "only allowed in logical models." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this structure definition, represented as a " - "URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this structure definition " - "when it is referenced in a specification, model, design or an " - "instance; also called its canonical identifier. This SHOULD be " - "globally unique and SHOULD be a literal address at which at which an " - "authoritative instance of this structure definition is (or will be) " - "published. This URL can be the target of a canonical reference. It " - "SHALL remain the same when the structure definition is stored on " - "different servers." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate structure definition instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the structure definition", - description=( - "The identifier that is used to identify this version of the structure " - "definition when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the structure " - "definition author and is not expected to be globally unique. For " - "example, it might be a timestamp (e.g. yyyymmdd) if a managed version " - "is not available. There is also no expectation that versions can be " - "placed in a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "copyright", - "keyword", - "fhirVersion", - "mapping", - "kind", - "abstract", - "context", - "contextInvariant", - "type", - "baseDefinition", - "derivation", - "snapshot", - "differential", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2203( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("abstract", "abstract__ext"), - ("kind", "kind__ext"), - ("name", "name__ext"), - ("status", "status__ext"), - ("type", "type__ext"), - ("url", "url__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class StructureDefinitionContext(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - If an extension, where it can be used in instances. - Identifies the types of resource or data type elements to which the - extension can be applied. - """ - - resource_type = Field("StructureDefinitionContext", const=True) - - expression: fhirtypes.String = Field( - None, - alias="expression", - title="Where the extension can be used in instances", - description=( - "An expression that defines where an extension can be used in " "resources." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - expression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expression", title="Extension field for ``expression``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="fhirpath | element | extension", - description=( - "Defines how to interpret the expression that defines what the context " - "of the extension is." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["fhirpath", "element", "extension"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureDefinitionContext`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "expression"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2950( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("expression", "expression__ext"), ("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class StructureDefinitionDifferential(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Differential view of the structure. - A differential view is expressed relative to the base StructureDefinition - - a statement of differences that it applies. - """ - - resource_type = Field("StructureDefinitionDifferential", const=True) - - element: typing.List[fhirtypes.ElementDefinitionType] = Field( - ..., - alias="element", - title="Definition of elements in the resource (if no StructureDefinition)", - description="Captures constraints on each element within the resource.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureDefinitionDifferential`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "element"] - - -class StructureDefinitionMapping(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - External specification that the content is mapped to. - An external specification that the content is mapped to. - """ - - resource_type = Field("StructureDefinitionMapping", const=True) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Versions, Issues, Scope limitations etc.", - description=( - "Comments about this mapping, including version notes, issues, scope " - "limitations, and other important notes for usage." - ), - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - identity: fhirtypes.Id = Field( - None, - alias="identity", - title="Internal id when this mapping is used", - description=( - "An Internal id that is used to identify this mapping set when specific" - " mappings are made." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - identity__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_identity", title="Extension field for ``identity``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Names what this mapping refers to", - description="A name for the specification that is being mapped to.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - uri: fhirtypes.Uri = Field( - None, - alias="uri", - title="Identifies what this mapping refers to", - description=( - "An absolute URI that identifies the specification that this mapping is" - " expressed to." - ), - # if property is element of this resource. - element_property=True, - ) - uri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_uri", title="Extension field for ``uri``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureDefinitionMapping`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identity", - "uri", - "name", - "comment", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2912( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("identity", "identity__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class StructureDefinitionSnapshot(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Snapshot view of the structure. - A snapshot view is expressed in a standalone form that can be used and - interpreted without considering the base StructureDefinition. - """ - - resource_type = Field("StructureDefinitionSnapshot", const=True) - - element: typing.List[fhirtypes.ElementDefinitionType] = Field( - ..., - alias="element", - title="Definition of elements in the resource (if no StructureDefinition)", - description="Captures constraints on each element within the resource.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureDefinitionSnapshot`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "element"] diff --git a/fhir/resources/structuremap.py b/fhir/resources/structuremap.py deleted file mode 100644 index aa143782..00000000 --- a/fhir/resources/structuremap.py +++ /dev/null @@ -1,2451 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/StructureMap -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class StructureMap(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A Map of relationships between 2 structures that can be used to transform - data. - """ - - resource_type = Field("StructureMap", const=True) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the structure map and/or its " - "contents. Copyright statements are generally legal restrictions on the" - " use and publishing of the structure map." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the structure map was published. " - "The date must change when the business version changes and it must " - "change if the status code changes. In addition, it should change when " - "the substantive content of the structure map changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the structure map", - description=( - "A free text natural language description of the structure map from a " - "consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this structure map is authored for " - "testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - group: typing.List[fhirtypes.StructureMapGroupType] = Field( - ..., - alias="group", - title="Named sections for reader convenience", - description=( - "Organizes the mapping into manageable chunks for human review/ease of " - "maintenance." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the structure map", - description=( - "A formal identifier that is used to identify this structure map when " - "it is represented in other formats, or referenced in a specification, " - "model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - import_fhir: typing.List[fhirtypes.Canonical] = Field( - None, - alias="import", - title="Other maps used by this map (canonical URLs)", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureMap"], - ) - import__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_import", title="Extension field for ``import_fhir``.") - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for structure map (if applicable)", - description=( - "A legal or geographic region in which the structure map is intended to" - " be used." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this structure map (computer friendly)", - description=( - "A natural language name identifying the structure map. This name " - "should be usable as an identifier for the module by machine processing" - " applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the " - "structure map." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this structure map is defined", - description=( - "Explanation of why this structure map is needed and why it has been " - "designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this structure map. Enables tracking the life-cycle of " - "the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - structure: typing.List[fhirtypes.StructureMapStructureType] = Field( - None, - alias="structure", - title="Structure Definition used by this map", - description=( - "A structure definition used by this map. The structure definition may " - "describe instances that are converted, or the instances that are " - "produced." - ), - # if property is element of this resource. - element_property=True, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this structure map (human friendly)", - description="A short, descriptive, user-friendly title for the structure map.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this structure map, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this structure map when it is" - " referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this structure map is (or will be) published. This URL can" - " be the target of a canonical reference. It SHALL remain the same when" - " the structure map is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate structure map instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the structure map", - description=( - "The identifier that is used to identify this version of the structure " - "map when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the structure map " - "author and is not expected to be globally unique. For example, it " - "might be a timestamp (e.g. yyyymmdd) if a managed version is not " - "available. There is also no expectation that versions can be placed in" - " a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureMap`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "copyright", - "structure", - "import", - "group", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1458( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("name", "name__ext"), - ("status", "status__ext"), - ("url", "url__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class StructureMapGroup(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Named sections for reader convenience. - Organizes the mapping into manageable chunks for human review/ease of - maintenance. - """ - - resource_type = Field("StructureMapGroup", const=True) - - documentation: fhirtypes.String = Field( - None, - alias="documentation", - title="Additional description/explanation for group", - description=( - "Additional supporting documentation that explains the purpose of the " - "group and the types of mappings within it." - ), - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - extends: fhirtypes.Id = Field( - None, - alias="extends", - title="Another group that this group adds rules to", - description=None, - # if property is element of this resource. - element_property=True, - ) - extends__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_extends", title="Extension field for ``extends``." - ) - - input: typing.List[fhirtypes.StructureMapGroupInputType] = Field( - ..., - alias="input", - title="Named instance provided when invoking the map", - description=( - "A name assigned to an instance of data. The instance must be provided " - "when the mapping is invoked." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.Id = Field( - None, - alias="name", - title="Human-readable label", - description="A unique name for the group for the convenience of human readers.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - rule: typing.List[fhirtypes.StructureMapGroupRuleType] = Field( - ..., - alias="rule", - title="Transform Rule from source to target", - description=None, - # if property is element of this resource. - element_property=True, - ) - - typeMode: fhirtypes.Code = Field( - None, - alias="typeMode", - title="none | types | type-and-types", - description=( - "If this is the default rule set to apply for the source type or this " - "combination of types." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["none", "types", "type-and-types"], - ) - typeMode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_typeMode", title="Extension field for ``typeMode``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureMapGroup`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "extends", - "typeMode", - "documentation", - "input", - "rule", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1983( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext"), ("typeMode", "typeMode__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class StructureMapGroupInput(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Named instance provided when invoking the map. - A name assigned to an instance of data. The instance must be provided when - the mapping is invoked. - """ - - resource_type = Field("StructureMapGroupInput", const=True) - - documentation: fhirtypes.String = Field( - None, - alias="documentation", - title="Documentation for this instance of data", - description=None, - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - mode: fhirtypes.Code = Field( - None, - alias="mode", - title="source | target", - description="Mode for this instance of data.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["source", "target"], - ) - mode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mode", title="Extension field for ``mode``." - ) - - name: fhirtypes.Id = Field( - None, - alias="name", - title="Name for this instance of data", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - type: fhirtypes.String = Field( - None, - alias="type", - title="Type for this instance of data", - description=None, - # if property is element of this resource. - element_property=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureMapGroupInput`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "type", - "mode", - "documentation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2515( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("mode", "mode__ext"), ("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class StructureMapGroupRule(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Transform Rule from source to target. - """ - - resource_type = Field("StructureMapGroupRule", const=True) - - dependent: typing.List[fhirtypes.StructureMapGroupRuleDependentType] = Field( - None, - alias="dependent", - title="Which other rules to apply in the context of this rule", - description=None, - # if property is element of this resource. - element_property=True, - ) - - documentation: fhirtypes.String = Field( - None, - alias="documentation", - title="Documentation for this instance of data", - description=None, - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - name: fhirtypes.Id = Field( - None, - alias="name", - title="Name of the rule for internal references", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - rule: typing.List[fhirtypes.StructureMapGroupRuleType] = Field( - None, - alias="rule", - title="Rules contained in this rule", - description=None, - # if property is element of this resource. - element_property=True, - ) - - source: typing.List[fhirtypes.StructureMapGroupRuleSourceType] = Field( - ..., - alias="source", - title="Source inputs to the mapping", - description=None, - # if property is element of this resource. - element_property=True, - ) - - target: typing.List[fhirtypes.StructureMapGroupRuleTargetType] = Field( - None, - alias="target", - title="Content to create because of this mapping rule", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureMapGroupRule`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "source", - "target", - "rule", - "dependent", - "documentation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2380( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class StructureMapGroupRuleDependent(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Which other rules to apply in the context of this rule. - """ - - resource_type = Field("StructureMapGroupRuleDependent", const=True) - - name: fhirtypes.Id = Field( - None, - alias="name", - title="Name of a rule or group to apply", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - variable: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="variable", - title="Variable to pass to the rule or group", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - variable__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_variable", title="Extension field for ``variable``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureMapGroupRuleDependent`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "name", "variable"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3314( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext"), ("variable", "variable__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class StructureMapGroupRuleSource(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Source inputs to the mapping. - """ - - resource_type = Field("StructureMapGroupRuleSource", const=True) - - check: fhirtypes.String = Field( - None, - alias="check", - title=( - "FHIRPath expression - must be true or the mapping engine throws an " - "error instead of completing" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - check__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_check", title="Extension field for ``check``." - ) - - condition: fhirtypes.String = Field( - None, - alias="condition", - title="FHIRPath expression - must be true or the rule does not apply", - description=None, - # if property is element of this resource. - element_property=True, - ) - condition__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_condition", title="Extension field for ``condition``." - ) - - context: fhirtypes.Id = Field( - None, - alias="context", - title="Type or variable this rule applies to", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - context__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_context", title="Extension field for ``context``." - ) - - defaultValueAddress: fhirtypes.AddressType = Field( - None, - alias="defaultValueAddress", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueAge: fhirtypes.AgeType = Field( - None, - alias="defaultValueAge", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueAnnotation: fhirtypes.AnnotationType = Field( - None, - alias="defaultValueAnnotation", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="defaultValueAttachment", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueBase64Binary: fhirtypes.Base64Binary = Field( - None, - alias="defaultValueBase64Binary", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueBase64Binary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueBase64Binary", - title="Extension field for ``defaultValueBase64Binary``.", - ) - - defaultValueBoolean: bool = Field( - None, - alias="defaultValueBoolean", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueBoolean", - title="Extension field for ``defaultValueBoolean``.", - ) - - defaultValueCanonical: fhirtypes.Canonical = Field( - None, - alias="defaultValueCanonical", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueCanonical", - title="Extension field for ``defaultValueCanonical``.", - ) - - defaultValueCode: fhirtypes.Code = Field( - None, - alias="defaultValueCode", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueCode", - title="Extension field for ``defaultValueCode``.", - ) - - defaultValueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="defaultValueCodeableConcept", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueCoding: fhirtypes.CodingType = Field( - None, - alias="defaultValueCoding", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueContactDetail: fhirtypes.ContactDetailType = Field( - None, - alias="defaultValueContactDetail", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueContactPoint: fhirtypes.ContactPointType = Field( - None, - alias="defaultValueContactPoint", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueContributor: fhirtypes.ContributorType = Field( - None, - alias="defaultValueContributor", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueCount: fhirtypes.CountType = Field( - None, - alias="defaultValueCount", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueDataRequirement: fhirtypes.DataRequirementType = Field( - None, - alias="defaultValueDataRequirement", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueDate: fhirtypes.Date = Field( - None, - alias="defaultValueDate", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueDate", - title="Extension field for ``defaultValueDate``.", - ) - - defaultValueDateTime: fhirtypes.DateTime = Field( - None, - alias="defaultValueDateTime", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueDateTime", - title="Extension field for ``defaultValueDateTime``.", - ) - - defaultValueDecimal: fhirtypes.Decimal = Field( - None, - alias="defaultValueDecimal", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueDecimal", - title="Extension field for ``defaultValueDecimal``.", - ) - - defaultValueDistance: fhirtypes.DistanceType = Field( - None, - alias="defaultValueDistance", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueDosage: fhirtypes.DosageType = Field( - None, - alias="defaultValueDosage", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueDuration: fhirtypes.DurationType = Field( - None, - alias="defaultValueDuration", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueExpression: fhirtypes.ExpressionType = Field( - None, - alias="defaultValueExpression", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueHumanName: fhirtypes.HumanNameType = Field( - None, - alias="defaultValueHumanName", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueId: fhirtypes.Id = Field( - None, - alias="defaultValueId", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_defaultValueId", title="Extension field for ``defaultValueId``." - ) - - defaultValueIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="defaultValueIdentifier", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueInstant: fhirtypes.Instant = Field( - None, - alias="defaultValueInstant", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueInstant__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueInstant", - title="Extension field for ``defaultValueInstant``.", - ) - - defaultValueInteger: fhirtypes.Integer = Field( - None, - alias="defaultValueInteger", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueInteger", - title="Extension field for ``defaultValueInteger``.", - ) - - defaultValueMarkdown: fhirtypes.Markdown = Field( - None, - alias="defaultValueMarkdown", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueMarkdown__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueMarkdown", - title="Extension field for ``defaultValueMarkdown``.", - ) - - defaultValueMeta: fhirtypes.MetaType = Field( - None, - alias="defaultValueMeta", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueMoney: fhirtypes.MoneyType = Field( - None, - alias="defaultValueMoney", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueOid: fhirtypes.Oid = Field( - None, - alias="defaultValueOid", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueOid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_defaultValueOid", title="Extension field for ``defaultValueOid``." - ) - - defaultValueParameterDefinition: fhirtypes.ParameterDefinitionType = Field( - None, - alias="defaultValueParameterDefinition", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValuePeriod: fhirtypes.PeriodType = Field( - None, - alias="defaultValuePeriod", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValuePositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="defaultValuePositiveInt", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValuePositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValuePositiveInt", - title="Extension field for ``defaultValuePositiveInt``.", - ) - - defaultValueQuantity: fhirtypes.QuantityType = Field( - None, - alias="defaultValueQuantity", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueRange: fhirtypes.RangeType = Field( - None, - alias="defaultValueRange", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueRatio: fhirtypes.RatioType = Field( - None, - alias="defaultValueRatio", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueReference: fhirtypes.ReferenceType = Field( - None, - alias="defaultValueReference", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueRelatedArtifact: fhirtypes.RelatedArtifactType = Field( - None, - alias="defaultValueRelatedArtifact", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueSampledData: fhirtypes.SampledDataType = Field( - None, - alias="defaultValueSampledData", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueSignature: fhirtypes.SignatureType = Field( - None, - alias="defaultValueSignature", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueString: fhirtypes.String = Field( - None, - alias="defaultValueString", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueString", - title="Extension field for ``defaultValueString``.", - ) - - defaultValueTime: fhirtypes.Time = Field( - None, - alias="defaultValueTime", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueTime", - title="Extension field for ``defaultValueTime``.", - ) - - defaultValueTiming: fhirtypes.TimingType = Field( - None, - alias="defaultValueTiming", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueTriggerDefinition: fhirtypes.TriggerDefinitionType = Field( - None, - alias="defaultValueTriggerDefinition", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="defaultValueUnsignedInt", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueUnsignedInt", - title="Extension field for ``defaultValueUnsignedInt``.", - ) - - defaultValueUri: fhirtypes.Uri = Field( - None, - alias="defaultValueUri", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_defaultValueUri", title="Extension field for ``defaultValueUri``." - ) - - defaultValueUrl: fhirtypes.Url = Field( - None, - alias="defaultValueUrl", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_defaultValueUrl", title="Extension field for ``defaultValueUrl``." - ) - - defaultValueUsageContext: fhirtypes.UsageContextType = Field( - None, - alias="defaultValueUsageContext", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - - defaultValueUuid: fhirtypes.Uuid = Field( - None, - alias="defaultValueUuid", - title="Default value if no value exists", - description="A value to use if there is no existing value in the source object.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e defaultValue[x] - one_of_many="defaultValue", - one_of_many_required=False, - ) - defaultValueUuid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_defaultValueUuid", - title="Extension field for ``defaultValueUuid``.", - ) - - element: fhirtypes.String = Field( - None, - alias="element", - title="Optional field for this source", - description=None, - # if property is element of this resource. - element_property=True, - ) - element__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_element", title="Extension field for ``element``." - ) - - listMode: fhirtypes.Code = Field( - None, - alias="listMode", - title="first | not_first | last | not_last | only_one", - description="How to handle the list mode for this element.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["first", "not_first", "last", "not_last", "only_one"], - ) - listMode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_listMode", title="Extension field for ``listMode``." - ) - - logMessage: fhirtypes.String = Field( - None, - alias="logMessage", - title="Message to put in log if source exists (FHIRPath)", - description=( - "A FHIRPath expression which specifies a message to put in the " - "transform log when content matching the source rule is found." - ), - # if property is element of this resource. - element_property=True, - ) - logMessage__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_logMessage", title="Extension field for ``logMessage``." - ) - - max: fhirtypes.String = Field( - None, - alias="max", - title="Specified maximum cardinality (number or *)", - description=( - 'Specified maximum cardinality for the element - a number or a "*". ' - "This is optional; if present, it acts an implicit check on the input " - "content (* just serves as documentation; it's the default value)." - ), - # if property is element of this resource. - element_property=True, - ) - max__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_max", title="Extension field for ``max``." - ) - - min: fhirtypes.Integer = Field( - None, - alias="min", - title="Specified minimum cardinality", - description=( - "Specified minimum cardinality for the element. This is optional; if " - "present, it acts an implicit check on the input content." - ), - # if property is element of this resource. - element_property=True, - ) - min__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_min", title="Extension field for ``min``." - ) - - type: fhirtypes.String = Field( - None, - alias="type", - title="Rule only applies if source has this type", - description=( - "Specified type for the element. This works as a condition on the " - "mapping - use for polymorphic elements." - ), - # if property is element of this resource. - element_property=True, - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - variable: fhirtypes.Id = Field( - None, - alias="variable", - title="Named context for field, if a field is specified", - description=None, - # if property is element of this resource. - element_property=True, - ) - variable__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_variable", title="Extension field for ``variable``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureMapGroupRuleSource`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "context", - "min", - "max", - "type", - "defaultValueBase64Binary", - "defaultValueBoolean", - "defaultValueCanonical", - "defaultValueCode", - "defaultValueDate", - "defaultValueDateTime", - "defaultValueDecimal", - "defaultValueId", - "defaultValueInstant", - "defaultValueInteger", - "defaultValueMarkdown", - "defaultValueOid", - "defaultValuePositiveInt", - "defaultValueString", - "defaultValueTime", - "defaultValueUnsignedInt", - "defaultValueUri", - "defaultValueUrl", - "defaultValueUuid", - "defaultValueAddress", - "defaultValueAge", - "defaultValueAnnotation", - "defaultValueAttachment", - "defaultValueCodeableConcept", - "defaultValueCoding", - "defaultValueContactPoint", - "defaultValueCount", - "defaultValueDistance", - "defaultValueDuration", - "defaultValueHumanName", - "defaultValueIdentifier", - "defaultValueMoney", - "defaultValuePeriod", - "defaultValueQuantity", - "defaultValueRange", - "defaultValueRatio", - "defaultValueReference", - "defaultValueSampledData", - "defaultValueSignature", - "defaultValueTiming", - "defaultValueContactDetail", - "defaultValueContributor", - "defaultValueDataRequirement", - "defaultValueExpression", - "defaultValueParameterDefinition", - "defaultValueRelatedArtifact", - "defaultValueTriggerDefinition", - "defaultValueUsageContext", - "defaultValueDosage", - "defaultValueMeta", - "element", - "listMode", - "variable", - "condition", - "check", - "logMessage", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3005( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("context", "context__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3005( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "defaultValue": [ - "defaultValueAddress", - "defaultValueAge", - "defaultValueAnnotation", - "defaultValueAttachment", - "defaultValueBase64Binary", - "defaultValueBoolean", - "defaultValueCanonical", - "defaultValueCode", - "defaultValueCodeableConcept", - "defaultValueCoding", - "defaultValueContactDetail", - "defaultValueContactPoint", - "defaultValueContributor", - "defaultValueCount", - "defaultValueDataRequirement", - "defaultValueDate", - "defaultValueDateTime", - "defaultValueDecimal", - "defaultValueDistance", - "defaultValueDosage", - "defaultValueDuration", - "defaultValueExpression", - "defaultValueHumanName", - "defaultValueId", - "defaultValueIdentifier", - "defaultValueInstant", - "defaultValueInteger", - "defaultValueMarkdown", - "defaultValueMeta", - "defaultValueMoney", - "defaultValueOid", - "defaultValueParameterDefinition", - "defaultValuePeriod", - "defaultValuePositiveInt", - "defaultValueQuantity", - "defaultValueRange", - "defaultValueRatio", - "defaultValueReference", - "defaultValueRelatedArtifact", - "defaultValueSampledData", - "defaultValueSignature", - "defaultValueString", - "defaultValueTime", - "defaultValueTiming", - "defaultValueTriggerDefinition", - "defaultValueUnsignedInt", - "defaultValueUri", - "defaultValueUrl", - "defaultValueUsageContext", - "defaultValueUuid", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class StructureMapGroupRuleTarget(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Content to create because of this mapping rule. - """ - - resource_type = Field("StructureMapGroupRuleTarget", const=True) - - context: fhirtypes.Id = Field( - None, - alias="context", - title="Type or variable this rule applies to", - description=None, - # if property is element of this resource. - element_property=True, - ) - context__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_context", title="Extension field for ``context``." - ) - - contextType: fhirtypes.Code = Field( - None, - alias="contextType", - title="type | variable", - description="How to interpret the context.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["type", "variable"], - ) - contextType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_contextType", title="Extension field for ``contextType``." - ) - - element: fhirtypes.String = Field( - None, - alias="element", - title="Field to create in the context", - description=None, - # if property is element of this resource. - element_property=True, - ) - element__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_element", title="Extension field for ``element``." - ) - - listMode: typing.List[fhirtypes.Code] = Field( - None, - alias="listMode", - title="first | share | last | collate", - description="If field is a list, how to manage the list.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["first", "share", "last", "collate"], - ) - listMode__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_listMode", title="Extension field for ``listMode``.") - - listRuleId: fhirtypes.Id = Field( - None, - alias="listRuleId", - title="Internal rule reference for shared list items", - description=None, - # if property is element of this resource. - element_property=True, - ) - listRuleId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_listRuleId", title="Extension field for ``listRuleId``." - ) - - parameter: typing.List[fhirtypes.StructureMapGroupRuleTargetParameterType] = Field( - None, - alias="parameter", - title="Parameters to the transform", - description=None, - # if property is element of this resource. - element_property=True, - ) - - transform: fhirtypes.Code = Field( - None, - alias="transform", - title="create | copy +", - description="How the data is copied / created.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["create", "copy", "+"], - ) - transform__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_transform", title="Extension field for ``transform``." - ) - - variable: fhirtypes.Id = Field( - None, - alias="variable", - title="Named context for field, if desired, and a field is specified", - description=None, - # if property is element of this resource. - element_property=True, - ) - variable__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_variable", title="Extension field for ``variable``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureMapGroupRuleTarget`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "context", - "contextType", - "element", - "variable", - "listMode", - "listRuleId", - "transform", - "parameter", - ] - - -class StructureMapGroupRuleTargetParameter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Parameters to the transform. - """ - - resource_type = Field("StructureMapGroupRuleTargetParameter", const=True) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Parameter value - variable or literal", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueDecimal: fhirtypes.Decimal = Field( - None, - alias="valueDecimal", - title="Parameter value - variable or literal", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDecimal", title="Extension field for ``valueDecimal``." - ) - - valueId: fhirtypes.Id = Field( - None, - alias="valueId", - title="Parameter value - variable or literal", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueId", title="Extension field for ``valueId``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Parameter value - variable or literal", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Parameter value - variable or literal", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureMapGroupRuleTargetParameter`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "valueId", - "valueString", - "valueBoolean", - "valueInteger", - "valueDecimal", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3937( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueBoolean", - "valueDecimal", - "valueId", - "valueInteger", - "valueString", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class StructureMapStructure(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Structure Definition used by this map. - A structure definition used by this map. The structure definition may - describe instances that are converted, or the instances that are produced. - """ - - resource_type = Field("StructureMapStructure", const=True) - - alias: fhirtypes.String = Field( - None, - alias="alias", - title="Name for type in this map", - description="The name used for this type in the map.", - # if property is element of this resource. - element_property=True, - ) - alias__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_alias", title="Extension field for ``alias``." - ) - - documentation: fhirtypes.String = Field( - None, - alias="documentation", - title="Documentation on use of structure", - description="Documentation that describes how the structure is used in the mapping.", - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - mode: fhirtypes.Code = Field( - None, - alias="mode", - title="source | queried | target | produced", - description="How the referenced structure is used in this mapping.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["source", "queried", "target", "produced"], - ) - mode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_mode", title="Extension field for ``mode``." - ) - - url: fhirtypes.Canonical = Field( - None, - alias="url", - title="Canonical reference to structure definition", - description="The canonical reference to the structure.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["StructureDefinition"], - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``StructureMapStructure`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "url", - "mode", - "alias", - "documentation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2424( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("mode", "mode__ext"), ("url", "url__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/subscription.py b/fhir/resources/subscription.py deleted file mode 100644 index 49465d26..00000000 --- a/fhir/resources/subscription.py +++ /dev/null @@ -1,362 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Subscription -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Subscription(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Server push subscription criteria. - The subscription resource is used to define a push-based subscription from - a server to another system. Once a subscription is registered with the - server, the server checks every resource that is created or updated, and if - the resource matches the given criteria, it sends a message on the defined - "channel" so that another system can take an appropriate action. - """ - - resource_type = Field("Subscription", const=True) - - channel: fhirtypes.SubscriptionChannelType = Field( - ..., - alias="channel", - title="The channel on which to report matches to the criteria", - description=( - "Details where to send notifications when resources are received that " - "meet the criteria." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactPointType] = Field( - None, - alias="contact", - title="Contact details for source (e.g. troubleshooting)", - description=( - "Contact details for a human to contact about the subscription. The " - "primary use of this for system administrator troubleshooting." - ), - # if property is element of this resource. - element_property=True, - ) - - criteria: fhirtypes.String = Field( - None, - alias="criteria", - title="Rule for server push", - description=( - "The rules that the server should use to determine when to generate " - "notifications for this subscription." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - criteria__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_criteria", title="Extension field for ``criteria``." - ) - - end: fhirtypes.Instant = Field( - None, - alias="end", - title="When to automatically delete the subscription", - description="The time for the server to turn the subscription off.", - # if property is element of this resource. - element_property=True, - ) - end__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_end", title="Extension field for ``end``." - ) - - error: fhirtypes.String = Field( - None, - alias="error", - title="Latest error note", - description=( - "A record of the last error that occurred when the server processed a " - "notification." - ), - # if property is element of this resource. - element_property=True, - ) - error__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_error", title="Extension field for ``error``." - ) - - reason: fhirtypes.String = Field( - None, - alias="reason", - title="Description of why this subscription was created", - description="A description of why this subscription is defined.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - reason__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_reason", title="Extension field for ``reason``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="requested | active | error | off", - description=( - "The status of the subscription, which marks the server state for " - "managing the subscription." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["requested", "active", "error", "off"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Subscription`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "status", - "contact", - "end", - "reason", - "criteria", - "error", - "channel", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1478( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("criteria", "criteria__ext"), - ("reason", "reason__ext"), - ("status", "status__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class SubscriptionChannel(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The channel on which to report matches to the criteria. - Details where to send notifications when resources are received that meet - the criteria. - """ - - resource_type = Field("SubscriptionChannel", const=True) - - endpoint: fhirtypes.Url = Field( - None, - alias="endpoint", - title="Where the channel points to", - description="The url that describes the actual end-point to send messages to.", - # if property is element of this resource. - element_property=True, - ) - endpoint__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_endpoint", title="Extension field for ``endpoint``." - ) - - header: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="header", - title="Usage depends on the channel type", - description="Additional headers / information to send as part of the notification.", - # if property is element of this resource. - element_property=True, - ) - header__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_header", title="Extension field for ``header``.") - - payload: fhirtypes.Code = Field( - None, - alias="payload", - title="MIME type to send, or omit for no payload", - description=( - "The mime type to send the payload in - either application/fhir+xml, or" - " application/fhir+json. If the payload is not present, then there is " - "no payload in the notification, just a notification. The mime type " - '"text/plain" may also be used for Email and SMS subscriptions.' - ), - # if property is element of this resource. - element_property=True, - ) - payload__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_payload", title="Extension field for ``payload``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="rest-hook | websocket | email | sms | message", - description="The type of channel to send notifications on.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["rest-hook", "websocket", "email", "sms", "message"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubscriptionChannel`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "endpoint", - "payload", - "header", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2173( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/substance.py b/fhir/resources/substance.py deleted file mode 100644 index b2044882..00000000 --- a/fhir/resources/substance.py +++ /dev/null @@ -1,295 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Substance -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class Substance(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A homogeneous material with a definite composition. - """ - - resource_type = Field("Substance", const=True) - - category: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="category", - title="What class/type of substance this is", - description=( - "A code that classifies the general type of substance. This is used " - "for searching, sorting and display purposes." - ), - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - ..., - alias="code", - title="What substance this is", - description="A code (or set of codes) that identify this substance.", - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Textual description of the substance, comments", - description=( - "A description of the substance - its appearance, handling " - "requirements, and other usage notes." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Unique identifier", - description="Unique identifier for the substance.", - # if property is element of this resource. - element_property=True, - ) - - ingredient: typing.List[fhirtypes.SubstanceIngredientType] = Field( - None, - alias="ingredient", - title="Composition information about the substance", - description="A substance can be composed of other substances.", - # if property is element of this resource. - element_property=True, - ) - - instance: typing.List[fhirtypes.SubstanceInstanceType] = Field( - None, - alias="instance", - title="If this describes a specific package/container of the substance", - description=( - "Substance may be used to describe a kind of substance, or a specific " - "package/container of the substance: an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | inactive | entered-in-error", - description="A code to indicate if the substance is actively used.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "inactive", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Substance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "category", - "code", - "description", - "instance", - "ingredient", - ] - - -class SubstanceIngredient(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Composition information about the substance. - A substance can be composed of other substances. - """ - - resource_type = Field("SubstanceIngredient", const=True) - - quantity: fhirtypes.RatioType = Field( - None, - alias="quantity", - title="Optional amount (concentration)", - description="The amount of the ingredient in the substance - a concentration ratio.", - # if property is element of this resource. - element_property=True, - ) - - substanceCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="substanceCodeableConcept", - title="A component of the substance", - description="Another substance that is a component of this substance.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e substance[x] - one_of_many="substance", - one_of_many_required=True, - ) - - substanceReference: fhirtypes.ReferenceType = Field( - None, - alias="substanceReference", - title="A component of the substance", - description="Another substance that is a component of this substance.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e substance[x] - one_of_many="substance", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Substance"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceIngredient`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "quantity", - "substanceCodeableConcept", - "substanceReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2168( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "substance": ["substanceCodeableConcept", "substanceReference"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class SubstanceInstance(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - If this describes a specific package/container of the substance. - Substance may be used to describe a kind of substance, or a specific - package/container of the substance: an instance. - """ - - resource_type = Field("SubstanceInstance", const=True) - - expiry: fhirtypes.DateTime = Field( - None, - alias="expiry", - title="When no longer valid to use", - description=( - "When the substance is no longer valid to use. For some substances, a " - "single arbitrary date is used for expiry." - ), - # if property is element of this resource. - element_property=True, - ) - expiry__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expiry", title="Extension field for ``expiry``." - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Identifier of the package/container", - description=( - "Identifier associated with the package/container (usually a label " - "affixed directly)." - ), - # if property is element of this resource. - element_property=True, - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Amount of substance in the package", - description="The amount of the substance.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceInstance`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "expiry", - "quantity", - ] diff --git a/fhir/resources/substanceamount.py b/fhir/resources/substanceamount.py deleted file mode 100644 index 454ef6ee..00000000 --- a/fhir/resources/substanceamount.py +++ /dev/null @@ -1,217 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SubstanceAmount -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, element, fhirtypes - - -class SubstanceAmount(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Chemical substances are a single substance type whose primary defining - element is the molecular structure. Chemical substances shall be defined on - the basis of their complete covalent molecular structure; the presence of a - salt (counter-ion) and/or solvates (water, alcohols) is also captured. - Purity, grade, physical form or particle size are not taken into account in - the definition of a chemical substance or in the assignment of a Substance - ID. - """ - - resource_type = Field("SubstanceAmount", const=True) - - amountQuantity: fhirtypes.QuantityType = Field( - None, - alias="amountQuantity", - title=( - "Used to capture quantitative values for a variety of elements. If only" - " limits are given, the arithmetic mean would be the average. If only a" - " single definite value for a given element is given, it would be " - "captured in this field" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - - amountRange: fhirtypes.RangeType = Field( - None, - alias="amountRange", - title=( - "Used to capture quantitative values for a variety of elements. If only" - " limits are given, the arithmetic mean would be the average. If only a" - " single definite value for a given element is given, it would be " - "captured in this field" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - - amountString: fhirtypes.String = Field( - None, - alias="amountString", - title=( - "Used to capture quantitative values for a variety of elements. If only" - " limits are given, the arithmetic mean would be the average. If only a" - " single definite value for a given element is given, it would be " - "captured in this field" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - amountString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_amountString", title="Extension field for ``amountString``." - ) - - amountText: fhirtypes.String = Field( - None, - alias="amountText", - title="A textual comment on a numeric value", - description=None, - # if property is element of this resource. - element_property=True, - ) - amountText__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_amountText", title="Extension field for ``amountText``." - ) - - amountType: fhirtypes.CodeableConceptType = Field( - None, - alias="amountType", - title=( - "Most elements that require a quantitative value will also have a field" - " called amount type. Amount type should always be specified because " - "the actual value of the amount is often dependent on it. EXAMPLE: In " - "capturing the actual relative amounts of substances or molecular " - "fragments it is essential to indicate whether the amount refers to a " - "mole ratio or weight ratio. For any given element an effort should be " - "made to use same the amount type for all related definitional elements" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - referenceRange: fhirtypes.SubstanceAmountReferenceRangeType = Field( - None, - alias="referenceRange", - title="Reference range of possible or expected values", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceAmount`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "amountQuantity", - "amountRange", - "amountString", - "amountType", - "amountText", - "referenceRange", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1763( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "amount": ["amountQuantity", "amountRange", "amountString"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class SubstanceAmountReferenceRange(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Reference range of possible or expected values. - """ - - resource_type = Field("SubstanceAmountReferenceRange", const=True) - - highLimit: fhirtypes.QuantityType = Field( - None, - alias="highLimit", - title="Upper limit possible or expected", - description=None, - # if property is element of this resource. - element_property=True, - ) - - lowLimit: fhirtypes.QuantityType = Field( - None, - alias="lowLimit", - title="Lower limit possible or expected", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceAmountReferenceRange`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "lowLimit", "highLimit"] diff --git a/fhir/resources/substancenucleicacid.py b/fhir/resources/substancenucleicacid.py deleted file mode 100644 index 755246a2..00000000 --- a/fhir/resources/substancenucleicacid.py +++ /dev/null @@ -1,408 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SubstanceNucleicAcid -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class SubstanceNucleicAcid(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Nucleic acids are defined by three distinct elements: the base, sugar and - linkage. Individual substance/moiety IDs will be created for each of these - elements. The nucleotide sequence will be always entered in the 5’-3’ - direction. - """ - - resource_type = Field("SubstanceNucleicAcid", const=True) - - areaOfHybridisation: fhirtypes.String = Field( - None, - alias="areaOfHybridisation", - title=( - "The area of hybridisation shall be described if applicable for double " - "stranded RNA or DNA. The number associated with the subunit followed " - "by the number associated to the residue shall be specified in " - "increasing order. The underscore \u201c\u201d shall be used as separator as " - "follows: \u201cSubunitnumber Residue\u201d" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - areaOfHybridisation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_areaOfHybridisation", - title="Extension field for ``areaOfHybridisation``.", - ) - - numberOfSubunits: fhirtypes.Integer = Field( - None, - alias="numberOfSubunits", - title=( - "The number of linear sequences of nucleotides linked through " - "phosphodiester bonds shall be described. Subunits would be strands of " - "nucleic acids that are tightly associated typically through Watson-" - "Crick base pairing. NOTE: If not specified in the reference source, " - "the assumption is that there is 1 subunit" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - numberOfSubunits__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_numberOfSubunits", - title="Extension field for ``numberOfSubunits``.", - ) - - oligoNucleotideType: fhirtypes.CodeableConceptType = Field( - None, - alias="oligoNucleotideType", - title="(TBC)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - sequenceType: fhirtypes.CodeableConceptType = Field( - None, - alias="sequenceType", - title=( - "The type of the sequence shall be specified based on a controlled " - "vocabulary" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - subunit: typing.List[fhirtypes.SubstanceNucleicAcidSubunitType] = Field( - None, - alias="subunit", - title=( - "Subunits are listed in order of decreasing length; sequences of the " - "same length will be ordered by molecular weight; subunits that have " - "identical sequences will be repeated multiple times" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceNucleicAcid`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "sequenceType", - "numberOfSubunits", - "areaOfHybridisation", - "oligoNucleotideType", - "subunit", - ] - - -class SubstanceNucleicAcidSubunit(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Subunits are listed in order of decreasing length; sequences of the same - length will be ordered by molecular weight; subunits that have identical - sequences will be repeated multiple times. - """ - - resource_type = Field("SubstanceNucleicAcidSubunit", const=True) - - fivePrime: fhirtypes.CodeableConceptType = Field( - None, - alias="fivePrime", - title=( - "The nucleotide present at the 5\u2019 terminal shall be specified based on " - "a controlled vocabulary. Since the sequence is represented from the 5'" - " to the 3' end, the 5\u2019 prime nucleotide is the letter at the first " - "position in the sequence. A separate representation would be redundant" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - length: fhirtypes.Integer = Field( - None, - alias="length", - title="The length of the sequence shall be captured", - description=None, - # if property is element of this resource. - element_property=True, - ) - length__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_length", title="Extension field for ``length``." - ) - - linkage: typing.List[fhirtypes.SubstanceNucleicAcidSubunitLinkageType] = Field( - None, - alias="linkage", - title="The linkages between sugar residues will also be captured", - description=None, - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.String = Field( - None, - alias="sequence", - title=( - "Actual nucleotide sequence notation from 5' to 3' end using standard " - "single letter codes. In addition to the base sequence, sugar and type " - "of phosphate or non-phosphate linkage should also be captured" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - sequenceAttachment: fhirtypes.AttachmentType = Field( - None, - alias="sequenceAttachment", - title="(TBC)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - subunit: fhirtypes.Integer = Field( - None, - alias="subunit", - title=( - "Index of linear sequences of nucleic acids in order of decreasing " - "length. Sequences of the same length will be ordered by molecular " - "weight. Subunits that have identical sequences will be repeated and " - "have sequential subscripts" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - subunit__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subunit", title="Extension field for ``subunit``." - ) - - sugar: typing.List[fhirtypes.SubstanceNucleicAcidSubunitSugarType] = Field( - None, - alias="sugar", - title="5.3.6.8.1 Sugar ID (Mandatory)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - threePrime: fhirtypes.CodeableConceptType = Field( - None, - alias="threePrime", - title=( - "The nucleotide present at the 3\u2019 terminal shall be specified based on " - "a controlled vocabulary. Since the sequence is represented from the 5'" - " to the 3' end, the 5\u2019 prime nucleotide is the letter at the last " - "position in the sequence. A separate representation would be redundant" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceNucleicAcidSubunit`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "subunit", - "sequence", - "length", - "sequenceAttachment", - "fivePrime", - "threePrime", - "linkage", - "sugar", - ] - - -class SubstanceNucleicAcidSubunitLinkage(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The linkages between sugar residues will also be captured. - """ - - resource_type = Field("SubstanceNucleicAcidSubunitLinkage", const=True) - - connectivity: fhirtypes.String = Field( - None, - alias="connectivity", - title=( - "The entity that links the sugar residues together should also be " - "captured for nearly all naturally occurring nucleic acid the linkage " - "is a phosphate group. For many synthetic oligonucleotides " - "phosphorothioate linkages are often seen. Linkage connectivity is " - "assumed to be 3\u2019-5\u2019. If the linkage is " - "either 3\u2019-3\u2019 or 5\u2019-5\u2019 this " - "should be specified" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - connectivity__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_connectivity", title="Extension field for ``connectivity``." - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Each linkage will be registered as a fragment and have an ID", - description=None, - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title=( - "Each linkage will be registered as a fragment and have at least one " - "name. A single name shall be assigned to each linkage" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - residueSite: fhirtypes.String = Field( - None, - alias="residueSite", - title="Residues shall be captured as described in 5.3.6.8.3", - description=None, - # if property is element of this resource. - element_property=True, - ) - residueSite__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_residueSite", title="Extension field for ``residueSite``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceNucleicAcidSubunitLinkage`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "connectivity", - "identifier", - "name", - "residueSite", - ] - - -class SubstanceNucleicAcidSubunitSugar(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - 5.3.6.8.1 Sugar ID (Mandatory). - """ - - resource_type = Field("SubstanceNucleicAcidSubunitSugar", const=True) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title=( - "The Substance ID of the sugar or sugar-like component that make up the" - " nucleotide" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title=( - "The name of the sugar or sugar-like component that make up the " - "nucleotide" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - residueSite: fhirtypes.String = Field( - None, - alias="residueSite", - title=( - "The residues that contain a given sugar will be captured. The order of" - " given residues will be captured in the 5\u2018-3\u2018direction consistent with" - " the base sequences listed above" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - residueSite__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_residueSite", title="Extension field for ``residueSite``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceNucleicAcidSubunitSugar`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "name", - "residueSite", - ] diff --git a/fhir/resources/substancepolymer.py b/fhir/resources/substancepolymer.py deleted file mode 100644 index bc7614f7..00000000 --- a/fhir/resources/substancepolymer.py +++ /dev/null @@ -1,463 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SubstancePolymer -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class SubstancePolymer(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field("SubstancePolymer", const=True) - - class_fhir: fhirtypes.CodeableConceptType = Field( - None, - alias="class", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - copolymerConnectivity: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="copolymerConnectivity", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - geometry: fhirtypes.CodeableConceptType = Field( - None, - alias="geometry", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - modification: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="modification", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - modification__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_modification", title="Extension field for ``modification``." - ) - - monomerSet: typing.List[fhirtypes.SubstancePolymerMonomerSetType] = Field( - None, - alias="monomerSet", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - repeat: typing.List[fhirtypes.SubstancePolymerRepeatType] = Field( - None, - alias="repeat", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstancePolymer`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "class", - "geometry", - "copolymerConnectivity", - "modification", - "monomerSet", - "repeat", - ] - - -class SubstancePolymerMonomerSet(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field("SubstancePolymerMonomerSet", const=True) - - ratioType: fhirtypes.CodeableConceptType = Field( - None, - alias="ratioType", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - startingMaterial: typing.List[ - fhirtypes.SubstancePolymerMonomerSetStartingMaterialType - ] = Field( - None, - alias="startingMaterial", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstancePolymerMonomerSet`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "ratioType", "startingMaterial"] - - -class SubstancePolymerMonomerSetStartingMaterial(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field("SubstancePolymerMonomerSetStartingMaterial", const=True) - - amount: fhirtypes.SubstanceAmountType = Field( - None, - alias="amount", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - isDefining: bool = Field( - None, - alias="isDefining", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - isDefining__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_isDefining", title="Extension field for ``isDefining``." - ) - - material: fhirtypes.CodeableConceptType = Field( - None, - alias="material", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstancePolymerMonomerSetStartingMaterial`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "material", - "type", - "isDefining", - "amount", - ] - - -class SubstancePolymerRepeat(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field("SubstancePolymerRepeat", const=True) - - averageMolecularFormula: fhirtypes.String = Field( - None, - alias="averageMolecularFormula", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - averageMolecularFormula__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_averageMolecularFormula", - title="Extension field for ``averageMolecularFormula``.", - ) - - numberOfUnits: fhirtypes.Integer = Field( - None, - alias="numberOfUnits", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - numberOfUnits__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_numberOfUnits", title="Extension field for ``numberOfUnits``." - ) - - repeatUnit: typing.List[fhirtypes.SubstancePolymerRepeatRepeatUnitType] = Field( - None, - alias="repeatUnit", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - repeatUnitAmountType: fhirtypes.CodeableConceptType = Field( - None, - alias="repeatUnitAmountType", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstancePolymerRepeat`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "numberOfUnits", - "averageMolecularFormula", - "repeatUnitAmountType", - "repeatUnit", - ] - - -class SubstancePolymerRepeatRepeatUnit(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field("SubstancePolymerRepeatRepeatUnit", const=True) - - amount: fhirtypes.SubstanceAmountType = Field( - None, - alias="amount", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - degreeOfPolymerisation: typing.List[ - fhirtypes.SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisationType - ] = Field( - None, - alias="degreeOfPolymerisation", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - orientationOfPolymerisation: fhirtypes.CodeableConceptType = Field( - None, - alias="orientationOfPolymerisation", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - repeatUnit: fhirtypes.String = Field( - None, - alias="repeatUnit", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - repeatUnit__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_repeatUnit", title="Extension field for ``repeatUnit``." - ) - - structuralRepresentation: typing.List[ - fhirtypes.SubstancePolymerRepeatRepeatUnitStructuralRepresentationType - ] = Field( - None, - alias="structuralRepresentation", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstancePolymerRepeatRepeatUnit`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "orientationOfPolymerisation", - "repeatUnit", - "amount", - "degreeOfPolymerisation", - "structuralRepresentation", - ] - - -class SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisation( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field( - "SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisation", const=True - ) - - amount: fhirtypes.SubstanceAmountType = Field( - None, - alias="amount", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - degree: fhirtypes.CodeableConceptType = Field( - None, - alias="degree", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstancePolymerRepeatRepeatUnitDegreeOfPolymerisation`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "degree", "amount"] - - -class SubstancePolymerRepeatRepeatUnitStructuralRepresentation( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field( - "SubstancePolymerRepeatRepeatUnitStructuralRepresentation", const=True - ) - - attachment: fhirtypes.AttachmentType = Field( - None, - alias="attachment", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - representation: fhirtypes.String = Field( - None, - alias="representation", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - representation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_representation", title="Extension field for ``representation``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstancePolymerRepeatRepeatUnitStructuralRepresentation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "representation", - "attachment", - ] diff --git a/fhir/resources/substanceprotein.py b/fhir/resources/substanceprotein.py deleted file mode 100644 index 710a60eb..00000000 --- a/fhir/resources/substanceprotein.py +++ /dev/null @@ -1,287 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SubstanceProtein -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class SubstanceProtein(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A SubstanceProtein is defined as a single unit of a linear amino acid - sequence, or a combination of subunits that are either covalently linked or - have a defined invariant stoichiometric relationship. This includes all - synthetic, recombinant and purified SubstanceProteins of defined sequence, - whether the use is therapeutic or prophylactic. This set of elements will - be used to describe albumins, coagulation factors, cytokines, growth - factors, peptide/SubstanceProtein hormones, enzymes, toxins, toxoids, - recombinant vaccines, and immunomodulators. - """ - - resource_type = Field("SubstanceProtein", const=True) - - disulfideLinkage: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="disulfideLinkage", - title=( - "The disulphide bond between two cysteine residues either on the same " - "subunit or on two different subunits shall be described. The position " - "of the disulfide bonds in the SubstanceProtein shall be listed in " - "increasing order of subunit number and position within subunit " - "followed by the abbreviation of the amino acids involved. The " - "disulfide linkage positions shall actually contain the amino acid " - "Cysteine at the respective positions" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - disulfideLinkage__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_disulfideLinkage", - title="Extension field for ``disulfideLinkage``.", - ) - - numberOfSubunits: fhirtypes.Integer = Field( - None, - alias="numberOfSubunits", - title=( - "Number of linear sequences of amino acids linked through peptide " - "bonds. The number of subunits constituting the SubstanceProtein shall " - "be described. It is possible that the number of subunits can be " - "variable" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - numberOfSubunits__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_numberOfSubunits", - title="Extension field for ``numberOfSubunits``.", - ) - - sequenceType: fhirtypes.CodeableConceptType = Field( - None, - alias="sequenceType", - title=( - "The SubstanceProtein descriptive elements will only be used when a " - "complete or partial amino acid sequence is available or derivable from" - " a nucleic acid sequence" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - subunit: typing.List[fhirtypes.SubstanceProteinSubunitType] = Field( - None, - alias="subunit", - title=( - "This subclause refers to the description of each subunit constituting " - "the SubstanceProtein. A subunit is a linear sequence of amino acids " - "linked through peptide bonds. The Subunit information shall be " - "provided when the finished SubstanceProtein is a complex of multiple " - "sequences; subunits are not used to delineate domains within a single " - "sequence. Subunits are listed in order of decreasing length; sequences" - " of the same length will be ordered by decreasing molecular weight; " - "subunits that have identical sequences will be repeated multiple times" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceProtein`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "sequenceType", - "numberOfSubunits", - "disulfideLinkage", - "subunit", - ] - - -class SubstanceProteinSubunit(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - This subclause refers to the description of each subunit constituting the - SubstanceProtein. A subunit is a linear sequence of amino acids linked - through peptide bonds. The Subunit information shall be provided when the - finished SubstanceProtein is a complex of multiple sequences; subunits are - not used to delineate domains within a single sequence. Subunits are listed - in order of decreasing length; sequences of the same length will be ordered - by decreasing molecular weight; subunits that have identical sequences will - be repeated multiple times. - """ - - resource_type = Field("SubstanceProteinSubunit", const=True) - - cTerminalModification: fhirtypes.String = Field( - None, - alias="cTerminalModification", - title="The modification at the C-terminal shall be specified", - description=None, - # if property is element of this resource. - element_property=True, - ) - cTerminalModification__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_cTerminalModification", - title="Extension field for ``cTerminalModification``.", - ) - - cTerminalModificationId: fhirtypes.IdentifierType = Field( - None, - alias="cTerminalModificationId", - title=( - "Unique identifier for molecular fragment modification based on the ISO" - " 11238 Substance ID" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - length: fhirtypes.Integer = Field( - None, - alias="length", - title="Length of linear sequences of amino acids contained in the subunit", - description=None, - # if property is element of this resource. - element_property=True, - ) - length__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_length", title="Extension field for ``length``." - ) - - nTerminalModification: fhirtypes.String = Field( - None, - alias="nTerminalModification", - title=( - "The name of the fragment modified at the N-terminal of the " - "SubstanceProtein shall be specified" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - nTerminalModification__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_nTerminalModification", - title="Extension field for ``nTerminalModification``.", - ) - - nTerminalModificationId: fhirtypes.IdentifierType = Field( - None, - alias="nTerminalModificationId", - title=( - "Unique identifier for molecular fragment modification based on the ISO" - " 11238 Substance ID" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - sequence: fhirtypes.String = Field( - None, - alias="sequence", - title=( - "The sequence information shall be provided enumerating the amino acids" - " from N- to C-terminal end using standard single-letter amino acid " - "codes. Uppercase shall be used for L-amino acids and lowercase for " - "D-amino acids. Transcribed SubstanceProteins will always be described " - "using the translated sequence; for synthetic peptide containing amino " - "acids that are not represented with a single letter code an X should " - "be used within the sequence. The modified amino acids will be " - "distinguished by their position in the sequence" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - sequence__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sequence", title="Extension field for ``sequence``." - ) - - sequenceAttachment: fhirtypes.AttachmentType = Field( - None, - alias="sequenceAttachment", - title=( - "The sequence information shall be provided enumerating the amino acids" - " from N- to C-terminal end using standard single-letter amino acid " - "codes. Uppercase shall be used for L-amino acids and lowercase for " - "D-amino acids. Transcribed SubstanceProteins will always be described " - "using the translated sequence; for synthetic peptide containing amino " - "acids that are not represented with a single letter code an X should " - "be used within the sequence. The modified amino acids will be " - "distinguished by their position in the sequence" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - subunit: fhirtypes.Integer = Field( - None, - alias="subunit", - title=( - "Index of primary sequences of amino acids linked through peptide bonds" - " in order of decreasing length. Sequences of the same length will be " - "ordered by molecular weight. Subunits that have identical sequences " - "will be repeated and have sequential subscripts" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - subunit__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subunit", title="Extension field for ``subunit``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceProteinSubunit`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "subunit", - "sequence", - "length", - "sequenceAttachment", - "nTerminalModificationId", - "nTerminalModification", - "cTerminalModificationId", - "cTerminalModification", - ] diff --git a/fhir/resources/substancereferenceinformation.py b/fhir/resources/substancereferenceinformation.py deleted file mode 100644 index c3b82cb8..00000000 --- a/fhir/resources/substancereferenceinformation.py +++ /dev/null @@ -1,443 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SubstanceReferenceInformation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class SubstanceReferenceInformation(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field("SubstanceReferenceInformation", const=True) - - classification: typing.List[ - fhirtypes.SubstanceReferenceInformationClassificationType - ] = Field( - None, - alias="classification", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - gene: typing.List[fhirtypes.SubstanceReferenceInformationGeneType] = Field( - None, - alias="gene", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - geneElement: typing.List[ - fhirtypes.SubstanceReferenceInformationGeneElementType - ] = Field( - None, - alias="geneElement", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - target: typing.List[fhirtypes.SubstanceReferenceInformationTargetType] = Field( - None, - alias="target", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceReferenceInformation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "comment", - "gene", - "geneElement", - "classification", - "target", - ] - - -class SubstanceReferenceInformationClassification(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field("SubstanceReferenceInformationClassification", const=True) - - classification: fhirtypes.CodeableConceptType = Field( - None, - alias="classification", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - domain: fhirtypes.CodeableConceptType = Field( - None, - alias="domain", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - source: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="source", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - subtype: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="subtype", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceReferenceInformationClassification`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "domain", - "classification", - "subtype", - "source", - ] - - -class SubstanceReferenceInformationGene(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field("SubstanceReferenceInformationGene", const=True) - - gene: fhirtypes.CodeableConceptType = Field( - None, - alias="gene", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - geneSequenceOrigin: fhirtypes.CodeableConceptType = Field( - None, - alias="geneSequenceOrigin", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - source: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="source", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceReferenceInformationGene`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "geneSequenceOrigin", - "gene", - "source", - ] - - -class SubstanceReferenceInformationGeneElement(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field("SubstanceReferenceInformationGeneElement", const=True) - - element: fhirtypes.IdentifierType = Field( - None, - alias="element", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - source: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="source", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceReferenceInformationGeneElement`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "element", "source"] - - -class SubstanceReferenceInformationTarget(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Todo. - """ - - resource_type = Field("SubstanceReferenceInformationTarget", const=True) - - amountQuantity: fhirtypes.QuantityType = Field( - None, - alias="amountQuantity", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - - amountRange: fhirtypes.RangeType = Field( - None, - alias="amountRange", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - - amountString: fhirtypes.String = Field( - None, - alias="amountString", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - amountString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_amountString", title="Extension field for ``amountString``." - ) - - amountType: fhirtypes.CodeableConceptType = Field( - None, - alias="amountType", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - interaction: fhirtypes.CodeableConceptType = Field( - None, - alias="interaction", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - organism: fhirtypes.CodeableConceptType = Field( - None, - alias="organism", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - organismType: fhirtypes.CodeableConceptType = Field( - None, - alias="organismType", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - source: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="source", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - target: fhirtypes.IdentifierType = Field( - None, - alias="target", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Todo", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceReferenceInformationTarget`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "target", - "type", - "interaction", - "organism", - "organismType", - "amountQuantity", - "amountRange", - "amountString", - "amountType", - "source", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3819( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "amount": ["amountQuantity", "amountRange", "amountString"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/substancesourcematerial.py b/fhir/resources/substancesourcematerial.py deleted file mode 100644 index c45a6960..00000000 --- a/fhir/resources/substancesourcematerial.py +++ /dev/null @@ -1,701 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SubstanceSourceMaterial -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field - -from . import backboneelement, domainresource, fhirtypes - - -class SubstanceSourceMaterial(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Source material shall capture information on the taxonomic and anatomical - origins as well as the fraction of a material that can result in or can be - modified to form a substance. This set of data elements shall be used to - define polymer substances isolated from biological matrices. Taxonomic and - anatomical origins shall be described using a controlled vocabulary as - required. This information is captured for naturally derived polymers ( . - starch) and structurally diverse substances. For Organisms belonging to the - Kingdom Plantae the Substance level defines the fresh material of a single - species or infraspecies, the Herbal Drug and the Herbal preparation. For - Herbal preparations, the fraction information will be captured at the - Substance information level and additional information for herbal extracts - will be captured at the Specified Substance Group 1 information level. See - for further explanation the Substance Class: Structurally Diverse and the - herbal annex. - """ - - resource_type = Field("SubstanceSourceMaterial", const=True) - - countryOfOrigin: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="countryOfOrigin", - title=( - "The country where the plant material is harvested or the countries " - "where the plasma is sourced from as laid down in accordance with the " - "Plasma Master File. For \u201cPlasma-derived substances\u201d the attribute " - "country of origin provides information about the countries used for " - "the manufacturing of the Cryopoor plama or Crioprecipitate" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - developmentStage: fhirtypes.CodeableConceptType = Field( - None, - alias="developmentStage", - title=( - "Stage of life for animals, plants, insects and microorganisms. This " - "information shall be provided only when the substance is significantly" - " different in these stages (e.g. foetal bovine serum)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - fractionDescription: typing.List[ - fhirtypes.SubstanceSourceMaterialFractionDescriptionType - ] = Field( - None, - alias="fractionDescription", - title=( - "Many complex materials are fractions of parts of plants, animals, or " - "minerals. Fraction elements are often necessary to define both " - "Substances and Specified Group 1 Substances. For substances derived " - "from Plants, fraction information will be captured at the Substance " - "information level ( . Oils, Juices and Exudates). Additional " - "information for Extracts, such as extraction solvent composition, will" - " be captured at the Specified Substance Group 1 information level. For" - " plasma-derived products fraction information will be captured at the " - "Substance and the Specified Substance Group 1 levels" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - geographicalLocation: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="geographicalLocation", - title=( - "The place/region where the plant is harvested or the places/regions " - "where the animal source material has its habitat" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - geographicalLocation__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_geographicalLocation", - title="Extension field for ``geographicalLocation``.", - ) - - organism: fhirtypes.SubstanceSourceMaterialOrganismType = Field( - None, - alias="organism", - title=( - "This subclause describes the organism which the substance is derived " - "from. For vaccines, the parent organism shall be specified based on " - "these subclause elements. As an example, full taxonomy will be " - "described for the Substance Name: ., Leaf" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - organismId: fhirtypes.IdentifierType = Field( - None, - alias="organismId", - title=( - "The unique identifier associated with the source material parent " - "organism shall be specified" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - organismName: fhirtypes.String = Field( - None, - alias="organismName", - title=( - "The organism accepted Scientific name shall be provided based on the " - "organism taxonomy" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - organismName__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_organismName", title="Extension field for ``organismName``." - ) - - parentSubstanceId: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="parentSubstanceId", - title=( - "The parent of the herbal drug Ginkgo biloba, Leaf is the substance ID " - "of the substance (fresh) of Ginkgo biloba L. or Ginkgo biloba L. " - "(Whole plant)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - parentSubstanceName: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="parentSubstanceName", - title="The parent substance of the Herbal Drug, or Herbal preparation", - description=None, - # if property is element of this resource. - element_property=True, - ) - parentSubstanceName__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, - alias="_parentSubstanceName", - title="Extension field for ``parentSubstanceName``.", - ) - - partDescription: typing.List[ - fhirtypes.SubstanceSourceMaterialPartDescriptionType - ] = Field( - None, - alias="partDescription", - title="To do", - description=None, - # if property is element of this resource. - element_property=True, - ) - - sourceMaterialClass: fhirtypes.CodeableConceptType = Field( - None, - alias="sourceMaterialClass", - title=( - "General high level classification of the source material specific to " - "the origin of the material" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - sourceMaterialState: fhirtypes.CodeableConceptType = Field( - None, - alias="sourceMaterialState", - title="The state of the source material when extracted", - description=None, - # if property is element of this resource. - element_property=True, - ) - - sourceMaterialType: fhirtypes.CodeableConceptType = Field( - None, - alias="sourceMaterialType", - title=( - "The type of the source material shall be specified based on a " - "controlled vocabulary. For vaccines, this subclause refers to the " - "class of infectious agent" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSourceMaterial`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "sourceMaterialClass", - "sourceMaterialType", - "sourceMaterialState", - "organismId", - "organismName", - "parentSubstanceId", - "parentSubstanceName", - "countryOfOrigin", - "geographicalLocation", - "developmentStage", - "fractionDescription", - "organism", - "partDescription", - ] - - -class SubstanceSourceMaterialFractionDescription(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Many complex materials are fractions of parts of plants, animals, or - minerals. Fraction elements are often necessary to define both Substances - and Specified Group 1 Substances. For substances derived from Plants, - fraction information will be captured at the Substance information level ( - . Oils, Juices and Exudates). Additional information for Extracts, such as - extraction solvent composition, will be captured at the Specified Substance - Group 1 information level. For plasma-derived products fraction information - will be captured at the Substance and the Specified Substance Group 1 - levels. - """ - - resource_type = Field("SubstanceSourceMaterialFractionDescription", const=True) - - fraction: fhirtypes.String = Field( - None, - alias="fraction", - title=( - "This element is capturing information about the fraction of a plant " - "part, or human plasma for fractionation" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - fraction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_fraction", title="Extension field for ``fraction``." - ) - - materialType: fhirtypes.CodeableConceptType = Field( - None, - alias="materialType", - title=( - "The specific type of the material constituting the component. For " - "Herbal preparations the particulars of the extracts (liquid/dry) is " - "described in Specified Substance Group 1" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSourceMaterialFractionDescription`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "fraction", "materialType"] - - -class SubstanceSourceMaterialOrganism(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - This subclause describes the organism which the substance is derived from. - For vaccines, the parent organism shall be specified based on these - subclause elements. As an example, full taxonomy will be described for the - Substance Name: ., Leaf. - """ - - resource_type = Field("SubstanceSourceMaterialOrganism", const=True) - - author: typing.List[fhirtypes.SubstanceSourceMaterialOrganismAuthorType] = Field( - None, - alias="author", - title="4.9.13.6.1 Author type (Conditional)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - family: fhirtypes.CodeableConceptType = Field( - None, - alias="family", - title="The family of an organism shall be specified", - description=None, - # if property is element of this resource. - element_property=True, - ) - - genus: fhirtypes.CodeableConceptType = Field( - None, - alias="genus", - title=( - "The genus of an organism shall be specified; refers to the Latin " - "epithet of the genus element of the plant/animal scientific name; it " - "is present in names for genera, species and infraspecies" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - hybrid: fhirtypes.SubstanceSourceMaterialOrganismHybridType = Field( - None, - alias="hybrid", - title="4.9.13.8.1 Hybrid species maternal organism ID (Optional)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - intraspecificDescription: fhirtypes.String = Field( - None, - alias="intraspecificDescription", - title=( - "The intraspecific description of an organism shall be specified based " - "on a controlled vocabulary. For Influenza Vaccine, the intraspecific " - "description shall contain the syntax of the antigen in line with the " - "WHO convention" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - intraspecificDescription__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_intraspecificDescription", - title="Extension field for ``intraspecificDescription``.", - ) - - intraspecificType: fhirtypes.CodeableConceptType = Field( - None, - alias="intraspecificType", - title="The Intraspecific type of an organism shall be specified", - description=None, - # if property is element of this resource. - element_property=True, - ) - - organismGeneral: fhirtypes.SubstanceSourceMaterialOrganismOrganismGeneralType = Field( - None, - alias="organismGeneral", - title="4.9.13.7.1 Kingdom (Conditional)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - species: fhirtypes.CodeableConceptType = Field( - None, - alias="species", - title=( - "The species of an organism shall be specified; refers to the Latin " - "epithet of the species of the plant/animal; it is present in names for" - " species and infraspecies" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSourceMaterialOrganism`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "family", - "genus", - "species", - "intraspecificType", - "intraspecificDescription", - "author", - "hybrid", - "organismGeneral", - ] - - -class SubstanceSourceMaterialOrganismAuthor(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - 4.9.13.6.1 Author type (Conditional). - """ - - resource_type = Field("SubstanceSourceMaterialOrganismAuthor", const=True) - - authorDescription: fhirtypes.String = Field( - None, - alias="authorDescription", - title=( - "The author of an organism species shall be specified. The author year " - "of an organism shall also be specified when applicable; refers to the " - "year in which the first author(s) published the infraspecific " - "plant/animal name (of any rank)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - authorDescription__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_authorDescription", - title="Extension field for ``authorDescription``.", - ) - - authorType: fhirtypes.CodeableConceptType = Field( - None, - alias="authorType", - title=( - "The type of author of an organism species shall be specified. The " - "parenthetical author of an organism species refers to the first author" - " who published the plant/animal name (of any rank). The primary author" - " of an organism species refers to the first author(s), who validly " - "published the plant/animal name" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSourceMaterialOrganismAuthor`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "authorType", - "authorDescription", - ] - - -class SubstanceSourceMaterialOrganismHybrid(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - 4.9.13.8.1 Hybrid species maternal organism ID (Optional). - """ - - resource_type = Field("SubstanceSourceMaterialOrganismHybrid", const=True) - - hybridType: fhirtypes.CodeableConceptType = Field( - None, - alias="hybridType", - title="The hybrid type of an organism shall be specified", - description=None, - # if property is element of this resource. - element_property=True, - ) - - maternalOrganismId: fhirtypes.String = Field( - None, - alias="maternalOrganismId", - title=( - "The identifier of the maternal species constituting the hybrid " - "organism shall be specified based on a controlled vocabulary. For " - "plants, the parents aren\u2019t always known, and it is unlikely that it " - "will be known which is maternal and which is paternal" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - maternalOrganismId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_maternalOrganismId", - title="Extension field for ``maternalOrganismId``.", - ) - - maternalOrganismName: fhirtypes.String = Field( - None, - alias="maternalOrganismName", - title=( - "The name of the maternal species constituting the hybrid organism " - "shall be specified. For plants, the parents aren\u2019t always known, and " - "it is unlikely that it will be known which is maternal and which is " - "paternal" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - maternalOrganismName__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_maternalOrganismName", - title="Extension field for ``maternalOrganismName``.", - ) - - paternalOrganismId: fhirtypes.String = Field( - None, - alias="paternalOrganismId", - title=( - "The identifier of the paternal species constituting the hybrid " - "organism shall be specified based on a controlled vocabulary" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - paternalOrganismId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_paternalOrganismId", - title="Extension field for ``paternalOrganismId``.", - ) - - paternalOrganismName: fhirtypes.String = Field( - None, - alias="paternalOrganismName", - title=( - "The name of the paternal species constituting the hybrid organism " - "shall be specified" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - paternalOrganismName__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_paternalOrganismName", - title="Extension field for ``paternalOrganismName``.", - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSourceMaterialOrganismHybrid`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "maternalOrganismId", - "maternalOrganismName", - "paternalOrganismId", - "paternalOrganismName", - "hybridType", - ] - - -class SubstanceSourceMaterialOrganismOrganismGeneral(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - 4.9.13.7.1 Kingdom (Conditional). - """ - - resource_type = Field("SubstanceSourceMaterialOrganismOrganismGeneral", const=True) - - class_fhir: fhirtypes.CodeableConceptType = Field( - None, - alias="class", - title="The class of an organism shall be specified", - description=None, - # if property is element of this resource. - element_property=True, - ) - - kingdom: fhirtypes.CodeableConceptType = Field( - None, - alias="kingdom", - title="The kingdom of an organism shall be specified", - description=None, - # if property is element of this resource. - element_property=True, - ) - - order: fhirtypes.CodeableConceptType = Field( - None, - alias="order", - title="The order of an organism shall be specified,", - description=None, - # if property is element of this resource. - element_property=True, - ) - - phylum: fhirtypes.CodeableConceptType = Field( - None, - alias="phylum", - title="The phylum of an organism shall be specified", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSourceMaterialOrganismOrganismGeneral`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "kingdom", - "phylum", - "class", - "order", - ] - - -class SubstanceSourceMaterialPartDescription(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - To do. - """ - - resource_type = Field("SubstanceSourceMaterialPartDescription", const=True) - - part: fhirtypes.CodeableConceptType = Field( - None, - alias="part", - title="Entity of anatomical origin of source material within an organism", - description=None, - # if property is element of this resource. - element_property=True, - ) - - partLocation: fhirtypes.CodeableConceptType = Field( - None, - alias="partLocation", - title=( - "The detailed anatomic location when the part can be extracted from " - "different anatomical locations of the organism. Multiple alternative " - "locations may apply" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSourceMaterialPartDescription`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "part", "partLocation"] diff --git a/fhir/resources/substancespecification.py b/fhir/resources/substancespecification.py deleted file mode 100644 index fddb619d..00000000 --- a/fhir/resources/substancespecification.py +++ /dev/null @@ -1,1477 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SubstanceSpecification -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class SubstanceSpecification(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The detailed description of a substance, typically at a level beyond what - is used for prescribing. - """ - - resource_type = Field("SubstanceSpecification", const=True) - - code: typing.List[fhirtypes.SubstanceSpecificationCodeType] = Field( - None, - alias="code", - title="Codes associated with the substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Textual comment about this record of a substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Textual description of the substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - domain: fhirtypes.CodeableConceptType = Field( - None, - alias="domain", - title="If the substance applies to only human or veterinary use", - description=None, - # if property is element of this resource. - element_property=True, - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Identifier by which this substance is known", - description=None, - # if property is element of this resource. - element_property=True, - ) - - moiety: typing.List[fhirtypes.SubstanceSpecificationMoietyType] = Field( - None, - alias="moiety", - title="Moiety, for structural modifications", - description=None, - # if property is element of this resource. - element_property=True, - ) - - molecularWeight: typing.List[ - fhirtypes.SubstanceSpecificationStructureIsotopeMolecularWeightType - ] = Field( - None, - alias="molecularWeight", - title=( - "The molecular weight or weight range (for proteins, polymers or " - "nucleic acids)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - name: typing.List[fhirtypes.SubstanceSpecificationNameType] = Field( - None, - alias="name", - title="Names applicable to this substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - - nucleicAcid: fhirtypes.ReferenceType = Field( - None, - alias="nucleicAcid", - title="Data items specific to nucleic acids", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SubstanceNucleicAcid"], - ) - - polymer: fhirtypes.ReferenceType = Field( - None, - alias="polymer", - title="Data items specific to polymers", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SubstancePolymer"], - ) - - property: typing.List[fhirtypes.SubstanceSpecificationPropertyType] = Field( - None, - alias="property", - title=( - "General specifications for this substance, including how it is related" - " to other substances" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - protein: fhirtypes.ReferenceType = Field( - None, - alias="protein", - title="Data items specific to proteins", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SubstanceProtein"], - ) - - referenceInformation: fhirtypes.ReferenceType = Field( - None, - alias="referenceInformation", - title="General information detailing this substance", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SubstanceReferenceInformation"], - ) - - relationship: typing.List[fhirtypes.SubstanceSpecificationRelationshipType] = Field( - None, - alias="relationship", - title=( - "A link between this substance and another, with details of the " - "relationship" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - source: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="source", - title="Supporting literature", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - sourceMaterial: fhirtypes.ReferenceType = Field( - None, - alias="sourceMaterial", - title="Material or taxonomic/anatomical source for the substance", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SubstanceSourceMaterial"], - ) - - status: fhirtypes.CodeableConceptType = Field( - None, - alias="status", - title="Status of substance within the catalogue e.g. approved", - description=None, - # if property is element of this resource. - element_property=True, - ) - - structure: fhirtypes.SubstanceSpecificationStructureType = Field( - None, - alias="structure", - title="Structural information", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="High level categorization, e.g. polymer or nucleic acid", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSpecification`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "type", - "status", - "domain", - "description", - "source", - "comment", - "moiety", - "property", - "referenceInformation", - "structure", - "code", - "name", - "molecularWeight", - "relationship", - "nucleicAcid", - "polymer", - "protein", - "sourceMaterial", - ] - - -class SubstanceSpecificationCode(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Codes associated with the substance. - """ - - resource_type = Field("SubstanceSpecificationCode", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="The specific code", - description=None, - # if property is element of this resource. - element_property=True, - ) - - comment: fhirtypes.String = Field( - None, - alias="comment", - title="Any comment can be provided in this field, if necessary", - description=None, - # if property is element of this resource. - element_property=True, - ) - comment__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_comment", title="Extension field for ``comment``." - ) - - source: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="source", - title="Supporting literature", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - status: fhirtypes.CodeableConceptType = Field( - None, - alias="status", - title="Status of the code assignment", - description=None, - # if property is element of this resource. - element_property=True, - ) - - statusDate: fhirtypes.DateTime = Field( - None, - alias="statusDate", - title=( - "The date at which the code status is changed as part of the " - "terminology maintenance" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - statusDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_statusDate", title="Extension field for ``statusDate``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSpecificationCode`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "status", - "statusDate", - "comment", - "source", - ] - - -class SubstanceSpecificationMoiety(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Moiety, for structural modifications. - """ - - resource_type = Field("SubstanceSpecificationMoiety", const=True) - - amountQuantity: fhirtypes.QuantityType = Field( - None, - alias="amountQuantity", - title="Quantitative value for this moiety", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - - amountString: fhirtypes.String = Field( - None, - alias="amountString", - title="Quantitative value for this moiety", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - amountString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_amountString", title="Extension field for ``amountString``." - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Identifier by which this moiety substance is known", - description=None, - # if property is element of this resource. - element_property=True, - ) - - molecularFormula: fhirtypes.String = Field( - None, - alias="molecularFormula", - title="Molecular formula", - description=None, - # if property is element of this resource. - element_property=True, - ) - molecularFormula__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_molecularFormula", - title="Extension field for ``molecularFormula``.", - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Textual name for this moiety substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - opticalActivity: fhirtypes.CodeableConceptType = Field( - None, - alias="opticalActivity", - title="Optical activity type", - description=None, - # if property is element of this resource. - element_property=True, - ) - - role: fhirtypes.CodeableConceptType = Field( - None, - alias="role", - title="Role that the moiety is playing", - description=None, - # if property is element of this resource. - element_property=True, - ) - - stereochemistry: fhirtypes.CodeableConceptType = Field( - None, - alias="stereochemistry", - title="Stereochemistry type", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSpecificationMoiety`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "role", - "identifier", - "name", - "stereochemistry", - "opticalActivity", - "molecularFormula", - "amountQuantity", - "amountString", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3116( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"amount": ["amountQuantity", "amountString"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class SubstanceSpecificationName(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Names applicable to this substance. - """ - - resource_type = Field("SubstanceSpecificationName", const=True) - - domain: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="domain", - title=( - "The use context of this name for example if there is a different name " - "a drug active ingredient as opposed to a food colour additive" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="The jurisdiction where this name applies", - description=None, - # if property is element of this resource. - element_property=True, - ) - - language: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="language", - title="Language of the name", - description=None, - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="The actual name", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - official: typing.List[fhirtypes.SubstanceSpecificationNameOfficialType] = Field( - None, - alias="official", - title="Details of the official nature of this name", - description=None, - # if property is element of this resource. - element_property=True, - ) - - preferred: bool = Field( - None, - alias="preferred", - title="If this is the preferred name for this substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - preferred__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_preferred", title="Extension field for ``preferred``." - ) - - source: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="source", - title="Supporting literature", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - status: fhirtypes.CodeableConceptType = Field( - None, - alias="status", - title="The status of the name", - description=None, - # if property is element of this resource. - element_property=True, - ) - - synonym: typing.List[fhirtypes.SubstanceSpecificationNameType] = Field( - None, - alias="synonym", - title="A synonym of this name", - description=None, - # if property is element of this resource. - element_property=True, - ) - - translation: typing.List[fhirtypes.SubstanceSpecificationNameType] = Field( - None, - alias="translation", - title="A translation for this name", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Name type", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSpecificationName`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "type", - "status", - "preferred", - "language", - "domain", - "jurisdiction", - "synonym", - "translation", - "official", - "source", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2850( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class SubstanceSpecificationNameOfficial(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Details of the official nature of this name. - """ - - resource_type = Field("SubstanceSpecificationNameOfficial", const=True) - - authority: fhirtypes.CodeableConceptType = Field( - None, - alias="authority", - title="Which authority uses this official name", - description=None, - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date of official name change", - description=None, - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - status: fhirtypes.CodeableConceptType = Field( - None, - alias="status", - title="The status of the official name", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSpecificationNameOfficial`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "authority", "status", "date"] - - -class SubstanceSpecificationProperty(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - General specifications for this substance, including how it is related to - other substances. - """ - - resource_type = Field("SubstanceSpecificationProperty", const=True) - - amountQuantity: fhirtypes.QuantityType = Field( - None, - alias="amountQuantity", - title="Quantitative value for this property", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - - amountString: fhirtypes.String = Field( - None, - alias="amountString", - title="Quantitative value for this property", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - amountString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_amountString", title="Extension field for ``amountString``." - ) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="A category for this property, e.g. Physical, Chemical, Enzymatic", - description=None, - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Property type e.g. viscosity, pH, isoelectric point", - description=None, - # if property is element of this resource. - element_property=True, - ) - - definingSubstanceCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="definingSubstanceCodeableConcept", - title=( - "A substance upon which a defining property depends (e.g. for " - "solubility: in water, in alcohol)" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definingSubstance[x] - one_of_many="definingSubstance", - one_of_many_required=False, - ) - - definingSubstanceReference: fhirtypes.ReferenceType = Field( - None, - alias="definingSubstanceReference", - title=( - "A substance upon which a defining property depends (e.g. for " - "solubility: in water, in alcohol)" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e definingSubstance[x] - one_of_many="definingSubstance", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SubstanceSpecification", "Substance"], - ) - - parameters: fhirtypes.String = Field( - None, - alias="parameters", - title=( - "Parameters that were used in the measurement of a property (e.g. for " - "viscosity: measured at 20C with a pH of 7.1)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - parameters__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_parameters", title="Extension field for ``parameters``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSpecificationProperty`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "category", - "code", - "parameters", - "definingSubstanceReference", - "definingSubstanceCodeableConcept", - "amountQuantity", - "amountString", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3354( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "amount": ["amountQuantity", "amountString"], - "definingSubstance": [ - "definingSubstanceCodeableConcept", - "definingSubstanceReference", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class SubstanceSpecificationRelationship(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A link between this substance and another, with details of the relationship. - """ - - resource_type = Field("SubstanceSpecificationRelationship", const=True) - - amountQuantity: fhirtypes.QuantityType = Field( - None, - alias="amountQuantity", - title=( - "A numeric factor for the relationship, for instance to express that " - "the salt of a substance has some percentage of the active substance in" - " relation to some other" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - - amountRange: fhirtypes.RangeType = Field( - None, - alias="amountRange", - title=( - "A numeric factor for the relationship, for instance to express that " - "the salt of a substance has some percentage of the active substance in" - " relation to some other" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - - amountRatio: fhirtypes.RatioType = Field( - None, - alias="amountRatio", - title=( - "A numeric factor for the relationship, for instance to express that " - "the salt of a substance has some percentage of the active substance in" - " relation to some other" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - - amountRatioLowLimit: fhirtypes.RatioType = Field( - None, - alias="amountRatioLowLimit", - title="For use when the numeric", - description=None, - # if property is element of this resource. - element_property=True, - ) - - amountString: fhirtypes.String = Field( - None, - alias="amountString", - title=( - "A numeric factor for the relationship, for instance to express that " - "the salt of a substance has some percentage of the active substance in" - " relation to some other" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e amount[x] - one_of_many="amount", - one_of_many_required=False, - ) - amountString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_amountString", title="Extension field for ``amountString``." - ) - - amountType: fhirtypes.CodeableConceptType = Field( - None, - alias="amountType", - title=( - 'An operator for the amount, for example "average", "approximately", ' - '"less than"' - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - isDefining: bool = Field( - None, - alias="isDefining", - title=( - "For example where an enzyme strongly bonds with a particular " - "substance, this is a defining relationship for that enzyme, out of " - "several possible substance relationships" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - isDefining__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_isDefining", title="Extension field for ``isDefining``." - ) - - relationship: fhirtypes.CodeableConceptType = Field( - None, - alias="relationship", - title='For example "salt to parent", "active moiety", "starting material"', - description=None, - # if property is element of this resource. - element_property=True, - ) - - source: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="source", - title="Supporting literature", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - substanceCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="substanceCodeableConcept", - title=( - "A pointer to another substance, as a resource or just a " - "representational code" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e substance[x] - one_of_many="substance", - one_of_many_required=False, - ) - - substanceReference: fhirtypes.ReferenceType = Field( - None, - alias="substanceReference", - title=( - "A pointer to another substance, as a resource or just a " - "representational code" - ), - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e substance[x] - one_of_many="substance", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SubstanceSpecification"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSpecificationRelationship`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "substanceReference", - "substanceCodeableConcept", - "relationship", - "isDefining", - "amountQuantity", - "amountRange", - "amountRatio", - "amountString", - "amountRatioLowLimit", - "amountType", - "source", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_3742( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "amount": ["amountQuantity", "amountRange", "amountRatio", "amountString"], - "substance": ["substanceCodeableConcept", "substanceReference"], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class SubstanceSpecificationStructure(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Structural information. - """ - - resource_type = Field("SubstanceSpecificationStructure", const=True) - - isotope: typing.List[fhirtypes.SubstanceSpecificationStructureIsotopeType] = Field( - None, - alias="isotope", - title=( - "Applicable for single substances that contain a radionuclide or a non-" - "natural isotopic ratio" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - molecularFormula: fhirtypes.String = Field( - None, - alias="molecularFormula", - title="Molecular formula", - description=None, - # if property is element of this resource. - element_property=True, - ) - molecularFormula__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_molecularFormula", - title="Extension field for ``molecularFormula``.", - ) - - molecularFormulaByMoiety: fhirtypes.String = Field( - None, - alias="molecularFormulaByMoiety", - title=( - "Specified per moiety according to the Hill system, i.e. first C, then " - "H, then alphabetical, each moiety separated by a dot" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - molecularFormulaByMoiety__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_molecularFormulaByMoiety", - title="Extension field for ``molecularFormulaByMoiety``.", - ) - - molecularWeight: fhirtypes.SubstanceSpecificationStructureIsotopeMolecularWeightType = Field( # noqa: B950 - None, - alias="molecularWeight", - title=( - "The molecular weight or weight range (for proteins, polymers or " - "nucleic acids)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - opticalActivity: fhirtypes.CodeableConceptType = Field( - None, - alias="opticalActivity", - title="Optical activity type", - description=None, - # if property is element of this resource. - element_property=True, - ) - - representation: typing.List[ - fhirtypes.SubstanceSpecificationStructureRepresentationType - ] = Field( - None, - alias="representation", - title="Molecular structural representation", - description=None, - # if property is element of this resource. - element_property=True, - ) - - source: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="source", - title="Supporting literature", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["DocumentReference"], - ) - - stereochemistry: fhirtypes.CodeableConceptType = Field( - None, - alias="stereochemistry", - title="Stereochemistry type", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSpecificationStructure`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "stereochemistry", - "opticalActivity", - "molecularFormula", - "molecularFormulaByMoiety", - "isotope", - "molecularWeight", - "source", - "representation", - ] - - -class SubstanceSpecificationStructureIsotope(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Applicable for single substances that contain a radionuclide or a non- - natural isotopic ratio. - """ - - resource_type = Field("SubstanceSpecificationStructureIsotope", const=True) - - halfLife: fhirtypes.QuantityType = Field( - None, - alias="halfLife", - title="Half life - for a non-natural nuclide", - description=None, - # if property is element of this resource. - element_property=True, - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Substance identifier for each non-natural or radioisotope", - description=None, - # if property is element of this resource. - element_property=True, - ) - - molecularWeight: fhirtypes.SubstanceSpecificationStructureIsotopeMolecularWeightType = Field( # noqa: B950 - None, - alias="molecularWeight", - title=( - "The molecular weight or weight range (for proteins, polymers or " - "nucleic acids)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.CodeableConceptType = Field( - None, - alias="name", - title="Substance name for each non-natural or radioisotope", - description=None, - # if property is element of this resource. - element_property=True, - ) - - substitution: fhirtypes.CodeableConceptType = Field( - None, - alias="substitution", - title="The type of isotopic substitution present in a single substance", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSpecificationStructureIsotope`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "name", - "substitution", - "halfLife", - "molecularWeight", - ] - - -class SubstanceSpecificationStructureIsotopeMolecularWeight( - backboneelement.BackboneElement -): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The molecular weight or weight range (for proteins, polymers or nucleic - acids). - """ - - resource_type = Field( - "SubstanceSpecificationStructureIsotopeMolecularWeight", const=True - ) - - amount: fhirtypes.QuantityType = Field( - None, - alias="amount", - title=( - "Used to capture quantitative values for a variety of elements. If only" - " limits are given, the arithmetic mean would be the average. If only a" - " single definite value for a given element is given, it would be " - "captured in this field" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - method: fhirtypes.CodeableConceptType = Field( - None, - alias="method", - title="The method by which the molecular weight was determined", - description=None, - # if property is element of this resource. - element_property=True, - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title=( - "Type of molecular weight such as exact, average (also known as. number" - " average), weight average" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSpecificationStructureIsotopeMolecularWeight`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "method", "type", "amount"] - - -class SubstanceSpecificationStructureRepresentation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Molecular structural representation. - """ - - resource_type = Field("SubstanceSpecificationStructureRepresentation", const=True) - - attachment: fhirtypes.AttachmentType = Field( - None, - alias="attachment", - title="An attached file with the structural representation", - description=None, - # if property is element of this resource. - element_property=True, - ) - - representation: fhirtypes.String = Field( - None, - alias="representation", - title=( - "The structural representation as text string in a format e.g. InChI, " - "SMILES, MOLFILE, CDX" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - representation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_representation", title="Extension field for ``representation``." - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="The type of structure (e.g. Full, Partial, Representative)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SubstanceSpecificationStructureRepresentation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "representation", - "attachment", - ] diff --git a/fhir/resources/supplydelivery.py b/fhir/resources/supplydelivery.py deleted file mode 100644 index 08a754d5..00000000 --- a/fhir/resources/supplydelivery.py +++ /dev/null @@ -1,373 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SupplyDelivery -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class SupplyDelivery(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Delivery of bulk Supplies. - Record of delivery of what is supplied. - """ - - resource_type = Field("SupplyDelivery", const=True) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Fulfills plan, proposal or order", - description=( - "A plan, proposal or order that is fulfilled in whole or in part by " - "this event." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SupplyRequest"], - ) - - destination: fhirtypes.ReferenceType = Field( - None, - alias="destination", - title="Where the Supply was sent", - description=( - "Identification of the facility/location where the Supply was shipped " - "to, as part of the dispense event." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="External identifier", - description=( - "Identifier for the supply delivery event that is used to identify it " - "across multiple disparate systems." - ), - # if property is element of this resource. - element_property=True, - ) - - occurrenceDateTime: fhirtypes.DateTime = Field( - None, - alias="occurrenceDateTime", - title="When event occurred", - description="The date or time(s) the activity occurred.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - occurrenceDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurrenceDateTime", - title="Extension field for ``occurrenceDateTime``.", - ) - - occurrencePeriod: fhirtypes.PeriodType = Field( - None, - alias="occurrencePeriod", - title="When event occurred", - description="The date or time(s) the activity occurred.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - occurrenceTiming: fhirtypes.TimingType = Field( - None, - alias="occurrenceTiming", - title="When event occurred", - description="The date or time(s) the activity occurred.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Part of referenced event", - description="A larger event of which this particular event is a component or step.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["SupplyDelivery", "Contract"], - ) - - patient: fhirtypes.ReferenceType = Field( - None, - alias="patient", - title="Patient for whom the item is supplied", - description=( - "A link to a resource representing the person whom the delivered item " - "is for." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - receiver: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="receiver", - title="Who collected the Supply", - description="Identifies the person who picked up the Supply.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="in-progress | completed | abandoned | entered-in-error", - description="A code specifying the state of the dispense event.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["in-progress", "completed", "abandoned", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - suppliedItem: fhirtypes.SupplyDeliverySuppliedItemType = Field( - None, - alias="suppliedItem", - title="The item that is delivered or supplied", - description="The item that is being delivered or has been supplied.", - # if property is element of this resource. - element_property=True, - ) - - supplier: fhirtypes.ReferenceType = Field( - None, - alias="supplier", - title="Dispenser", - description=( - "The individual responsible for dispensing the medication, supplier or " - "device." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - type: fhirtypes.CodeableConceptType = Field( - None, - alias="type", - title="Category of dispense event", - description=( - "Indicates the type of dispensing event that is performed. Examples " - "include: Trial Fill, Completion of Trial, Partial Fill, Emergency " - "Fill, Samples, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SupplyDelivery`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "basedOn", - "partOf", - "status", - "patient", - "type", - "suppliedItem", - "occurrenceDateTime", - "occurrencePeriod", - "occurrenceTiming", - "supplier", - "destination", - "receiver", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1693( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "occurrence": ["occurrenceDateTime", "occurrencePeriod", "occurrenceTiming"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class SupplyDeliverySuppliedItem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The item that is delivered or supplied. - The item that is being delivered or has been supplied. - """ - - resource_type = Field("SupplyDeliverySuppliedItem", const=True) - - itemCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="itemCodeableConcept", - title="Medication, Substance, or Device supplied", - description=( - "Identifies the medication, substance or device being dispensed. This " - "is either a link to a resource representing the details of the item or" - " a code that identifies the item from a known list." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e item[x] - one_of_many="item", - one_of_many_required=False, - ) - - itemReference: fhirtypes.ReferenceType = Field( - None, - alias="itemReference", - title="Medication, Substance, or Device supplied", - description=( - "Identifies the medication, substance or device being dispensed. This " - "is either a link to a resource representing the details of the item or" - " a code that identifies the item from a known list." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e item[x] - one_of_many="item", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Medication", "Substance", "Device"], - ) - - quantity: fhirtypes.QuantityType = Field( - None, - alias="quantity", - title="Amount dispensed", - description=( - "The amount of supply that has been dispensed. Includes unit of " "measure." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SupplyDeliverySuppliedItem`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "quantity", - "itemCodeableConcept", - "itemReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2918( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = {"item": ["itemCodeableConcept", "itemReference"]} - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/supplyrequest.py b/fhir/resources/supplyrequest.py deleted file mode 100644 index 07606088..00000000 --- a/fhir/resources/supplyrequest.py +++ /dev/null @@ -1,483 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SupplyRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, domainresource, fhirtypes - - -class SupplyRequest(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Request for a medication, substance or device. - A record of a request for a medication, substance or device used in the - healthcare setting. - """ - - resource_type = Field("SupplyRequest", const=True) - - authoredOn: fhirtypes.DateTime = Field( - None, - alias="authoredOn", - title="When the request was made", - description=None, - # if property is element of this resource. - element_property=True, - ) - authoredOn__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_authoredOn", title="Extension field for ``authoredOn``." - ) - - category: fhirtypes.CodeableConceptType = Field( - None, - alias="category", - title="The kind of supply (central, non-stock, etc.)", - description=( - "Category of supply, e.g. central, non-stock, etc. This is used to " - "support work flows associated with the supply process." - ), - # if property is element of this resource. - element_property=True, - ) - - deliverFrom: fhirtypes.ReferenceType = Field( - None, - alias="deliverFrom", - title="The origin of the supply", - description="Where the supply is expected to come from.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization", "Location"], - ) - - deliverTo: fhirtypes.ReferenceType = Field( - None, - alias="deliverTo", - title="The destination of the supply", - description="Where the supply is destined to go.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization", "Location", "Patient"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for SupplyRequest", - description=( - "Business identifiers assigned to this SupplyRequest by the author " - "and/or other systems. These identifiers remain constant as the " - "resource is updated and propagates from server to server." - ), - # if property is element of this resource. - element_property=True, - ) - - itemCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="itemCodeableConcept", - title="Medication, Substance, or Device requested to be supplied", - description=( - "The item that is requested to be supplied. This is either a link to a " - "resource representing the details of the item or a code that " - "identifies the item from a known list." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e item[x] - one_of_many="item", - one_of_many_required=True, - ) - - itemReference: fhirtypes.ReferenceType = Field( - None, - alias="itemReference", - title="Medication, Substance, or Device requested to be supplied", - description=( - "The item that is requested to be supplied. This is either a link to a " - "resource representing the details of the item or a code that " - "identifies the item from a known list." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e item[x] - one_of_many="item", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Medication", "Substance", "Device"], - ) - - occurrenceDateTime: fhirtypes.DateTime = Field( - None, - alias="occurrenceDateTime", - title="When the request should be fulfilled", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - occurrenceDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_occurrenceDateTime", - title="Extension field for ``occurrenceDateTime``.", - ) - - occurrencePeriod: fhirtypes.PeriodType = Field( - None, - alias="occurrencePeriod", - title="When the request should be fulfilled", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - occurrenceTiming: fhirtypes.TimingType = Field( - None, - alias="occurrenceTiming", - title="When the request should be fulfilled", - description=None, - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e occurrence[x] - one_of_many="occurrence", - one_of_many_required=False, - ) - - parameter: typing.List[fhirtypes.SupplyRequestParameterType] = Field( - None, - alias="parameter", - title="Ordered item details", - description=( - "Specific parameters for the ordered item. For example, the size of " - "the indicated item." - ), - # if property is element of this resource. - element_property=True, - ) - - priority: fhirtypes.Code = Field( - None, - alias="priority", - title="routine | urgent | asap | stat", - description=( - "Indicates how quickly this SupplyRequest should be addressed with " - "respect to other requests." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["routine", "urgent", "asap", "stat"], - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - quantity: fhirtypes.QuantityType = Field( - ..., - alias="quantity", - title="The requested amount of the item indicated", - description="The amount that is being ordered of the indicated item.", - # if property is element of this resource. - element_property=True, - ) - - reasonCode: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="reasonCode", - title="The reason why the supply item was requested", - description=None, - # if property is element of this resource. - element_property=True, - ) - - reasonReference: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="reasonReference", - title="The reason why the supply item was requested", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Condition", - "Observation", - "DiagnosticReport", - "DocumentReference", - ], - ) - - requester: fhirtypes.ReferenceType = Field( - None, - alias="requester", - title="Individual making the request", - description="The device, practitioner, etc. who initiated the request.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "Patient", - "RelatedPerson", - "Device", - ], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | suspended +", - description="Status of the supply request.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "suspended", "+"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - supplier: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="supplier", - title="Who is intended to fulfill the request", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization", "HealthcareService"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SupplyRequest`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "category", - "priority", - "itemCodeableConcept", - "itemReference", - "quantity", - "parameter", - "occurrenceDateTime", - "occurrencePeriod", - "occurrenceTiming", - "authoredOn", - "requester", - "supplier", - "reasonCode", - "reasonReference", - "deliverFrom", - "deliverTo", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1597( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "item": ["itemCodeableConcept", "itemReference"], - "occurrence": [ - "occurrenceDateTime", - "occurrencePeriod", - "occurrenceTiming", - ], - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class SupplyRequestParameter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Ordered item details. - Specific parameters for the ordered item. For example, the size of the - indicated item. - """ - - resource_type = Field("SupplyRequestParameter", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Item detail", - description="A code or string that identifies the device detail being asserted.", - # if property is element of this resource. - element_property=True, - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Value of detail", - description="The value of the device detail.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="Value of detail", - description="The value of the device detail.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Value of detail", - description="The value of the device detail.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - valueRange: fhirtypes.RangeType = Field( - None, - alias="valueRange", - title="Value of detail", - description="The value of the device detail.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``SupplyRequestParameter`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "valueCodeableConcept", - "valueQuantity", - "valueRange", - "valueBoolean", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2524( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueBoolean", - "valueCodeableConcept", - "valueQuantity", - "valueRange", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/task.py b/fhir/resources/task.py deleted file mode 100644 index 416f2eda..00000000 --- a/fhir/resources/task.py +++ /dev/null @@ -1,2307 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Task -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class Task(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A task to be performed. - """ - - resource_type = Field("Task", const=True) - - authoredOn: fhirtypes.DateTime = Field( - None, - alias="authoredOn", - title="Task Creation Date", - description="The date and time this task was created.", - # if property is element of this resource. - element_property=True, - ) - authoredOn__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_authoredOn", title="Extension field for ``authoredOn``." - ) - - basedOn: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="basedOn", - title="Request fulfilled by this task", - description=( - "BasedOn refers to a higher-level authorization that triggered the " - 'creation of the task. It references a "request" resource such as a ' - "ServiceRequest, MedicationRequest, ServiceRequest, CarePlan, etc. " - 'which is distinct from the "request" resource the task is seeking to ' - "fulfill. This latter resource is referenced by FocusOn. For example," - " based on a ServiceRequest (= BasedOn), a task is created to fulfill a" - " procedureRequest ( = FocusOn ) to collect a specimen from a patient." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - businessStatus: fhirtypes.CodeableConceptType = Field( - None, - alias="businessStatus", - title='E.g. "Specimen collected", "IV prepped"', - description="Contains business-specific nuances of the business state.", - # if property is element of this resource. - element_property=True, - ) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="Task Type", - description="A name or code (or both) briefly describing what the task involves.", - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Human-readable explanation of task", - description="A free-text description of what is to be performed.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Healthcare event during which this task originated", - description=( - "The healthcare event (e.g. a patient and healthcare provider " - "interaction) during which this task was created." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - executionPeriod: fhirtypes.PeriodType = Field( - None, - alias="executionPeriod", - title="Start and end time of execution", - description=( - "Identifies the time action was first taken against the task (start) " - "and/or the time final action was taken against the task prior to " - "marking it as completed (end)." - ), - # if property is element of this resource. - element_property=True, - ) - - focus: fhirtypes.ReferenceType = Field( - None, - alias="focus", - title="What task is acting on", - description=( - "The request being actioned or the resource being manipulated by this " - "task." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - for_fhir: fhirtypes.ReferenceType = Field( - None, - alias="for", - title="Beneficiary of the Task", - description=( - "The entity who benefits from the performance of the service specified " - "in the task (e.g., the patient)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - groupIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="groupIdentifier", - title="Requisition or grouper id", - description=( - "An identifier that links together multiple tasks and other requests " - "that were created in the same context." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Task Instance Identifier", - description="The business identifier for this task.", - # if property is element of this resource. - element_property=True, - ) - - input: typing.List[fhirtypes.TaskInputType] = Field( - None, - alias="input", - title="Information used to perform task", - description=( - "Additional information that may be needed in the execution of the " "task." - ), - # if property is element of this resource. - element_property=True, - ) - - instantiatesCanonical: fhirtypes.Canonical = Field( - None, - alias="instantiatesCanonical", - title="Formal definition of task", - description=( - "The URL pointing to a *FHIR*-defined protocol, guideline, orderset or " - "other definition that is adhered to in whole or in part by this Task." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ActivityDefinition"], - ) - instantiatesCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_instantiatesCanonical", - title="Extension field for ``instantiatesCanonical``.", - ) - - instantiatesUri: fhirtypes.Uri = Field( - None, - alias="instantiatesUri", - title="Formal definition of task", - description=( - "The URL pointing to an *externally* maintained protocol, guideline, " - "orderset or other definition that is adhered to in whole or in part by" - " this Task." - ), - # if property is element of this resource. - element_property=True, - ) - instantiatesUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_instantiatesUri", title="Extension field for ``instantiatesUri``." - ) - - insurance: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="insurance", - title="Associated insurance coverage", - description=( - "Insurance plans, coverage extensions, pre-authorizations and/or pre-" - "determinations that may be relevant to the Task." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Coverage", "ClaimResponse"], - ) - - intent: fhirtypes.Code = Field( - None, - alias="intent", - title=( - "unknown | proposal | plan | order | original-order | reflex-order | " - "filler-order | instance-order | option" - ), - description=( - 'Indicates the "level" of actionability associated with the Task, i.e. ' - "i+R[9]Cs this a proposed task, a planned task, an actionable task, " - "etc." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "unknown", - "proposal", - "plan", - "order", - "original-order", - "reflex-order", - "filler-order", - "instance-order", - "option", - ], - ) - intent__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_intent", title="Extension field for ``intent``." - ) - - lastModified: fhirtypes.DateTime = Field( - None, - alias="lastModified", - title="Task Last Modified Date", - description="The date and time of last modification to this task.", - # if property is element of this resource. - element_property=True, - ) - lastModified__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastModified", title="Extension field for ``lastModified``." - ) - - location: fhirtypes.ReferenceType = Field( - None, - alias="location", - title="Where task occurs", - description="Principal physical location where the this task is performed.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Location"], - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Comments made about the task", - description="Free-text information captured about the task as it progresses.", - # if property is element of this resource. - element_property=True, - ) - - output: typing.List[fhirtypes.TaskOutputType] = Field( - None, - alias="output", - title="Information produced as part of task", - description="Outputs produced by the Task.", - # if property is element of this resource. - element_property=True, - ) - - owner: fhirtypes.ReferenceType = Field( - None, - alias="owner", - title="Responsible individual", - description=( - "Individual organization or Device currently responsible for task " - "execution." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Practitioner", - "PractitionerRole", - "Organization", - "CareTeam", - "HealthcareService", - "Patient", - "Device", - "RelatedPerson", - ], - ) - - partOf: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="partOf", - title="Composite task", - description="Task that this particular task is part of.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Task"], - ) - - performerType: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="performerType", - title="Requested performer", - description="The kind of participant that should perform the task.", - # if property is element of this resource. - element_property=True, - ) - - priority: fhirtypes.Code = Field( - None, - alias="priority", - title="routine | urgent | asap | stat", - description=( - "Indicates how quickly the Task should be addressed with respect to " - "other requests." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["routine", "urgent", "asap", "stat"], - ) - priority__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_priority", title="Extension field for ``priority``." - ) - - reasonCode: fhirtypes.CodeableConceptType = Field( - None, - alias="reasonCode", - title="Why task is needed", - description="A description or code indicating why this task needs to be performed.", - # if property is element of this resource. - element_property=True, - ) - - reasonReference: fhirtypes.ReferenceType = Field( - None, - alias="reasonReference", - title="Why task is needed", - description="A resource reference indicating why this task needs to be performed.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - relevantHistory: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="relevantHistory", - title="Key events in history of the Task", - description=( - "Links to Provenance records for past versions of this Task that " - "identify key state transitions or updates that are likely to be " - "relevant to a user looking at the current version of the task." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Provenance"], - ) - - requester: fhirtypes.ReferenceType = Field( - None, - alias="requester", - title="Who is asking for task to be done", - description="The creator of the task.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Device", - "Organization", - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - ], - ) - - restriction: fhirtypes.TaskRestrictionType = Field( - None, - alias="restriction", - title="Constraints on fulfillment tasks", - description=( - "If the Task.focus is a request resource and the task is seeking " - "fulfillment (i.e. is asking for the request to be actioned), this " - "element identifies any limitations on what parts of the referenced " - "request should be actioned." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | requested | received | accepted | +", - description="The current status of the task.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "requested", "received", "accepted", "+"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusReason: fhirtypes.CodeableConceptType = Field( - None, - alias="statusReason", - title="Reason for current status", - description="An explanation as to why this task is held, failed, was refused, etc.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Task`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "instantiatesCanonical", - "instantiatesUri", - "basedOn", - "groupIdentifier", - "partOf", - "status", - "statusReason", - "businessStatus", - "intent", - "priority", - "code", - "description", - "focus", - "for", - "encounter", - "executionPeriod", - "authoredOn", - "lastModified", - "requester", - "performerType", - "owner", - "location", - "reasonCode", - "reasonReference", - "insurance", - "note", - "relevantHistory", - "restriction", - "input", - "output", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_594( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("intent", "intent__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TaskInput(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information used to perform task. - Additional information that may be needed in the execution of the task. - """ - - resource_type = Field("TaskInput", const=True) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Label for the input", - description=( - "A code or description indicating how the input is intended to be used " - "as part of the task execution." - ), - # if property is element of this resource. - element_property=True, - ) - - valueAddress: fhirtypes.AddressType = Field( - None, - alias="valueAddress", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueAge: fhirtypes.AgeType = Field( - None, - alias="valueAge", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueAnnotation: fhirtypes.AnnotationType = Field( - None, - alias="valueAnnotation", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="valueAttachment", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueBase64Binary: fhirtypes.Base64Binary = Field( - None, - alias="valueBase64Binary", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBase64Binary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valueBase64Binary", - title="Extension field for ``valueBase64Binary``.", - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCanonical: fhirtypes.Canonical = Field( - None, - alias="valueCanonical", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueCanonical", title="Extension field for ``valueCanonical``." - ) - - valueCode: fhirtypes.Code = Field( - None, - alias="valueCode", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueCode", title="Extension field for ``valueCode``." - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueCoding: fhirtypes.CodingType = Field( - None, - alias="valueCoding", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueContactDetail: fhirtypes.ContactDetailType = Field( - None, - alias="valueContactDetail", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueContactPoint: fhirtypes.ContactPointType = Field( - None, - alias="valueContactPoint", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueContributor: fhirtypes.ContributorType = Field( - None, - alias="valueContributor", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueCount: fhirtypes.CountType = Field( - None, - alias="valueCount", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDataRequirement: fhirtypes.DataRequirementType = Field( - None, - alias="valueDataRequirement", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDate: fhirtypes.Date = Field( - None, - alias="valueDate", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDate", title="Extension field for ``valueDate``." - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueDecimal: fhirtypes.Decimal = Field( - None, - alias="valueDecimal", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDecimal", title="Extension field for ``valueDecimal``." - ) - - valueDistance: fhirtypes.DistanceType = Field( - None, - alias="valueDistance", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDosage: fhirtypes.DosageType = Field( - None, - alias="valueDosage", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDuration: fhirtypes.DurationType = Field( - None, - alias="valueDuration", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueExpression: fhirtypes.ExpressionType = Field( - None, - alias="valueExpression", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueHumanName: fhirtypes.HumanNameType = Field( - None, - alias="valueHumanName", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueId: fhirtypes.Id = Field( - None, - alias="valueId", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueId", title="Extension field for ``valueId``." - ) - - valueIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="valueIdentifier", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueInstant: fhirtypes.Instant = Field( - None, - alias="valueInstant", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueInstant__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInstant", title="Extension field for ``valueInstant``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valueMarkdown: fhirtypes.Markdown = Field( - None, - alias="valueMarkdown", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueMarkdown__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueMarkdown", title="Extension field for ``valueMarkdown``." - ) - - valueMeta: fhirtypes.MetaType = Field( - None, - alias="valueMeta", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueMoney: fhirtypes.MoneyType = Field( - None, - alias="valueMoney", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueOid: fhirtypes.Oid = Field( - None, - alias="valueOid", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueOid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueOid", title="Extension field for ``valueOid``." - ) - - valueParameterDefinition: fhirtypes.ParameterDefinitionType = Field( - None, - alias="valueParameterDefinition", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valuePeriod: fhirtypes.PeriodType = Field( - None, - alias="valuePeriod", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valuePositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="valuePositiveInt", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valuePositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valuePositiveInt", - title="Extension field for ``valuePositiveInt``.", - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueRange: fhirtypes.RangeType = Field( - None, - alias="valueRange", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueRatio: fhirtypes.RatioType = Field( - None, - alias="valueRatio", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueRelatedArtifact: fhirtypes.RelatedArtifactType = Field( - None, - alias="valueRelatedArtifact", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueSampledData: fhirtypes.SampledDataType = Field( - None, - alias="valueSampledData", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueSignature: fhirtypes.SignatureType = Field( - None, - alias="valueSignature", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - valueTime: fhirtypes.Time = Field( - None, - alias="valueTime", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueTime", title="Extension field for ``valueTime``." - ) - - valueTiming: fhirtypes.TimingType = Field( - None, - alias="valueTiming", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueTriggerDefinition: fhirtypes.TriggerDefinitionType = Field( - None, - alias="valueTriggerDefinition", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="valueUnsignedInt", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valueUnsignedInt", - title="Extension field for ``valueUnsignedInt``.", - ) - - valueUri: fhirtypes.Uri = Field( - None, - alias="valueUri", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUri", title="Extension field for ``valueUri``." - ) - - valueUrl: fhirtypes.Url = Field( - None, - alias="valueUrl", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUrl", title="Extension field for ``valueUrl``." - ) - - valueUsageContext: fhirtypes.UsageContextType = Field( - None, - alias="valueUsageContext", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueUuid: fhirtypes.Uuid = Field( - None, - alias="valueUuid", - title="Content to use in performing the task", - description="The value of the input parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUuid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUuid", title="Extension field for ``valueUuid``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TaskInput`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "valueBase64Binary", - "valueBoolean", - "valueCanonical", - "valueCode", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueId", - "valueInstant", - "valueInteger", - "valueMarkdown", - "valueOid", - "valuePositiveInt", - "valueString", - "valueTime", - "valueUnsignedInt", - "valueUri", - "valueUrl", - "valueUuid", - "valueAddress", - "valueAge", - "valueAnnotation", - "valueAttachment", - "valueCodeableConcept", - "valueCoding", - "valueContactPoint", - "valueCount", - "valueDistance", - "valueDuration", - "valueHumanName", - "valueIdentifier", - "valueMoney", - "valuePeriod", - "valueQuantity", - "valueRange", - "valueRatio", - "valueReference", - "valueSampledData", - "valueSignature", - "valueTiming", - "valueContactDetail", - "valueContributor", - "valueDataRequirement", - "valueExpression", - "valueParameterDefinition", - "valueRelatedArtifact", - "valueTriggerDefinition", - "valueUsageContext", - "valueDosage", - "valueMeta", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1131( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueAddress", - "valueAge", - "valueAnnotation", - "valueAttachment", - "valueBase64Binary", - "valueBoolean", - "valueCanonical", - "valueCode", - "valueCodeableConcept", - "valueCoding", - "valueContactDetail", - "valueContactPoint", - "valueContributor", - "valueCount", - "valueDataRequirement", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueDistance", - "valueDosage", - "valueDuration", - "valueExpression", - "valueHumanName", - "valueId", - "valueIdentifier", - "valueInstant", - "valueInteger", - "valueMarkdown", - "valueMeta", - "valueMoney", - "valueOid", - "valueParameterDefinition", - "valuePeriod", - "valuePositiveInt", - "valueQuantity", - "valueRange", - "valueRatio", - "valueReference", - "valueRelatedArtifact", - "valueSampledData", - "valueSignature", - "valueString", - "valueTime", - "valueTiming", - "valueTriggerDefinition", - "valueUnsignedInt", - "valueUri", - "valueUrl", - "valueUsageContext", - "valueUuid", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class TaskOutput(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information produced as part of task. - Outputs produced by the Task. - """ - - resource_type = Field("TaskOutput", const=True) - - type: fhirtypes.CodeableConceptType = Field( - ..., - alias="type", - title="Label for output", - description="The name of the Output parameter.", - # if property is element of this resource. - element_property=True, - ) - - valueAddress: fhirtypes.AddressType = Field( - None, - alias="valueAddress", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueAge: fhirtypes.AgeType = Field( - None, - alias="valueAge", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueAnnotation: fhirtypes.AnnotationType = Field( - None, - alias="valueAnnotation", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueAttachment: fhirtypes.AttachmentType = Field( - None, - alias="valueAttachment", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueBase64Binary: fhirtypes.Base64Binary = Field( - None, - alias="valueBase64Binary", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBase64Binary__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valueBase64Binary", - title="Extension field for ``valueBase64Binary``.", - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCanonical: fhirtypes.Canonical = Field( - None, - alias="valueCanonical", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueCanonical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueCanonical", title="Extension field for ``valueCanonical``." - ) - - valueCode: fhirtypes.Code = Field( - None, - alias="valueCode", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueCode", title="Extension field for ``valueCode``." - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueCoding: fhirtypes.CodingType = Field( - None, - alias="valueCoding", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueContactDetail: fhirtypes.ContactDetailType = Field( - None, - alias="valueContactDetail", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueContactPoint: fhirtypes.ContactPointType = Field( - None, - alias="valueContactPoint", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueContributor: fhirtypes.ContributorType = Field( - None, - alias="valueContributor", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueCount: fhirtypes.CountType = Field( - None, - alias="valueCount", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDataRequirement: fhirtypes.DataRequirementType = Field( - None, - alias="valueDataRequirement", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDate: fhirtypes.Date = Field( - None, - alias="valueDate", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDate", title="Extension field for ``valueDate``." - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueDecimal: fhirtypes.Decimal = Field( - None, - alias="valueDecimal", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDecimal", title="Extension field for ``valueDecimal``." - ) - - valueDistance: fhirtypes.DistanceType = Field( - None, - alias="valueDistance", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDosage: fhirtypes.DosageType = Field( - None, - alias="valueDosage", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueDuration: fhirtypes.DurationType = Field( - None, - alias="valueDuration", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueExpression: fhirtypes.ExpressionType = Field( - None, - alias="valueExpression", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueHumanName: fhirtypes.HumanNameType = Field( - None, - alias="valueHumanName", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueId: fhirtypes.Id = Field( - None, - alias="valueId", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueId", title="Extension field for ``valueId``." - ) - - valueIdentifier: fhirtypes.IdentifierType = Field( - None, - alias="valueIdentifier", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueInstant: fhirtypes.Instant = Field( - None, - alias="valueInstant", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueInstant__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInstant", title="Extension field for ``valueInstant``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valueMarkdown: fhirtypes.Markdown = Field( - None, - alias="valueMarkdown", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueMarkdown__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueMarkdown", title="Extension field for ``valueMarkdown``." - ) - - valueMeta: fhirtypes.MetaType = Field( - None, - alias="valueMeta", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueMoney: fhirtypes.MoneyType = Field( - None, - alias="valueMoney", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueOid: fhirtypes.Oid = Field( - None, - alias="valueOid", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueOid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueOid", title="Extension field for ``valueOid``." - ) - - valueParameterDefinition: fhirtypes.ParameterDefinitionType = Field( - None, - alias="valueParameterDefinition", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valuePeriod: fhirtypes.PeriodType = Field( - None, - alias="valuePeriod", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valuePositiveInt: fhirtypes.PositiveInt = Field( - None, - alias="valuePositiveInt", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valuePositiveInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valuePositiveInt", - title="Extension field for ``valuePositiveInt``.", - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueRange: fhirtypes.RangeType = Field( - None, - alias="valueRange", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueRatio: fhirtypes.RatioType = Field( - None, - alias="valueRatio", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueRelatedArtifact: fhirtypes.RelatedArtifactType = Field( - None, - alias="valueRelatedArtifact", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueSampledData: fhirtypes.SampledDataType = Field( - None, - alias="valueSampledData", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueSignature: fhirtypes.SignatureType = Field( - None, - alias="valueSignature", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - valueTime: fhirtypes.Time = Field( - None, - alias="valueTime", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueTime", title="Extension field for ``valueTime``." - ) - - valueTiming: fhirtypes.TimingType = Field( - None, - alias="valueTiming", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueTriggerDefinition: fhirtypes.TriggerDefinitionType = Field( - None, - alias="valueTriggerDefinition", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueUnsignedInt: fhirtypes.UnsignedInt = Field( - None, - alias="valueUnsignedInt", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUnsignedInt__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_valueUnsignedInt", - title="Extension field for ``valueUnsignedInt``.", - ) - - valueUri: fhirtypes.Uri = Field( - None, - alias="valueUri", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUri", title="Extension field for ``valueUri``." - ) - - valueUrl: fhirtypes.Url = Field( - None, - alias="valueUrl", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUrl", title="Extension field for ``valueUrl``." - ) - - valueUsageContext: fhirtypes.UsageContextType = Field( - None, - alias="valueUsageContext", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueUuid: fhirtypes.Uuid = Field( - None, - alias="valueUuid", - title="Result of output", - description="The value of the Output parameter as a basic type.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - valueUuid__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUuid", title="Extension field for ``valueUuid``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TaskOutput`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "valueBase64Binary", - "valueBoolean", - "valueCanonical", - "valueCode", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueId", - "valueInstant", - "valueInteger", - "valueMarkdown", - "valueOid", - "valuePositiveInt", - "valueString", - "valueTime", - "valueUnsignedInt", - "valueUri", - "valueUrl", - "valueUuid", - "valueAddress", - "valueAge", - "valueAnnotation", - "valueAttachment", - "valueCodeableConcept", - "valueCoding", - "valueContactPoint", - "valueCount", - "valueDistance", - "valueDuration", - "valueHumanName", - "valueIdentifier", - "valueMoney", - "valuePeriod", - "valueQuantity", - "valueRange", - "valueRatio", - "valueReference", - "valueSampledData", - "valueSignature", - "valueTiming", - "valueContactDetail", - "valueContributor", - "valueDataRequirement", - "valueExpression", - "valueParameterDefinition", - "valueRelatedArtifact", - "valueTriggerDefinition", - "valueUsageContext", - "valueDosage", - "valueMeta", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1260( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueAddress", - "valueAge", - "valueAnnotation", - "valueAttachment", - "valueBase64Binary", - "valueBoolean", - "valueCanonical", - "valueCode", - "valueCodeableConcept", - "valueCoding", - "valueContactDetail", - "valueContactPoint", - "valueContributor", - "valueCount", - "valueDataRequirement", - "valueDate", - "valueDateTime", - "valueDecimal", - "valueDistance", - "valueDosage", - "valueDuration", - "valueExpression", - "valueHumanName", - "valueId", - "valueIdentifier", - "valueInstant", - "valueInteger", - "valueMarkdown", - "valueMeta", - "valueMoney", - "valueOid", - "valueParameterDefinition", - "valuePeriod", - "valuePositiveInt", - "valueQuantity", - "valueRange", - "valueRatio", - "valueReference", - "valueRelatedArtifact", - "valueSampledData", - "valueSignature", - "valueString", - "valueTime", - "valueTiming", - "valueTriggerDefinition", - "valueUnsignedInt", - "valueUri", - "valueUrl", - "valueUsageContext", - "valueUuid", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values - - -class TaskRestriction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Constraints on fulfillment tasks. - If the Task.focus is a request resource and the task is seeking fulfillment - (i.e. is asking for the request to be actioned), this element identifies - any limitations on what parts of the referenced request should be actioned. - """ - - resource_type = Field("TaskRestriction", const=True) - - period: fhirtypes.PeriodType = Field( - None, - alias="period", - title="When fulfillment sought", - description="Over what time-period is fulfillment sought.", - # if property is element of this resource. - element_property=True, - ) - - recipient: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="recipient", - title="For whom is fulfillment sought?", - description=( - "For requests that are targeted to more than on potential " - "recipient/target, for whom is fulfillment sought?" - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "Patient", - "Practitioner", - "PractitionerRole", - "RelatedPerson", - "Group", - "Organization", - ], - ) - - repetitions: fhirtypes.PositiveInt = Field( - None, - alias="repetitions", - title="How many times to repeat", - description="Indicates the number of times the requested action should occur.", - # if property is element of this resource. - element_property=True, - ) - repetitions__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_repetitions", title="Extension field for ``repetitions``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TaskRestriction`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "repetitions", - "period", - "recipient", - ] diff --git a/fhir/resources/terminologycapabilities.py b/fhir/resources/terminologycapabilities.py deleted file mode 100644 index 410871e2..00000000 --- a/fhir/resources/terminologycapabilities.py +++ /dev/null @@ -1,1398 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/TerminologyCapabilities -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class TerminologyCapabilities(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A statement of system capabilities. - A TerminologyCapabilities resource documents a set of capabilities - (behaviors) of a FHIR Terminology Server that may be used as a statement of - actual server functionality or a statement of required or desired server - implementation. - """ - - resource_type = Field("TerminologyCapabilities", const=True) - - closure: fhirtypes.TerminologyCapabilitiesClosureType = Field( - None, - alias="closure", - title=( - "Information about the [ConceptMap/$closure](conceptmap-operation-" - "closure.html) operation" - ), - description="Whether the $closure operation is supported.", - # if property is element of this resource. - element_property=True, - ) - - codeSearch: fhirtypes.Code = Field( - None, - alias="codeSearch", - title="explicit | all", - description=( - "The degree to which the server supports the code search parameter on " - "ValueSet, if it is supported." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["explicit", "all"], - ) - codeSearch__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_codeSearch", title="Extension field for ``codeSearch``." - ) - - codeSystem: typing.List[fhirtypes.TerminologyCapabilitiesCodeSystemType] = Field( - None, - alias="codeSystem", - title="A code system supported by the server", - description=( - "Identifies a code system that is supported by the server. If there is " - "a no code system URL, then this declares the general assumptions a " - "client can make about support for any CodeSystem resource." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the terminology capabilities and/or " - "its contents. Copyright statements are generally legal restrictions on" - " the use and publishing of the terminology capabilities." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the terminology capabilities was " - "published. The date must change when the business version changes and " - "it must change if the status code changes. In addition, it should " - "change when the substantive content of the terminology capabilities " - "changes." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the terminology capabilities", - description=( - "A free text natural language description of the terminology " - "capabilities from a consumer's perspective. Typically, this is used " - "when the capability statement describes a desired rather than an " - "actual solution, for example as a formal expression of requirements as" - " part of an RFP." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - expansion: fhirtypes.TerminologyCapabilitiesExpansionType = Field( - None, - alias="expansion", - title=( - "Information about the [ValueSet/$expand](valueset-operation-" - "expand.html) operation" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this terminology capabilities is " - "authored for testing purposes (or education/evaluation/marketing) and " - "is not intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - implementation: fhirtypes.TerminologyCapabilitiesImplementationType = Field( - None, - alias="implementation", - title="If this describes a specific instance", - description=( - "Identifies a specific implementation instance that is described by the" - " terminology capability statement - i.e. a particular installation, " - "rather than the capabilities of a software program." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for terminology capabilities (if applicable)", - description=( - "A legal or geographic region in which the terminology capabilities is " - "intended to be used." - ), - # if property is element of this resource. - element_property=True, - ) - - kind: fhirtypes.Code = Field( - None, - alias="kind", - title="instance | capability | requirements", - description=( - "The way that this statement is intended to be used, to describe an " - "actual running instance of software, a particular product (kind, not " - "instance of software) or a class of implementation (e.g. a desired " - "purchase)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["instance", "capability", "requirements"], - ) - kind__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_kind", title="Extension field for ``kind``." - ) - - lockedDate: bool = Field( - None, - alias="lockedDate", - title="Whether lockedDate is supported", - description="Whether the server supports lockedDate.", - # if property is element of this resource. - element_property=True, - ) - lockedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lockedDate", title="Extension field for ``lockedDate``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this terminology capabilities (computer friendly)", - description=( - "A natural language name identifying the terminology capabilities. This" - " name should be usable as an identifier for the module by machine " - "processing applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the " - "terminology capabilities." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this terminology capabilities is defined", - description=( - "Explanation of why this terminology capabilities is needed and why it " - "has been designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - software: fhirtypes.TerminologyCapabilitiesSoftwareType = Field( - None, - alias="software", - title="Software that is covered by this terminology capability statement", - description=( - "Software that is covered by this terminology capability statement. It" - " is used when the statement describes the capabilities of a particular" - " software version, independent of an installation." - ), - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this terminology capabilities. Enables tracking the " - "life-cycle of the content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this terminology capabilities (human friendly)", - description=( - "A short, descriptive, user-friendly title for the terminology " - "capabilities." - ), - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - translation: fhirtypes.TerminologyCapabilitiesTranslationType = Field( - None, - alias="translation", - title=( - "Information about the [ConceptMap/$translate](conceptmap-operation-" - "translate.html) operation" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this terminology capabilities, represented as" - " a URI (globally unique)" - ), - description=( - "An absolute URI that is used to identify this terminology capabilities" - " when it is referenced in a specification, model, design or an " - "instance; also called its canonical identifier. This SHOULD be " - "globally unique and SHOULD be a literal address at which at which an " - "authoritative instance of this terminology capabilities is (or will " - "be) published. This URL can be the target of a canonical reference. It" - " SHALL remain the same when the terminology capabilities is stored on " - "different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate terminology capabilities " - "instances." - ), - # if property is element of this resource. - element_property=True, - ) - - validateCode: fhirtypes.TerminologyCapabilitiesValidateCodeType = Field( - None, - alias="validateCode", - title=( - "Information about the [ValueSet/$validate-code](valueset-operation-" - "validate-code.html) operation" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the terminology capabilities", - description=( - "The identifier that is used to identify this version of the " - "terminology capabilities when it is referenced in a specification, " - "model, design or instance. This is an arbitrary value managed by the " - "terminology capabilities author and is not expected to be globally " - "unique. For example, it might be a timestamp (e.g. yyyymmdd) if a " - "managed version is not available. There is also no expectation that " - "versions can be placed in a lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TerminologyCapabilities`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "version", - "name", - "title", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "copyright", - "kind", - "software", - "implementation", - "lockedDate", - "codeSystem", - "expansion", - "codeSearch", - "validateCode", - "translation", - "closure", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2602( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("date", "date__ext"), - ("kind", "kind__ext"), - ("status", "status__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TerminologyCapabilitiesClosure(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about the [ConceptMap/$closure](conceptmap-operation- - closure.html) operation. - Whether the $closure operation is supported. - """ - - resource_type = Field("TerminologyCapabilitiesClosure", const=True) - - translation: bool = Field( - None, - alias="translation", - title="If cross-system closure is supported", - description=None, - # if property is element of this resource. - element_property=True, - ) - translation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_translation", title="Extension field for ``translation``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TerminologyCapabilitiesClosure`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "translation"] - - -class TerminologyCapabilitiesCodeSystem(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A code system supported by the server. - Identifies a code system that is supported by the server. If there is a no - code system URL, then this declares the general assumptions a client can - make about support for any CodeSystem resource. - """ - - resource_type = Field("TerminologyCapabilitiesCodeSystem", const=True) - - subsumption: bool = Field( - None, - alias="subsumption", - title="Whether subsumption is supported", - description="True if subsumption is supported for this version of the code system.", - # if property is element of this resource. - element_property=True, - ) - subsumption__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_subsumption", title="Extension field for ``subsumption``." - ) - - uri: fhirtypes.Canonical = Field( - None, - alias="uri", - title="URI for the Code System", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CodeSystem"], - ) - uri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_uri", title="Extension field for ``uri``." - ) - - version: typing.List[ - fhirtypes.TerminologyCapabilitiesCodeSystemVersionType - ] = Field( - None, - alias="version", - title="Version of Code System supported", - description=( - "For the code system, a list of versions that are supported by the " - "server." - ), - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TerminologyCapabilitiesCodeSystem`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "uri", "version", "subsumption"] - - -class TerminologyCapabilitiesCodeSystemVersion(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Version of Code System supported. - For the code system, a list of versions that are supported by the server. - """ - - resource_type = Field("TerminologyCapabilitiesCodeSystemVersion", const=True) - - code: fhirtypes.String = Field( - None, - alias="code", - title="Version identifier for this version", - description=( - "For version-less code systems, there should be a single version with " - "no identifier." - ), - # if property is element of this resource. - element_property=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - compositional: bool = Field( - None, - alias="compositional", - title="If compositional grammar is supported", - description="If the compositional grammar defined by the code system is supported.", - # if property is element of this resource. - element_property=True, - ) - compositional__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_compositional", title="Extension field for ``compositional``." - ) - - filter: typing.List[ - fhirtypes.TerminologyCapabilitiesCodeSystemVersionFilterType - ] = Field( - None, - alias="filter", - title="Filter Properties supported", - description=None, - # if property is element of this resource. - element_property=True, - ) - - isDefault: bool = Field( - None, - alias="isDefault", - title="If this is the default version for this code system", - description=None, - # if property is element of this resource. - element_property=True, - ) - isDefault__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_isDefault", title="Extension field for ``isDefault``." - ) - - language: typing.List[fhirtypes.Code] = Field( - None, - alias="language", - title="Language Displays supported", - description=None, - # if property is element of this resource. - element_property=True, - ) - language__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_language", title="Extension field for ``language``.") - - property: typing.List[fhirtypes.Code] = Field( - None, - alias="property", - title="Properties supported for $lookup", - description=None, - # if property is element of this resource. - element_property=True, - ) - property__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_property", title="Extension field for ``property``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TerminologyCapabilitiesCodeSystemVersion`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "isDefault", - "compositional", - "language", - "filter", - "property", - ] - - -class TerminologyCapabilitiesCodeSystemVersionFilter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Filter Properties supported. - """ - - resource_type = Field("TerminologyCapabilitiesCodeSystemVersionFilter", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Code of the property supported", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - op: typing.List[fhirtypes.Code] = Field( - None, - alias="op", - title="Operations supported for the property", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - op__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_op", title="Extension field for ``op``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TerminologyCapabilitiesCodeSystemVersionFilter`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "code", "op"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4981( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext"), ("op", "op__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TerminologyCapabilitiesExpansion(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about the [ValueSet/$expand](valueset-operation-expand.html) - operation. - """ - - resource_type = Field("TerminologyCapabilitiesExpansion", const=True) - - hierarchical: bool = Field( - None, - alias="hierarchical", - title="Whether the server can return nested value sets", - description=None, - # if property is element of this resource. - element_property=True, - ) - hierarchical__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_hierarchical", title="Extension field for ``hierarchical``." - ) - - incomplete: bool = Field( - None, - alias="incomplete", - title="Allow request for incomplete expansions?", - description="Allow request for incomplete expansions?", - # if property is element of this resource. - element_property=True, - ) - incomplete__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_incomplete", title="Extension field for ``incomplete``." - ) - - paging: bool = Field( - None, - alias="paging", - title="Whether the server supports paging on expansion", - description=None, - # if property is element of this resource. - element_property=True, - ) - paging__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_paging", title="Extension field for ``paging``." - ) - - parameter: typing.List[ - fhirtypes.TerminologyCapabilitiesExpansionParameterType - ] = Field( - None, - alias="parameter", - title="Supported expansion parameter", - description=None, - # if property is element of this resource. - element_property=True, - ) - - textFilter: fhirtypes.Markdown = Field( - None, - alias="textFilter", - title="Documentation about text searching works", - description=None, - # if property is element of this resource. - element_property=True, - ) - textFilter__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_textFilter", title="Extension field for ``textFilter``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TerminologyCapabilitiesExpansion`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "hierarchical", - "paging", - "incomplete", - "parameter", - "textFilter", - ] - - -class TerminologyCapabilitiesExpansionParameter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Supported expansion parameter. - """ - - resource_type = Field("TerminologyCapabilitiesExpansionParameter", const=True) - - documentation: fhirtypes.String = Field( - None, - alias="documentation", - title="Description of support for parameter", - description=None, - # if property is element of this resource. - element_property=True, - ) - documentation__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_documentation", title="Extension field for ``documentation``." - ) - - name: fhirtypes.Code = Field( - None, - alias="name", - title="Expansion Parameter name", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TerminologyCapabilitiesExpansionParameter`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "name", "documentation"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4479( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TerminologyCapabilitiesImplementation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - If this describes a specific instance. - Identifies a specific implementation instance that is described by the - terminology capability statement - i.e. a particular installation, rather - than the capabilities of a software program. - """ - - resource_type = Field("TerminologyCapabilitiesImplementation", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Describes this specific instance", - description=( - "Information about the specific installation that this terminology " - "capability statement relates to." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - url: fhirtypes.Url = Field( - None, - alias="url", - title="Base URL for the implementation", - description="An absolute base URL for the implementation.", - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TerminologyCapabilitiesImplementation`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "description", "url"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4075( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("description", "description__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TerminologyCapabilitiesSoftware(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Software that is covered by this terminology capability statement. - Software that is covered by this terminology capability statement. It is - used when the statement describes the capabilities of a particular software - version, independent of an installation. - """ - - resource_type = Field("TerminologyCapabilitiesSoftware", const=True) - - name: fhirtypes.String = Field( - None, - alias="name", - title="A name the software is known by", - description="Name the software is known by.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Version covered by this statement", - description="The version identifier for the software covered by this statement.", - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TerminologyCapabilitiesSoftware`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "name", "version"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3431( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TerminologyCapabilitiesTranslation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about the [ConceptMap/$translate](conceptmap-operation- - translate.html) operation. - """ - - resource_type = Field("TerminologyCapabilitiesTranslation", const=True) - - needsMap: bool = Field( - None, - alias="needsMap", - title="Whether the client must identify the map", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - needsMap__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_needsMap", title="Extension field for ``needsMap``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TerminologyCapabilitiesTranslation`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "needsMap"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3764( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("needsMap", "needsMap__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TerminologyCapabilitiesValidateCode(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about the [ValueSet/$validate-code](valueset-operation- - validate-code.html) operation. - """ - - resource_type = Field("TerminologyCapabilitiesValidateCode", const=True) - - translations: bool = Field( - None, - alias="translations", - title="Whether translations are validated", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - translations__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_translations", title="Extension field for ``translations``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TerminologyCapabilitiesValidateCode`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "translations"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3777( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("translations", "translations__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/testreport.py b/fhir/resources/testreport.py deleted file mode 100644 index 838ff9fd..00000000 --- a/fhir/resources/testreport.py +++ /dev/null @@ -1,858 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/TestReport -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class TestReport(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Describes the results of a TestScript execution. - A summary of information based on the results of executing a TestScript. - """ - - resource_type = Field("TestReport", const=True) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="External identifier", - description=( - "Identifier for the TestScript assigned for external purposes outside " - "the context of FHIR." - ), - # if property is element of this resource. - element_property=True, - ) - - issued: fhirtypes.DateTime = Field( - None, - alias="issued", - title="When the TestScript was executed and this TestReport was generated", - description=None, - # if property is element of this resource. - element_property=True, - ) - issued__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_issued", title="Extension field for ``issued``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Informal name of the executed TestScript", - description="A free text natural language name identifying the executed TestScript.", - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - participant: typing.List[fhirtypes.TestReportParticipantType] = Field( - None, - alias="participant", - title=( - "A participant in the test execution, either the execution engine, a " - "client, or a server" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - result: fhirtypes.Code = Field( - None, - alias="result", - title="pass | fail | pending", - description="The overall result from the execution of the TestScript.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["pass", "fail", "pending"], - ) - result__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_result", title="Extension field for ``result``." - ) - - score: fhirtypes.Decimal = Field( - None, - alias="score", - title=( - "The final score (percentage of tests passed) resulting from the " - "execution of the TestScript" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - score__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_score", title="Extension field for ``score``." - ) - - setup: fhirtypes.TestReportSetupType = Field( - None, - alias="setup", - title=( - "The results of the series of required setup operations before the " - "tests were executed" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="completed | in-progress | waiting | stopped | entered-in-error", - description="The current state of this test report.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "completed", - "in-progress", - "waiting", - "stopped", - "entered-in-error", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - teardown: fhirtypes.TestReportTeardownType = Field( - None, - alias="teardown", - title="The results of running the series of required clean up steps", - description=( - "The results of the series of operations required to clean up after all" - " the tests were executed (successfully or otherwise)." - ), - # if property is element of this resource. - element_property=True, - ) - - test: typing.List[fhirtypes.TestReportTestType] = Field( - None, - alias="test", - title="A test executed from the test script", - description=None, - # if property is element of this resource. - element_property=True, - ) - - testScript: fhirtypes.ReferenceType = Field( - ..., - alias="testScript", - title=( - "Reference to the version-specific TestScript that was executed to " - "produce this TestReport" - ), - description=( - "Ideally this is an absolute URL that is used to identify the version-" - "specific TestScript that was executed, matching the `TestScript.url`." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["TestScript"], - ) - - tester: fhirtypes.String = Field( - None, - alias="tester", - title="Name of the tester producing this report (Organization or individual)", - description=None, - # if property is element of this resource. - element_property=True, - ) - tester__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_tester", title="Extension field for ``tester``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestReport`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "name", - "status", - "testScript", - "result", - "score", - "tester", - "issued", - "participant", - "setup", - "test", - "teardown", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1252( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("result", "result__ext"), ("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestReportParticipant(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A participant in the test execution, either the execution engine, a client, - or a server. - """ - - resource_type = Field("TestReportParticipant", const=True) - - display: fhirtypes.String = Field( - None, - alias="display", - title="The display name of the participant", - description=None, - # if property is element of this resource. - element_property=True, - ) - display__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_display", title="Extension field for ``display``." - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title="test-engine | client | server", - description="The type of participant.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["test-engine", "client", "server"], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - uri: fhirtypes.Uri = Field( - None, - alias="uri", - title="The uri of the participant. An absolute URL is preferred", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - uri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_uri", title="Extension field for ``uri``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestReportParticipant`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "type", "uri", "display"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2403( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext"), ("uri", "uri__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestReportSetup(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The results of the series of required setup operations before the tests - were executed. - """ - - resource_type = Field("TestReportSetup", const=True) - - action: typing.List[fhirtypes.TestReportSetupActionType] = Field( - ..., - alias="action", - title="A setup operation or assert that was executed", - description="Action would contain either an operation or an assertion.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestReportSetup`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "action"] - - -class TestReportSetupAction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A setup operation or assert that was executed. - Action would contain either an operation or an assertion. - """ - - resource_type = Field("TestReportSetupAction", const=True) - - assert_fhir: fhirtypes.TestReportSetupActionAssertType = Field( - None, - alias="assert", - title="The assertion to perform", - description="The results of the assertion performed on the previous operations.", - # if property is element of this resource. - element_property=True, - ) - - operation: fhirtypes.TestReportSetupActionOperationType = Field( - None, - alias="operation", - title="The operation to perform", - description="The operation performed.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestReportSetupAction`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "operation", "assert"] - - -class TestReportSetupActionAssert(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The assertion to perform. - The results of the assertion performed on the previous operations. - """ - - resource_type = Field("TestReportSetupActionAssert", const=True) - - detail: fhirtypes.String = Field( - None, - alias="detail", - title="A link to further details on the result", - description=None, - # if property is element of this resource. - element_property=True, - ) - detail__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_detail", title="Extension field for ``detail``." - ) - - message: fhirtypes.Markdown = Field( - None, - alias="message", - title="A message associated with the result", - description="An explanatory message associated with the result.", - # if property is element of this resource. - element_property=True, - ) - message__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_message", title="Extension field for ``message``." - ) - - result: fhirtypes.Code = Field( - None, - alias="result", - title="pass | skip | fail | warning | error", - description="The result of this assertion.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["pass", "skip", "fail", "warning", "error"], - ) - result__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_result", title="Extension field for ``result``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestReportSetupActionAssert`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "result", "message", "detail"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3013( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("result", "result__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestReportSetupActionOperation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The operation to perform. - The operation performed. - """ - - resource_type = Field("TestReportSetupActionOperation", const=True) - - detail: fhirtypes.Uri = Field( - None, - alias="detail", - title="A link to further details on the result", - description=None, - # if property is element of this resource. - element_property=True, - ) - detail__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_detail", title="Extension field for ``detail``." - ) - - message: fhirtypes.Markdown = Field( - None, - alias="message", - title="A message associated with the result", - description="An explanatory message associated with the result.", - # if property is element of this resource. - element_property=True, - ) - message__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_message", title="Extension field for ``message``." - ) - - result: fhirtypes.Code = Field( - None, - alias="result", - title="pass | skip | fail | warning | error", - description="The result of this operation.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["pass", "skip", "fail", "warning", "error"], - ) - result__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_result", title="Extension field for ``result``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestReportSetupActionOperation`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "result", "message", "detail"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3326( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("result", "result__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestReportTeardown(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The results of running the series of required clean up steps. - The results of the series of operations required to clean up after all the - tests were executed (successfully or otherwise). - """ - - resource_type = Field("TestReportTeardown", const=True) - - action: typing.List[fhirtypes.TestReportTeardownActionType] = Field( - ..., - alias="action", - title="One or more teardown operations performed", - description="The teardown action will only contain an operation.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestReportTeardown`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "action"] - - -class TestReportTeardownAction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - One or more teardown operations performed. - The teardown action will only contain an operation. - """ - - resource_type = Field("TestReportTeardownAction", const=True) - - operation: fhirtypes.TestReportSetupActionOperationType = Field( - ..., - alias="operation", - title="The teardown operation performed", - description="An operation would involve a REST request to a server.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestReportTeardownAction`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "operation"] - - -class TestReportTest(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A test executed from the test script. - """ - - resource_type = Field("TestReportTest", const=True) - - action: typing.List[fhirtypes.TestReportTestActionType] = Field( - ..., - alias="action", - title="A test operation or assert that was performed", - description="Action would contain either an operation or an assertion.", - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Tracking/reporting short description of the test", - description=( - "A short description of the test used by test engines for tracking and " - "reporting purposes." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Tracking/logging name of this test", - description=( - "The name of this test used for tracking/logging purposes by test " - "engines." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestReportTest`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "name", "description", "action"] - - -class TestReportTestAction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A test operation or assert that was performed. - Action would contain either an operation or an assertion. - """ - - resource_type = Field("TestReportTestAction", const=True) - - assert_fhir: fhirtypes.TestReportSetupActionAssertType = Field( - None, - alias="assert", - title="The assertion performed", - description="The results of the assertion performed on the previous operations.", - # if property is element of this resource. - element_property=True, - ) - - operation: fhirtypes.TestReportSetupActionOperationType = Field( - None, - alias="operation", - title="The operation performed", - description="An operation would involve a REST request to a server.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestReportTestAction`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "operation", "assert"] diff --git a/fhir/resources/tests/__init__.py b/fhir/resources/tests/__init__.py deleted file mode 100644 index 4bd1e4b2..00000000 --- a/fhir/resources/tests/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -__fhir_version__ = "4.0.1" diff --git a/fhir/resources/tests/conftest.py b/fhir/resources/tests/conftest.py deleted file mode 100644 index 38f2100f..00000000 --- a/fhir/resources/tests/conftest.py +++ /dev/null @@ -1 +0,0 @@ -pytest_plugins = ["fhir.resources.tests.fixtures"] diff --git a/fhir/resources/tests/fixtures.py b/fhir/resources/tests/fixtures.py deleted file mode 100644 index 9308c0b9..00000000 --- a/fhir/resources/tests/fixtures.py +++ /dev/null @@ -1,87 +0,0 @@ -import hashlib -import io -import os -import pathlib -import shutil -import sys -import tempfile -import zipfile -from os.path import dirname - -import pytest # type: ignore - -EXAMPLE_RESOURCES_URL = ( - "https://github.com/nazrulworld/hl7-archives/raw/" - "0.2.1/FHIR/R4/" - "4.0.1-examples-json.zip" -) -ROOT_PATH = dirname(dirname(dirname(dirname(os.path.abspath(__file__))))) -CACHE_PATH = os.path.join(ROOT_PATH, ".cache") - - -def download_and_store(url, path): - """ """ - import requests - - try: - sys.stdout.write("Attempting to download from {0}\n".format(url)) - ret = requests.get(url) - except requests.HTTPError as exc: - raise LookupError("Failed to download. Full error: {0!s}".format(exc)) - else: - if not ret.ok: - raise Exception("Failed to download {0}".format(url)) - with io.open(path, "wb") as handle: - for chunk in ret.iter_content(): - handle.write(chunk) - sys.stdout.write( - "Download has been completed, now saved to {0}\n".format(path) - ) - - -def expand(self, local): - """Expand the ZIP file at the given path to the cache directory.""" - path = os.path.join(self.cache, local) - assert os.path.exists(path) - import zipfile # import here as we can bypass its use with a manual unzip - - with zipfile.ZipFile(path) as z: - z.extractall(self.cache) - - -@pytest.fixture(scope="session") -def base_settings(): - - if not os.path.exists(CACHE_PATH): - os.makedirs(CACHE_PATH) - - settings = {} - - example_data_file_uri = EXAMPLE_RESOURCES_URL - - example_data_file_id = hashlib.md5(example_data_file_uri.encode()).hexdigest() - - example_data_file_location = os.path.join( - CACHE_PATH, (example_data_file_id + ".zip") - ) - - if not os.path.exists(example_data_file_location): - download_and_store(example_data_file_uri, example_data_file_location) - - temp_data_dir = tempfile.mkdtemp() - # extract all files from archive and put into temp dir - with zipfile.ZipFile(example_data_file_location) as z: - z.extractall(temp_data_dir) - - zip_dir_name = pathlib.Path(EXAMPLE_RESOURCES_URL).name[:-4] - if "FHIR_UNITTEST_DATADIR" not in os.environ: - os.environ.setdefault( - "FHIR_UNITTEST_DATADIR", os.path.join(temp_data_dir, zip_dir_name) - ) - - settings["unittest_data_dir"] = pathlib.Path(os.environ["FHIR_UNITTEST_DATADIR"]) - - yield settings - - os.environ.pop("FHIR_UNITTEST_DATADIR") - shutil.rmtree(temp_data_dir) diff --git a/fhir/resources/tests/test_account.py b/fhir/resources/tests/test_account.py deleted file mode 100644 index bba45282..00000000 --- a/fhir/resources/tests/test_account.py +++ /dev/null @@ -1,135 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Account -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import account - - -def impl_account_1(inst): - assert inst.coverage[0].coverage.reference == "Coverage/7546D" - assert inst.coverage[0].priority == 1 - assert inst.description == "Hospital charges" - assert inst.id == "example" - assert inst.identifier[0].system == "urn:oid:0.1.2.3.4.5.6.7" - assert inst.identifier[0].value == "654321" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "HACC Funded Billing for Peter James Chalmers" - assert inst.owner.reference == "Organization/hl7" - assert inst.servicePeriod.end == fhirtypes.DateTime.validate( - "2016-06-30T12:09:24+00:06" - ) - assert inst.servicePeriod.start == fhirtypes.DateTime.validate( - "2016-01-01T12:09:24+00:06" - ) - assert inst.status == "active" - assert inst.subject[0].display == "Peter James Chalmers" - assert inst.subject[0].reference == "Patient/example" - assert inst.text.div == ( - '
HACC Funded ' - "Billing for Peter James Chalmers
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "PBILLACCT" - assert inst.type.coding[0].display == "patient billing account" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.type.text == "patient" - - -def test_account_1(base_settings): - """No. 1 tests collection for Account. - Test File: account-example.json - """ - filename = base_settings["unittest_data_dir"] / "account-example.json" - inst = account.Account.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Account" == inst.resource_type - - impl_account_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Account" == data["resourceType"] - - inst2 = account.Account(**data) - impl_account_1(inst2) - - -def impl_account_2(inst): - assert inst.coverage[0].coverage.reference == "Coverage/9876B1" - assert inst.coverage[0].priority == 1 - assert inst.coverage[1].coverage.reference == "Coverage/7546D" - assert inst.coverage[1].priority == 2 - assert inst.description == "Hospital charges" - assert inst.guarantor[0].onHold is False - assert inst.guarantor[0].party.display == "Bénédicte du Marché" - assert inst.guarantor[0].party.reference == "RelatedPerson/benedicte" - assert inst.guarantor[0].period.start == fhirtypes.DateTime.validate( - "2016-01-01T12:09:24+00:06" - ) - assert inst.id == "ewg" - assert inst.identifier[0].system == "urn:oid:0.1.2.3.4.5.6.7" - assert inst.identifier[0].value == "654321" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Inpatient: Peter James Chalmers" - assert inst.owner.display == "Burgers University Medical Center" - assert inst.owner.reference == "Organization/f001" - assert inst.servicePeriod.end == fhirtypes.DateTime.validate( - "2016-06-30T12:09:24+00:06" - ) - assert inst.servicePeriod.start == fhirtypes.DateTime.validate( - "2016-01-01T12:09:24+00:06" - ) - assert inst.status == "active" - assert inst.subject[0].display == "Peter James Chalmers" - assert inst.subject[0].reference == "Patient/example" - assert inst.text.div == ( - '
Inpatient ' - "Admission for Peter James Chalmers Account
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "PBILLACCT" - assert inst.type.coding[0].display == "patient billing account" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.type.text == "patient" - - -def test_account_2(base_settings): - """No. 2 tests collection for Account. - Test File: account-example-with-guarantor.json - """ - filename = ( - base_settings["unittest_data_dir"] / "account-example-with-guarantor.json" - ) - inst = account.Account.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Account" == inst.resource_type - - impl_account_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Account" == data["resourceType"] - - inst2 = account.Account(**data) - impl_account_2(inst2) diff --git a/fhir/resources/tests/test_activitydefinition.py b/fhir/resources/tests/test_activitydefinition.py deleted file mode 100644 index 641bf61d..00000000 --- a/fhir/resources/tests/test_activitydefinition.py +++ /dev/null @@ -1,911 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ActivityDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import activitydefinition - - -def impl_activitydefinition_1(inst): - assert inst.code.coding[0].code == "zika-virus-exposure-assessment" - assert inst.code.coding[0].system == "http://example.org/questionnaires" - assert inst.description == "Administer Zika Virus Exposure Assessment" - assert inst.id == "administer-zika-virus-exposure-assessment" - assert inst.kind == "ServiceRequest" - assert inst.library[0] == "Library/zika-virus-intervention-logic" - assert inst.participant[0].type == "practitioner" - assert inst.relatedArtifact[0].type == "derived-from" - assert ( - inst.relatedArtifact[0].url - == "https://www.cdc.gov/zika/hc-providers/pregnant-woman.html" - ) - assert ( - inst.relatedArtifact[1].resource - == "Questionnaire/zika-virus-exposure-assessment" - ) - assert inst.relatedArtifact[1].type == "depends-on" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == ( - "http://example.org/ActivityDefinition/administer-zika-virus-" - "exposure-assessment" - ) - assert inst.useContext[0].code.code == "age" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueRange.low.unit == "a" - assert float(inst.useContext[0].valueRange.low.value) == float(12) - - -def test_activitydefinition_1(base_settings): - """No. 1 tests collection for ActivityDefinition. - Test File: activitydefinition-administer-zika-virus-exposure-assessment.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "activitydefinition-administer-zika-virus-exposure-assessment.json" - ) - inst = activitydefinition.ActivityDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ActivityDefinition" == inst.resource_type - - impl_activitydefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ActivityDefinition" == data["resourceType"] - - inst2 = activitydefinition.ActivityDefinition(**data) - impl_activitydefinition_1(inst2) - - -def impl_activitydefinition_2(inst): - assert inst.code.text == "Provide Mosquito Prevention Advice" - assert inst.description == "Provide mosquito prevention advice" - assert inst.id == "provide-mosquito-prevention-advice" - assert inst.kind == "CommunicationRequest" - assert inst.library[0] == "Library/zika-virus-intervention-logic" - assert inst.participant[0].type == "practitioner" - assert ( - inst.relatedArtifact[0].display - == "Advice for patients about how to avoid Mosquito bites." - ) - assert inst.relatedArtifact[0].type == "documentation" - assert ( - inst.relatedArtifact[0].url == "http://www.cdc.gov/zika/prevention/index.html" - ) - assert inst.relatedArtifact[1].display == ( - "Advice for patients about which mosquito repellents are " - "effective and safe to use in pregnancy. [DEET, IF3535 and " - "Picardin are safe during]" - ) - assert inst.relatedArtifact[1].type == "documentation" - assert inst.relatedArtifact[1].url == ( - "https://www.epa.gov/insect-repellents/find-insect-repellent-" "right-you" - ) - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == ( - "http://example.org/ActivityDefinition/provide-mosquito-" "prevention-advice" - ) - - -def test_activitydefinition_2(base_settings): - """No. 2 tests collection for ActivityDefinition. - Test File: activitydefinition-provide-mosquito-prevention-advice.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "activitydefinition-provide-mosquito-prevention-advice.json" - ) - inst = activitydefinition.ActivityDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ActivityDefinition" == inst.resource_type - - impl_activitydefinition_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ActivityDefinition" == data["resourceType"] - - inst2 = activitydefinition.ActivityDefinition(**data) - impl_activitydefinition_2(inst2) - - -def impl_activitydefinition_3(inst): - assert inst.approvalDate == fhirtypes.Date.validate("2016-03-12") - assert inst.author[0].name == "Motive Medical Intelligence" - assert inst.author[0].telecom[0].system == "phone" - assert inst.author[0].telecom[0].use == "work" - assert inst.author[0].telecom[0].value == "415-362-4007" - assert inst.author[0].telecom[1].system == "email" - assert inst.author[0].telecom[1].use == "work" - assert inst.author[0].telecom[1].value == "info@motivemi.com" - assert inst.code.coding[0].code == "306206005" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Referral to service (procedure)" - assert inst.contact[0].telecom[0].system == "phone" - assert inst.contact[0].telecom[0].use == "work" - assert inst.contact[0].telecom[0].value == "415-362-4007" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].use == "work" - assert inst.contact[0].telecom[1].value == "info@motivemi.com" - assert inst.copyright == ( - "© Copyright 2016 Motive Medical Intelligence. All rights " "reserved." - ) - assert inst.date == fhirtypes.DateTime.validate("2017-03-03T14:06:00Z") - assert inst.description == ( - "refer to primary care mental-health integrated care program " - "for evaluation and treatment of mental health conditions now" - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2017-12-31T12:09:24+00:06" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2016-01-01T12:09:24+00:06" - ) - assert inst.experimental is True - assert inst.id == "referralPrimaryCareMentalHealth-initial" - assert inst.identifier[0].system == "http://motivemi.com/artifacts" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "referralPrimaryCareMentalHealth" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.kind == "ServiceRequest" - assert inst.lastReviewDate == fhirtypes.Date.validate("2016-08-15") - assert inst.name == "ReferralPrimaryCareMentalHealth" - assert inst.participant[0].type == "practitioner" - assert inst.publisher == "Motive Medical Intelligence" - assert inst.relatedArtifact[0].display == ( - "Practice Guideline for the Treatment of Patients with Major " - "Depressive Disorder" - ) - assert inst.relatedArtifact[0].type == "citation" - assert inst.relatedArtifact[0].url == ( - "http://psychiatryonline.org/pb/assets/raw/sitewide/practice_" - "guidelines/guidelines/mdd.pdf" - ) - assert ( - inst.relatedArtifact[1].resource - == "ActivityDefinition/referralPrimaryCareMentalHealth" - ) - assert inst.relatedArtifact[1].type == "successor" - assert inst.status == "retired" - assert inst.text.status == "generated" - assert inst.title == "Referral to Primary Care Mental Health" - assert inst.topic[0].text == "Mental Health Referral" - assert inst.url == ( - "http://motivemi.com/artifacts/ActivityDefinition/referralPri" - "maryCareMentalHealth" - ) - assert inst.useContext[0].code.code == "age" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "D000328" - assert inst.useContext[0].valueCodeableConcept.coding[0].display == "Adult" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "https://meshb.nlm.nih.gov" - ) - assert inst.useContext[1].code.code == "focus" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "87512008" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].display - == "Mild major depression" - ) - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[2].code.code == "focus" - assert ( - inst.useContext[2].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[2].valueCodeableConcept.coding[0].code == "40379007" - assert ( - inst.useContext[2].valueCodeableConcept.coding[0].display - == "Major depression, recurrent, mild" - ) - assert ( - inst.useContext[2].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[3].code.code == "focus" - assert ( - inst.useContext[3].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[3].valueCodeableConcept.coding[0].code == "225444004" - assert ( - inst.useContext[3].valueCodeableConcept.coding[0].display - == "At risk for suicide (finding)" - ) - assert ( - inst.useContext[3].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[4].code.code == "focus" - assert ( - inst.useContext[4].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[4].valueCodeableConcept.coding[0].code == "306206005" - assert ( - inst.useContext[4].valueCodeableConcept.coding[0].display - == "Referral to service (procedure)" - ) - assert ( - inst.useContext[4].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[5].code.code == "user" - assert ( - inst.useContext[5].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[5].valueCodeableConcept.coding[0].code == "309343006" - assert inst.useContext[5].valueCodeableConcept.coding[0].display == "Physician" - assert ( - inst.useContext[5].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[6].code.code == "venue" - assert ( - inst.useContext[6].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[6].valueCodeableConcept.coding[0].code == "440655000" - assert ( - inst.useContext[6].valueCodeableConcept.coding[0].display - == "Outpatient environment" - ) - assert ( - inst.useContext[6].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "1.0.0" - - -def test_activitydefinition_3(base_settings): - """No. 3 tests collection for ActivityDefinition. - Test File: activitydefinition-predecessor-example.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "activitydefinition-predecessor-example.json" - ) - inst = activitydefinition.ActivityDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ActivityDefinition" == inst.resource_type - - impl_activitydefinition_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ActivityDefinition" == data["resourceType"] - - inst2 = activitydefinition.ActivityDefinition(**data) - impl_activitydefinition_3(inst2) - - -def impl_activitydefinition_4(inst): - assert inst.code.text == "Serum Zika and Dengue Virus IgM" - assert inst.description == "Order Serum Zika and Dengue Virus IgM" - assert inst.id == "serum-zika-dengue-virus-igm" - assert inst.kind == "ServiceRequest" - assert inst.library[0] == "Library/zika-virus-intervention-logic" - assert inst.participant[0].type == "practitioner" - assert inst.relatedArtifact[0].display == ( - "Explanation of diagnostic tests for Zika virus and which to " - "use based on the patient’s clinical and exposure history." - ) - assert inst.relatedArtifact[0].type == "documentation" - assert ( - inst.relatedArtifact[0].url - == "http://www.cdc.gov/zika/hc-providers/diagnostic.html" - ) - assert ( - inst.relatedArtifact[1].resource == "ActivityDefinition/serum-dengue-virus-igm" - ) - assert inst.relatedArtifact[1].type == "derived-from" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == ( - "http://example.org/ActivityDefinition/serum-zika-dengue-" "virus-igm" - ) - - -def test_activitydefinition_4(base_settings): - """No. 4 tests collection for ActivityDefinition. - Test File: activitydefinition-order-serum-zika-dengue-virus-igm.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "activitydefinition-order-serum-zika-dengue-virus-igm.json" - ) - inst = activitydefinition.ActivityDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ActivityDefinition" == inst.resource_type - - impl_activitydefinition_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ActivityDefinition" == data["resourceType"] - - inst2 = activitydefinition.ActivityDefinition(**data) - impl_activitydefinition_4(inst2) - - -def impl_activitydefinition_5(inst): - assert inst.approvalDate == fhirtypes.Date.validate("2016-03-12") - assert inst.author[0].name == "Motive Medical Intelligence" - assert inst.author[0].telecom[0].system == "phone" - assert inst.author[0].telecom[0].use == "work" - assert inst.author[0].telecom[0].value == "415-362-4007" - assert inst.author[0].telecom[1].system == "email" - assert inst.author[0].telecom[1].use == "work" - assert inst.author[0].telecom[1].value == "info@motivemi.com" - assert inst.contact[0].telecom[0].system == "phone" - assert inst.contact[0].telecom[0].use == "work" - assert inst.contact[0].telecom[0].value == "415-362-4007" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].use == "work" - assert inst.contact[0].telecom[1].value == "info@motivemi.com" - assert inst.contained[0].id == "citalopramMedication" - assert inst.contained[1].id == "citalopramSubstance" - assert inst.copyright == ( - "© Copyright 2016 Motive Medical Intelligence. All rights " "reserved." - ) - assert inst.date == fhirtypes.DateTime.validate("2015-08-15T12:09:24+00:06") - assert inst.description == ( - "Citalopram 20 mg tablet 1 tablet oral 1 time daily now (30 " "table; 3 refills" - ) - assert inst.dosage[0].doseAndRate[0].doseQuantity.unit == "{tbl}" - assert float(inst.dosage[0].doseAndRate[0].doseQuantity.value) == float(1) - assert inst.dosage[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosage[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosage[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosage[0].route.coding[0].code == "26643006" - assert inst.dosage[0].route.coding[0].display == "Oral route (qualifier value)" - assert inst.dosage[0].route.text == "Oral route (qualifier value)" - assert inst.dosage[0].text == "1 tablet oral 1 time daily" - assert inst.dosage[0].timing.repeat.frequency == 1 - assert float(inst.dosage[0].timing.repeat.period) == float(1) - assert inst.dosage[0].timing.repeat.periodUnit == "d" - assert ( - inst.dynamicValue[0].expression.description - == "dispenseRequest.numberOfRepeatsAllowed is three (3)" - ) - assert inst.dynamicValue[0].expression.expression == "3" - assert inst.dynamicValue[0].expression.language == "text/cql" - assert inst.dynamicValue[0].path == "dispenseRequest.numberOfRepeatsAllowed" - assert ( - inst.dynamicValue[1].expression.description - == "dispenseRequest.quantity is thirty (30) tablets" - ) - assert inst.dynamicValue[1].expression.expression == "30 '{tbl}'" - assert inst.dynamicValue[1].expression.language == "text/cql" - assert inst.dynamicValue[1].path == "dispenseRequest.quantity" - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2017-12-31T12:09:24+00:06" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2016-01-01T12:09:24+00:06" - ) - assert inst.experimental is True - assert inst.id == "citalopramPrescription" - assert inst.identifier[0].system == "http://motivemi.com" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "citalopramPrescription" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.kind == "MedicationRequest" - assert inst.lastReviewDate == fhirtypes.Date.validate("2016-08-15") - assert inst.name == "CitalopramPrescription" - assert inst.productReference.reference == "#citalopramMedication" - assert inst.publisher == "Motive Medical Intelligence" - assert inst.purpose == ( - "Defines a guideline supported prescription for the treatment" - " of depressive disorders" - ) - assert inst.relatedArtifact[0].display == ( - "Practice Guideline for the Treatment of Patients with Major " - "Depressive Disorder" - ) - assert inst.relatedArtifact[0].type == "citation" - assert inst.relatedArtifact[0].url == ( - "http://psychiatryonline.org/pb/assets/raw/sitewide/practice_" - "guidelines/guidelines/mdd.pdf" - ) - assert inst.relatedArtifact[1].resource == "#citalopramMedication" - assert inst.relatedArtifact[1].type == "composed-of" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Citalopram Prescription" - assert inst.topic[0].text == "Mental Health Treatment" - assert inst.url == ( - "http://motivemi.com/artifacts/ActivityDefinition/citalopramP" "rescription" - ) - assert inst.usage == ( - "This activity definition is used as part of various suicide " "risk order sets" - ) - assert inst.useContext[0].code.code == "age" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "D000328" - assert inst.useContext[0].valueCodeableConcept.coding[0].display == "Adult" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "https://meshb.nlm.nih.gov" - ) - assert inst.useContext[1].code.code == "focus" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "87512008" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].display - == "Mild major depression" - ) - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[2].code.code == "focus" - assert ( - inst.useContext[2].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[2].valueCodeableConcept.coding[0].code == "40379007" - assert ( - inst.useContext[2].valueCodeableConcept.coding[0].display - == "Major depression, recurrent, mild" - ) - assert ( - inst.useContext[2].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[3].code.code == "focus" - assert ( - inst.useContext[3].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[3].valueCodeableConcept.coding[0].code == "225444004" - assert ( - inst.useContext[3].valueCodeableConcept.coding[0].display - == "At risk for suicide (finding)" - ) - assert ( - inst.useContext[3].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[4].code.code == "focus" - assert ( - inst.useContext[4].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[4].valueCodeableConcept.coding[0].code == "306206005" - assert ( - inst.useContext[4].valueCodeableConcept.coding[0].display - == "Referral to service (procedure)" - ) - assert ( - inst.useContext[4].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[5].code.code == "user" - assert ( - inst.useContext[5].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[5].valueCodeableConcept.coding[0].code == "309343006" - assert inst.useContext[5].valueCodeableConcept.coding[0].display == "Physician" - assert ( - inst.useContext[5].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[6].code.code == "venue" - assert ( - inst.useContext[6].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[6].valueCodeableConcept.coding[0].code == "440655000" - assert ( - inst.useContext[6].valueCodeableConcept.coding[0].display - == "Outpatient environment" - ) - assert ( - inst.useContext[6].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "1.0.0" - - -def test_activitydefinition_5(base_settings): - """No. 5 tests collection for ActivityDefinition. - Test File: activitydefinition-medicationorder-example.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "activitydefinition-medicationorder-example.json" - ) - inst = activitydefinition.ActivityDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ActivityDefinition" == inst.resource_type - - impl_activitydefinition_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ActivityDefinition" == data["resourceType"] - - inst2 = activitydefinition.ActivityDefinition(**data) - impl_activitydefinition_5(inst2) - - -def impl_activitydefinition_6(inst): - assert inst.approvalDate == fhirtypes.Date.validate("2017-03-01") - assert inst.author[0].name == "Motive Medical Intelligence" - assert inst.author[0].telecom[0].system == "phone" - assert inst.author[0].telecom[0].use == "work" - assert inst.author[0].telecom[0].value == "415-362-4007" - assert inst.author[0].telecom[1].system == "email" - assert inst.author[0].telecom[1].use == "work" - assert inst.author[0].telecom[1].value == "info@motivemi.com" - assert inst.code.coding[0].code == "306206005" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Referral to service (procedure)" - assert inst.contact[0].telecom[0].system == "phone" - assert inst.contact[0].telecom[0].use == "work" - assert inst.contact[0].telecom[0].value == "415-362-4007" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].use == "work" - assert inst.contact[0].telecom[1].value == "info@motivemi.com" - assert inst.copyright == ( - "© Copyright 2016 Motive Medical Intelligence. All rights " "reserved." - ) - assert inst.date == fhirtypes.DateTime.validate("2017-03-03T14:06:00Z") - assert inst.description == ( - "refer to primary care mental-health integrated care program " - "for evaluation and treatment of mental health conditions now" - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2017-12-31T12:09:24+00:06" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2017-03-01T12:09:24+00:06" - ) - assert inst.experimental is True - assert inst.id == "referralPrimaryCareMentalHealth" - assert inst.identifier[0].system == "http://motivemi.com/artifacts" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "referralPrimaryCareMentalHealth" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.kind == "ServiceRequest" - assert inst.lastReviewDate == fhirtypes.Date.validate("2017-03-01") - assert inst.name == "ReferralPrimaryCareMentalHealth" - assert inst.participant[0].type == "practitioner" - assert inst.publisher == "Motive Medical Intelligence" - assert inst.relatedArtifact[0].display == ( - "Practice Guideline for the Treatment of Patients with Major " - "Depressive Disorder" - ) - assert inst.relatedArtifact[0].type == "citation" - assert inst.relatedArtifact[0].url == ( - "http://psychiatryonline.org/pb/assets/raw/sitewide/practice_" - "guidelines/guidelines/mdd.pdf" - ) - assert ( - inst.relatedArtifact[1].resource - == "ActivityDefinition/referralPrimaryCareMentalHealth-initial" - ) - assert inst.relatedArtifact[1].type == "predecessor" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Referral to Primary Care Mental Health" - assert inst.topic[0].text == "Mental Health Referral" - assert inst.url == ( - "http://motivemi.com/artifacts/ActivityDefinition/referralPri" - "maryCareMentalHealth" - ) - assert inst.useContext[0].code.code == "age" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "D000328" - assert inst.useContext[0].valueCodeableConcept.coding[0].display == "Adult" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "https://meshb.nlm.nih.gov" - ) - assert inst.useContext[1].code.code == "focus" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "87512008" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].display - == "Mild major depression" - ) - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[2].code.code == "focus" - assert ( - inst.useContext[2].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[2].valueCodeableConcept.coding[0].code == "40379007" - assert ( - inst.useContext[2].valueCodeableConcept.coding[0].display - == "Major depression, recurrent, mild" - ) - assert ( - inst.useContext[2].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[3].code.code == "focus" - assert ( - inst.useContext[3].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[3].valueCodeableConcept.coding[0].code == "225444004" - assert ( - inst.useContext[3].valueCodeableConcept.coding[0].display - == "At risk for suicide (finding)" - ) - assert ( - inst.useContext[3].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[4].code.code == "focus" - assert ( - inst.useContext[4].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[4].valueCodeableConcept.coding[0].code == "306206005" - assert ( - inst.useContext[4].valueCodeableConcept.coding[0].display - == "Referral to service (procedure)" - ) - assert ( - inst.useContext[4].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[5].code.code == "user" - assert ( - inst.useContext[5].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[5].valueCodeableConcept.coding[0].code == "309343006" - assert inst.useContext[5].valueCodeableConcept.coding[0].display == "Physician" - assert ( - inst.useContext[5].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[6].code.code == "venue" - assert ( - inst.useContext[6].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[6].valueCodeableConcept.coding[0].code == "440655000" - assert ( - inst.useContext[6].valueCodeableConcept.coding[0].display - == "Outpatient environment" - ) - assert ( - inst.useContext[6].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "1.1.0" - - -def test_activitydefinition_6(base_settings): - """No. 6 tests collection for ActivityDefinition. - Test File: activitydefinition-example.json - """ - filename = base_settings["unittest_data_dir"] / "activitydefinition-example.json" - inst = activitydefinition.ActivityDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ActivityDefinition" == inst.resource_type - - impl_activitydefinition_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ActivityDefinition" == data["resourceType"] - - inst2 = activitydefinition.ActivityDefinition(**data) - impl_activitydefinition_6(inst2) - - -def impl_activitydefinition_7(inst): - assert inst.code.text == "Serum Dengue Virus IgM" - assert inst.description == "Order Serum Dengue Virus IgM" - assert inst.id == "serum-dengue-virus-igm" - assert inst.kind == "ServiceRequest" - assert inst.participant[0].type == "practitioner" - assert inst.relatedArtifact[0].display == ( - "Explanation of diagnostic tests for Dengue virus and which " - "to use based on the patient’s clinical and exposure history." - ) - assert inst.relatedArtifact[0].type == "documentation" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://example.org/ActivityDefinition/serum-dengue-virus-igm" - - -def test_activitydefinition_7(base_settings): - """No. 7 tests collection for ActivityDefinition. - Test File: activitydefinition-order-serum-dengue-virus-igm.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "activitydefinition-order-serum-dengue-virus-igm.json" - ) - inst = activitydefinition.ActivityDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ActivityDefinition" == inst.resource_type - - impl_activitydefinition_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ActivityDefinition" == data["resourceType"] - - inst2 = activitydefinition.ActivityDefinition(**data) - impl_activitydefinition_7(inst2) - - -def impl_activitydefinition_8(inst): - assert inst.bodySite[0].coding[0].code == "17401000" - assert inst.bodySite[0].coding[0].display == "Heart valve structure" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.code.coding[0].code == "34068001" - assert inst.code.coding[0].display == "Heart valve replacement" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.description == "Heart valve replacement" - assert inst.id == "heart-valve-replacement" - assert inst.kind == "ServiceRequest" - assert inst.location.reference == "Location/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participant[0].role.coding[0].code == "207RI0011X" - assert inst.participant[0].role.coding[0].display == "Interventional Cardiology" - assert ( - inst.participant[0].role.coding[0].system == "http://nucc.org/provider-taxonomy" - ) - assert inst.participant[0].role.text == "Interventional Cardiology" - assert inst.participant[0].type == "practitioner" - assert ( - inst.purpose == "Describes the proposal to perform a Heart Valve replacement." - ) - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.topic[0].coding[0].code == "34068001" - assert inst.topic[0].coding[0].display == "Heart valve replacement" - assert inst.topic[0].coding[0].system == "http://snomed.info/sct" - assert inst.useContext[0].code.code == "age" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "D000328" - assert inst.useContext[0].valueCodeableConcept.coding[0].display == "Adult" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "https://meshb.nlm.nih.gov" - ) - assert inst.useContext[1].code.code == "user" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "309343006" - assert inst.useContext[1].valueCodeableConcept.coding[0].display == "Physician" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - - -def test_activitydefinition_8(base_settings): - """No. 8 tests collection for ActivityDefinition. - Test File: activitydefinition-servicerequest-example.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "activitydefinition-servicerequest-example.json" - ) - inst = activitydefinition.ActivityDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ActivityDefinition" == inst.resource_type - - impl_activitydefinition_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ActivityDefinition" == data["resourceType"] - - inst2 = activitydefinition.ActivityDefinition(**data) - impl_activitydefinition_8(inst2) - - -def impl_activitydefinition_9(inst): - assert inst.code.coding[0].code == "BlueTubes" - assert inst.code.coding[0].display == "Blood collect tubes blue cap" - assert inst.description == "10 Blood collect tubes blue cap" - assert inst.id == "blood-tubes-supply" - assert inst.kind == "SupplyRequest" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.purpose == ( - "Describes a request for 10 Blood collection tubes with blue " "caps." - ) - assert float(inst.quantity.value) == float(10) - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.transform == "StructureMap/supplyrequest-transform" - - -def test_activitydefinition_9(base_settings): - """No. 9 tests collection for ActivityDefinition. - Test File: activitydefinition-supplyrequest-example.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "activitydefinition-supplyrequest-example.json" - ) - inst = activitydefinition.ActivityDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ActivityDefinition" == inst.resource_type - - impl_activitydefinition_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ActivityDefinition" == data["resourceType"] - - inst2 = activitydefinition.ActivityDefinition(**data) - impl_activitydefinition_9(inst2) diff --git a/fhir/resources/tests/test_adverseevent.py b/fhir/resources/tests/test_adverseevent.py deleted file mode 100644 index b0265fd3..00000000 --- a/fhir/resources/tests/test_adverseevent.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/AdverseEvent -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import adverseevent - - -def impl_adverseevent_1(inst): - assert inst.actuality == "actual" - assert inst.category[0].coding[0].code == "product-use-error" - assert inst.category[0].coding[0].display == "Product Use Error" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/adverse-event-category" - ) - assert inst.date == fhirtypes.DateTime.validate("2017-01-29T12:34:56+00:00") - assert inst.event.coding[0].code == "304386008" - assert inst.event.coding[0].display == "O/E - itchy rash" - assert inst.event.coding[0].system == "http://snomed.info/sct" - assert inst.event.text == "This was a mild rash on the left forearm" - assert inst.id == "example" - assert inst.identifier.system == "http://acme.com/ids/patients/risks" - assert inst.identifier.value == "49476534" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.recorder.reference == "Practitioner/example" - assert inst.seriousness.coding[0].code == "Non-serious" - assert inst.seriousness.coding[0].display == "Non-serious" - assert inst.seriousness.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/adverse-event-" "seriousness" - ) - assert inst.severity.coding[0].code == "mild" - assert inst.severity.coding[0].display == "Mild" - assert ( - inst.severity.coding[0].system - == "http://terminology.hl7.org/CodeSystem/adverse-event-severity" - ) - assert inst.subject.reference == "Patient/example" - assert inst.suspectEntity[0].instance.reference == "Medication/example" - assert inst.text.status == "generated" - - -def test_adverseevent_1(base_settings): - """No. 1 tests collection for AdverseEvent. - Test File: adverseevent-example.json - """ - filename = base_settings["unittest_data_dir"] / "adverseevent-example.json" - inst = adverseevent.AdverseEvent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AdverseEvent" == inst.resource_type - - impl_adverseevent_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AdverseEvent" == data["resourceType"] - - inst2 = adverseevent.AdverseEvent(**data) - impl_adverseevent_1(inst2) diff --git a/fhir/resources/tests/test_allergyintolerance.py b/fhir/resources/tests/test_allergyintolerance.py deleted file mode 100644 index 30d4de3d..00000000 --- a/fhir/resources/tests/test_allergyintolerance.py +++ /dev/null @@ -1,360 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/AllergyIntolerance -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import allergyintolerance - - -def impl_allergyintolerance_1(inst): - assert inst.clinicalStatus.coding[0].code == "active" - assert inst.clinicalStatus.coding[0].display == "Active" - assert inst.clinicalStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "clinical" - ) - assert inst.code.coding[0].code == "716184000" - assert inst.code.coding[0].display == "No Known Latex Allergy (situation)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "No Known Latex Allergy" - assert inst.id == "nkla" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.recordedDate == fhirtypes.DateTime.validate("2015-08-06T15:37:31-06:00") - assert inst.recorder.reference == "Practitioner/example" - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert inst.verificationStatus.coding[0].display == "Confirmed" - assert inst.verificationStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "verification" - ) - - -def test_allergyintolerance_1(base_settings): - """No. 1 tests collection for AllergyIntolerance. - Test File: allergyintolerance-nkla.json - """ - filename = base_settings["unittest_data_dir"] / "allergyintolerance-nkla.json" - inst = allergyintolerance.AllergyIntolerance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AllergyIntolerance" == inst.resource_type - - impl_allergyintolerance_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AllergyIntolerance" == data["resourceType"] - - inst2 = allergyintolerance.AllergyIntolerance(**data) - impl_allergyintolerance_1(inst2) - - -def impl_allergyintolerance_2(inst): - assert inst.asserter.reference == "Patient/example" - assert inst.category[0] == "food" - assert inst.clinicalStatus.coding[0].code == "active" - assert inst.clinicalStatus.coding[0].display == "Active" - assert inst.clinicalStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "clinical" - ) - assert inst.code.coding[0].code == "227493005" - assert inst.code.coding[0].display == "Cashew nuts" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.criticality == "high" - assert inst.id == "example" - assert inst.identifier[0].system == "http://acme.com/ids/patients/risks" - assert inst.identifier[0].value == "49476534" - assert inst.lastOccurrence == fhirtypes.DateTime.validate( - "2012-06-12T12:09:24+00:06" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == ( - "The criticality is high becasue of the observed anaphylactic" - " reaction when challenged with cashew extract." - ) - assert inst.onsetDateTime == fhirtypes.DateTime.validate( - "2004-10-09T12:09:24+00:06" - ) - assert inst.patient.reference == "Patient/example" - assert inst.reaction[0].description == ( - "Challenge Protocol. Severe reaction to subcutaneous cashew " - "extract. Epinephrine administered" - ) - assert inst.reaction[0].exposureRoute.coding[0].code == "34206005" - assert inst.reaction[0].exposureRoute.coding[0].display == "Subcutaneous route" - assert inst.reaction[0].exposureRoute.coding[0].system == "http://snomed.info/sct" - assert inst.reaction[0].manifestation[0].coding[0].code == "39579001" - assert ( - inst.reaction[0].manifestation[0].coding[0].display == "Anaphylactic reaction" - ) - assert ( - inst.reaction[0].manifestation[0].coding[0].system == "http://snomed.info/sct" - ) - assert inst.reaction[0].onset == fhirtypes.DateTime.validate( - "2012-06-12T11:15:33+10:00" - ) - assert inst.reaction[0].severity == "severe" - assert inst.reaction[0].substance.coding[0].code == "1160593" - assert ( - inst.reaction[0].substance.coding[0].display - == "cashew nut allergenic extract Injectable Product" - ) - assert ( - inst.reaction[0].substance.coding[0].system - == "http://www.nlm.nih.gov/research/umls/rxnorm" - ) - assert inst.reaction[1].manifestation[0].coding[0].code == "64305001" - assert inst.reaction[1].manifestation[0].coding[0].display == "Urticaria" - assert ( - inst.reaction[1].manifestation[0].coding[0].system == "http://snomed.info/sct" - ) - assert inst.reaction[1].note[0].text == ( - "The patient reports that the onset of urticaria was within " - "15 minutes of eating cashews." - ) - assert inst.reaction[1].onset == fhirtypes.DateTime.validate( - "2004-06-12T11:15:33+10:00" - ) - assert inst.reaction[1].severity == "moderate" - assert inst.recordedDate == fhirtypes.DateTime.validate("2014-10-09T14:58:00+11:00") - assert inst.recorder.reference == "Practitioner/example" - assert inst.text.status == "generated" - assert inst.type == "allergy" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert inst.verificationStatus.coding[0].display == "Confirmed" - assert inst.verificationStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "verification" - ) - - -def test_allergyintolerance_2(base_settings): - """No. 2 tests collection for AllergyIntolerance. - Test File: allergyintolerance-example.json - """ - filename = base_settings["unittest_data_dir"] / "allergyintolerance-example.json" - inst = allergyintolerance.AllergyIntolerance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AllergyIntolerance" == inst.resource_type - - impl_allergyintolerance_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AllergyIntolerance" == data["resourceType"] - - inst2 = allergyintolerance.AllergyIntolerance(**data) - impl_allergyintolerance_2(inst2) - - -def impl_allergyintolerance_3(inst): - assert inst.clinicalStatus.coding[0].code == "active" - assert inst.clinicalStatus.coding[0].display == "Active" - assert inst.clinicalStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "clinical" - ) - assert inst.code.coding[0].code == "716186003" - assert inst.code.coding[0].display == "No Known Allergy (situation)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "NKA" - assert inst.id == "nka" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/mom" - assert inst.recordedDate == fhirtypes.DateTime.validate("2015-08-06T15:37:31-06:00") - assert inst.recorder.reference == "Practitioner/example" - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert inst.verificationStatus.coding[0].display == "Confirmed" - assert inst.verificationStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "verification" - ) - - -def test_allergyintolerance_3(base_settings): - """No. 3 tests collection for AllergyIntolerance. - Test File: allergyintolerance-nka.json - """ - filename = base_settings["unittest_data_dir"] / "allergyintolerance-nka.json" - inst = allergyintolerance.AllergyIntolerance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AllergyIntolerance" == inst.resource_type - - impl_allergyintolerance_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AllergyIntolerance" == data["resourceType"] - - inst2 = allergyintolerance.AllergyIntolerance(**data) - impl_allergyintolerance_3(inst2) - - -def impl_allergyintolerance_4(inst): - assert inst.category[0] == "medication" - assert inst.clinicalStatus.coding[0].code == "active" - assert inst.clinicalStatus.coding[0].display == "Active" - assert inst.clinicalStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "clinical" - ) - assert inst.code.coding[0].code == "7980" - assert inst.code.coding[0].display == "Penicillin G" - assert inst.code.coding[0].system == "http://www.nlm.nih.gov/research/umls/rxnorm" - assert inst.criticality == "high" - assert inst.id == "medication" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.reaction[0].manifestation[0].coding[0].code == "247472004" - assert inst.reaction[0].manifestation[0].coding[0].display == "Hives" - assert ( - inst.reaction[0].manifestation[0].coding[0].system == "http://snomed.info/sct" - ) - assert inst.recordedDate == fhirtypes.DateTime.validate("2010-03-01T12:09:24+00:06") - assert inst.recorder.reference == "Practitioner/13" - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "unconfirmed" - assert inst.verificationStatus.coding[0].display == "Unconfirmed" - assert inst.verificationStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "verification" - ) - - -def test_allergyintolerance_4(base_settings): - """No. 4 tests collection for AllergyIntolerance. - Test File: allergyintolerance-medication.json - """ - filename = base_settings["unittest_data_dir"] / "allergyintolerance-medication.json" - inst = allergyintolerance.AllergyIntolerance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AllergyIntolerance" == inst.resource_type - - impl_allergyintolerance_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AllergyIntolerance" == data["resourceType"] - - inst2 = allergyintolerance.AllergyIntolerance(**data) - impl_allergyintolerance_4(inst2) - - -def impl_allergyintolerance_5(inst): - assert inst.category[0] == "food" - assert inst.clinicalStatus.coding[0].code == "active" - assert inst.clinicalStatus.coding[0].display == "Active" - assert inst.clinicalStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "clinical" - ) - assert inst.code.coding[0].code == "227037002" - assert inst.code.coding[0].display == "Fish - dietary (substance)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Allergic to fresh fish. Tolerates canned fish" - assert inst.id == "fishallergy" - assert inst.identifier[0].system == "http://acme.com/ids/patients/risks" - assert inst.identifier[0].value == "49476535" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.recordedDate == fhirtypes.DateTime.validate("2015-08-06T15:37:31-06:00") - assert inst.recorder.reference == "Practitioner/example" - assert inst.text.status == "additional" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert inst.verificationStatus.coding[0].display == "Confirmed" - assert inst.verificationStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "verification" - ) - - -def test_allergyintolerance_5(base_settings): - """No. 5 tests collection for AllergyIntolerance. - Test File: allergyintolerance-fishallergy.json - """ - filename = ( - base_settings["unittest_data_dir"] / "allergyintolerance-fishallergy.json" - ) - inst = allergyintolerance.AllergyIntolerance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AllergyIntolerance" == inst.resource_type - - impl_allergyintolerance_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AllergyIntolerance" == data["resourceType"] - - inst2 = allergyintolerance.AllergyIntolerance(**data) - impl_allergyintolerance_5(inst2) - - -def impl_allergyintolerance_6(inst): - assert inst.clinicalStatus.coding[0].code == "active" - assert inst.clinicalStatus.coding[0].display == "Active" - assert inst.clinicalStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "clinical" - ) - assert inst.code.coding[0].code == "409137002" - assert inst.code.coding[0].display == "No Known Drug Allergy (situation)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "NKDA" - assert inst.id == "nkda" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/mom" - assert inst.recordedDate == fhirtypes.DateTime.validate("2015-08-06T15:37:31-06:00") - assert inst.recorder.reference == "Practitioner/example" - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert inst.verificationStatus.coding[0].display == "Confirmed" - assert inst.verificationStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "verification" - ) - - -def test_allergyintolerance_6(base_settings): - """No. 6 tests collection for AllergyIntolerance. - Test File: allergyintolerance-nkda.json - """ - filename = base_settings["unittest_data_dir"] / "allergyintolerance-nkda.json" - inst = allergyintolerance.AllergyIntolerance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AllergyIntolerance" == inst.resource_type - - impl_allergyintolerance_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AllergyIntolerance" == data["resourceType"] - - inst2 = allergyintolerance.AllergyIntolerance(**data) - impl_allergyintolerance_6(inst2) diff --git a/fhir/resources/tests/test_appointment.py b/fhir/resources/tests/test_appointment.py deleted file mode 100644 index 6d18188a..00000000 --- a/fhir/resources/tests/test_appointment.py +++ /dev/null @@ -1,264 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Appointment -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import appointment - - -def impl_appointment_1(inst): - assert inst.appointmentType.coding[0].code == "FOLLOWUP" - assert ( - inst.appointmentType.coding[0].display - == "A follow up visit from a previous appointment" - ) - assert ( - inst.appointmentType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0276" - ) - assert inst.basedOn[0].reference == "ServiceRequest/myringotomy" - assert inst.comment == ( - "Further expand on the results of the MRI and determine the " - "next actions that may be appropriate." - ) - assert inst.created == fhirtypes.DateTime.validate("2013-10-10T12:09:24+00:06") - assert inst.description == "Discussion on the results of your recent MRI" - assert inst.end == fhirtypes.Instant.validate("2013-12-10T11:00:00Z") - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participant[0].actor.display == "Peter James Chalmers" - assert inst.participant[0].actor.reference == "Patient/example" - assert inst.participant[0].required == "required" - assert inst.participant[0].status == "accepted" - assert inst.participant[1].actor.display == "Dr Adam Careful" - assert inst.participant[1].actor.reference == "Practitioner/example" - assert inst.participant[1].required == "required" - assert inst.participant[1].status == "accepted" - assert inst.participant[1].type[0].coding[0].code == "ATND" - assert ( - inst.participant[1].type[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.participant[2].actor.display == "South Wing, second floor" - assert inst.participant[2].actor.reference == "Location/1" - assert inst.participant[2].required == "required" - assert inst.participant[2].status == "accepted" - assert inst.priority == 5 - assert inst.reasonReference[0].display == "Severe burn of left ear" - assert inst.reasonReference[0].reference == "Condition/example" - assert inst.serviceCategory[0].coding[0].code == "gp" - assert inst.serviceCategory[0].coding[0].display == "General Practice" - assert ( - inst.serviceCategory[0].coding[0].system - == "http://example.org/service-category" - ) - assert inst.serviceType[0].coding[0].code == "52" - assert inst.serviceType[0].coding[0].display == "General Discussion" - assert inst.specialty[0].coding[0].code == "394814009" - assert inst.specialty[0].coding[0].display == "General practice" - assert inst.specialty[0].coding[0].system == "http://snomed.info/sct" - assert inst.start == fhirtypes.Instant.validate("2013-12-10T09:00:00Z") - assert inst.status == "booked" - assert inst.text.div == ( - '
Brian MRI ' - "results discussion
" - ) - assert inst.text.status == "generated" - - -def test_appointment_1(base_settings): - """No. 1 tests collection for Appointment. - Test File: appointment-example.json - """ - filename = base_settings["unittest_data_dir"] / "appointment-example.json" - inst = appointment.Appointment.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Appointment" == inst.resource_type - - impl_appointment_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Appointment" == data["resourceType"] - - inst2 = appointment.Appointment(**data) - impl_appointment_1(inst2) - - -def impl_appointment_2(inst): - assert inst.appointmentType.coding[0].code == "WALKIN" - assert ( - inst.appointmentType.coding[0].display - == "A previously unscheduled walk-in visit" - ) - assert ( - inst.appointmentType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0276" - ) - assert inst.comment == ( - "Further expand on the results of the MRI and determine the " - "next actions that may be appropriate." - ) - assert inst.created == fhirtypes.DateTime.validate("2015-12-02T11:15:33+10:00") - assert inst.description == "Discussion on the results of your recent MRI" - assert inst.id == "examplereq" - assert ( - inst.identifier[0].system == "http://example.org/sampleappointment-identifier" - ) - assert inst.identifier[0].value == "123" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.minutesDuration == 15 - assert inst.participant[0].actor.display == "Peter James Chalmers" - assert inst.participant[0].actor.reference == "Patient/example" - assert inst.participant[0].required == "required" - assert inst.participant[0].status == "needs-action" - assert inst.participant[1].required == "required" - assert inst.participant[1].status == "needs-action" - assert inst.participant[1].type[0].coding[0].code == "ATND" - assert ( - inst.participant[1].type[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.participant[2].actor.display == "South Wing, second floor" - assert inst.participant[2].actor.reference == "Location/1" - assert inst.participant[2].required == "required" - assert inst.participant[2].status == "accepted" - assert inst.priority == 5 - assert inst.reasonCode[0].coding[0].code == "413095006" - assert inst.reasonCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.reasonCode[0].text == "Clinical Review" - assert inst.requestedPeriod[0].end == fhirtypes.DateTime.validate( - "2016-06-09T12:09:24+00:06" - ) - assert inst.requestedPeriod[0].start == fhirtypes.DateTime.validate( - "2016-06-02T12:09:24+00:06" - ) - assert inst.serviceCategory[0].coding[0].code == "gp" - assert inst.serviceCategory[0].coding[0].display == "General Practice" - assert ( - inst.serviceCategory[0].coding[0].system - == "http://example.org/service-category" - ) - assert inst.slot[0].reference == "Slot/example" - assert inst.specialty[0].coding[0].code == "394814009" - assert inst.specialty[0].coding[0].display == "General practice" - assert inst.specialty[0].coding[0].system == "http://snomed.info/sct" - assert inst.status == "proposed" - assert inst.text.div == ( - '
Brian MRI ' - "results discussion
" - ) - assert inst.text.status == "generated" - - -def test_appointment_2(base_settings): - """No. 2 tests collection for Appointment. - Test File: appointment-example-request.json - """ - filename = base_settings["unittest_data_dir"] / "appointment-example-request.json" - inst = appointment.Appointment.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Appointment" == inst.resource_type - - impl_appointment_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Appointment" == data["resourceType"] - - inst2 = appointment.Appointment(**data) - impl_appointment_2(inst2) - - -def impl_appointment_3(inst): - assert inst.appointmentType.coding[0].code == "WALKIN" - assert ( - inst.appointmentType.coding[0].display - == "A previously unscheduled walk-in visit" - ) - assert ( - inst.appointmentType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0276" - ) - assert inst.comment == ( - "Clarify the results of the MRI to ensure context of test was" " correct" - ) - assert inst.description == "Discussion about Peter Chalmers MRI results" - assert inst.end == fhirtypes.Instant.validate("2013-12-09T11:00:00Z") - assert inst.id == "2docs" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participant[0].actor.display == "Peter James Chalmers" - assert inst.participant[0].actor.reference == "Patient/example" - assert inst.participant[0].required == "information-only" - assert inst.participant[0].status == "accepted" - assert inst.participant[1].actor.display == "Dr Adam Careful" - assert inst.participant[1].actor.reference == "Practitioner/example" - assert inst.participant[1].required == "required" - assert inst.participant[1].status == "accepted" - assert inst.participant[2].actor.display == "Luigi Maas" - assert inst.participant[2].actor.reference == "Practitioner/f202" - assert inst.participant[2].required == "required" - assert inst.participant[2].status == "accepted" - assert inst.participant[3].actor.display == "Phone Call" - assert inst.participant[3].required == "information-only" - assert inst.participant[3].status == "accepted" - assert inst.priority == 5 - assert inst.serviceCategory[0].coding[0].code == "gp" - assert inst.serviceCategory[0].coding[0].display == "General Practice" - assert ( - inst.serviceCategory[0].coding[0].system - == "http://example.org/service-category" - ) - assert inst.serviceType[0].coding[0].code == "52" - assert inst.serviceType[0].coding[0].display == "General Discussion" - assert inst.specialty[0].coding[0].code == "394814009" - assert inst.specialty[0].coding[0].display == "General practice" - assert inst.specialty[0].coding[0].system == "http://snomed.info/sct" - assert inst.start == fhirtypes.Instant.validate("2013-12-09T09:00:00Z") - assert inst.status == "booked" - assert inst.supportingInformation[0].reference == "DiagnosticReport/ultrasound" - assert inst.text.div == ( - '
Brian MRI ' - "results discussion
" - ) - assert inst.text.status == "generated" - - -def test_appointment_3(base_settings): - """No. 3 tests collection for Appointment. - Test File: appointment-example2doctors.json - """ - filename = base_settings["unittest_data_dir"] / "appointment-example2doctors.json" - inst = appointment.Appointment.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Appointment" == inst.resource_type - - impl_appointment_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Appointment" == data["resourceType"] - - inst2 = appointment.Appointment(**data) - impl_appointment_3(inst2) diff --git a/fhir/resources/tests/test_appointmentresponse.py b/fhir/resources/tests/test_appointmentresponse.py deleted file mode 100644 index 141447d4..00000000 --- a/fhir/resources/tests/test_appointmentresponse.py +++ /dev/null @@ -1,105 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/AppointmentResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import appointmentresponse - - -def impl_appointmentresponse_1(inst): - assert inst.actor.display == "Dr Adam Careful" - assert inst.actor.reference == "Practitioner/example" - assert inst.appointment.display == "Brian MRI results discussion" - assert inst.appointment.reference == "Appointment/examplereq" - assert inst.comment == "can't we try for this time, can't do mornings" - assert inst.end == fhirtypes.Instant.validate("2013-12-25T13:30:00Z") - assert inst.id == "exampleresp" - assert ( - inst.identifier[0].system - == "http://example.org/sampleappointmentresponse-identifier" - ) - assert inst.identifier[0].value == "response123" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participantStatus == "tentative" - assert inst.participantType[0].coding[0].code == "ATND" - assert ( - inst.participantType[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.start == fhirtypes.Instant.validate("2013-12-25T13:15:00Z") - assert inst.text.div == ( - '
Accept Brian MRI' - " results discussion
" - ) - assert inst.text.status == "generated" - - -def test_appointmentresponse_1(base_settings): - """No. 1 tests collection for AppointmentResponse. - Test File: appointmentresponse-example-req.json - """ - filename = ( - base_settings["unittest_data_dir"] / "appointmentresponse-example-req.json" - ) - inst = appointmentresponse.AppointmentResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AppointmentResponse" == inst.resource_type - - impl_appointmentresponse_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AppointmentResponse" == data["resourceType"] - - inst2 = appointmentresponse.AppointmentResponse(**data) - impl_appointmentresponse_1(inst2) - - -def impl_appointmentresponse_2(inst): - assert inst.actor.display == "Peter James Chalmers" - assert inst.actor.reference == "Patient/example" - assert inst.appointment.display == "Brian MRI results discussion" - assert inst.appointment.reference == "Appointment/example" - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participantStatus == "accepted" - assert inst.text.div == ( - '
Accept Brian MRI' - " results discussion
" - ) - assert inst.text.status == "generated" - - -def test_appointmentresponse_2(base_settings): - """No. 2 tests collection for AppointmentResponse. - Test File: appointmentresponse-example.json - """ - filename = base_settings["unittest_data_dir"] / "appointmentresponse-example.json" - inst = appointmentresponse.AppointmentResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AppointmentResponse" == inst.resource_type - - impl_appointmentresponse_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AppointmentResponse" == data["resourceType"] - - inst2 = appointmentresponse.AppointmentResponse(**data) - impl_appointmentresponse_2(inst2) diff --git a/fhir/resources/tests/test_auditevent.py b/fhir/resources/tests/test_auditevent.py deleted file mode 100644 index dba88d1a..00000000 --- a/fhir/resources/tests/test_auditevent.py +++ /dev/null @@ -1,865 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/AuditEvent -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import auditevent - - -def impl_auditevent_1(inst): - assert inst.action == "E" - assert inst.agent[0].altId == "601847123" - assert inst.agent[0].name == "Grahame Grieve" - assert inst.agent[0].requestor is True - assert inst.agent[0].type.coding[0].code == "humanuser" - assert inst.agent[0].type.coding[0].display == "human user" - assert inst.agent[0].type.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/extra-security-role-" "type" - ) - assert inst.agent[0].who.identifier.value == "95" - assert inst.agent[1].altId == "6580" - assert inst.agent[1].network.address == "Workstation1.ehr.familyclinic.com" - assert inst.agent[1].network.type == "1" - assert inst.agent[1].requestor is False - assert inst.agent[1].type.coding[0].code == "110153" - assert inst.agent[1].type.coding[0].display == "Source Role ID" - assert ( - inst.agent[1].type.coding[0].system - == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.agent[1].who.identifier.system == "urn:oid:2.16.840.1.113883.4.2" - assert inst.agent[1].who.identifier.value == "2.16.840.1.113883.4.2" - assert inst.entity[0].query == bytes_validator( - ( - "aHR0cDovL2ZoaXItZGV2LmhlYWx0aGludGVyc2VjdGlvbnMuY29tLmF1L29w" - "ZW4vRW5jb3VudGVyP3BhcnRpY2lwYW50PTEz" - ) - ) - assert inst.entity[0].role.code == "24" - assert inst.entity[0].role.display == "Query" - assert ( - inst.entity[0].role.system - == "http://terminology.hl7.org/CodeSystem/object-role" - ) - assert inst.entity[0].type.code == "2" - assert inst.entity[0].type.display == "System Object" - assert ( - inst.entity[0].type.system - == "http://terminology.hl7.org/CodeSystem/audit-entity-type" - ) - assert inst.id == "example-search" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "0" - assert inst.recorded == fhirtypes.Instant.validate("2015-08-22T23:42:24Z") - assert inst.source.observer.display == "hl7connect.healthintersections.com.au" - assert inst.source.site == "Cloud" - assert inst.source.type[0].code == "3" - assert inst.source.type[0].display == "Web Server" - assert ( - inst.source.type[0].system - == "http://terminology.hl7.org/CodeSystem/security-source-type" - ) - assert inst.subtype[0].code == "search" - assert inst.subtype[0].display == "search" - assert inst.subtype[0].system == "http://hl7.org/fhir/restful-interaction" - assert inst.text.status == "generated" - assert inst.type.code == "rest" - assert inst.type.display == "Restful Operation" - assert inst.type.system == "http://terminology.hl7.org/CodeSystem/audit-event-type" - - -def test_auditevent_1(base_settings): - """No. 1 tests collection for AuditEvent. - Test File: audit-event-example-search.json - """ - filename = base_settings["unittest_data_dir"] / "audit-event-example-search.json" - inst = auditevent.AuditEvent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AuditEvent" == inst.resource_type - - impl_auditevent_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AuditEvent" == data["resourceType"] - - inst2 = auditevent.AuditEvent(**data) - impl_auditevent_1(inst2) - - -def impl_auditevent_2(inst): - assert inst.action == "E" - assert inst.agent[0].altId == "601847123" - assert inst.agent[0].name == "Grahame Grieve" - assert inst.agent[0].network.address == "127.0.0.1" - assert inst.agent[0].network.type == "2" - assert inst.agent[0].requestor is True - assert inst.agent[0].type.coding[0].code == "humanuser" - assert inst.agent[0].type.coding[0].display == "human user" - assert inst.agent[0].type.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/extra-security-role-" "type" - ) - assert inst.agent[0].who.identifier.value == "95" - assert inst.agent[1].altId == "6580" - assert inst.agent[1].network.address == "Workstation1.ehr.familyclinic.com" - assert inst.agent[1].network.type == "1" - assert inst.agent[1].requestor is False - assert inst.agent[1].type.coding[0].code == "110153" - assert inst.agent[1].type.coding[0].display == "Source Role ID" - assert ( - inst.agent[1].type.coding[0].system - == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.agent[1].who.identifier.system == "urn:oid:2.16.840.1.113883.4.2" - assert inst.agent[1].who.identifier.value == "2.16.840.1.113883.4.2" - assert inst.id == "example-logout" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "0" - assert inst.recorded == fhirtypes.Instant.validate("2013-06-20T23:46:41Z") - assert ( - inst.source.observer.identifier.value == "hl7connect.healthintersections.com.au" - ) - assert inst.source.site == "Cloud" - assert inst.source.type[0].code == "3" - assert inst.source.type[0].display == "Web Server" - assert ( - inst.source.type[0].system - == "http://terminology.hl7.org/CodeSystem/security-source-type" - ) - assert inst.subtype[0].code == "110123" - assert inst.subtype[0].display == "Logout" - assert inst.subtype[0].system == "http://dicom.nema.org/resources/ontology/DCM" - assert inst.text.status == "generated" - assert inst.type.code == "110114" - assert inst.type.display == "User Authentication" - assert inst.type.system == "http://dicom.nema.org/resources/ontology/DCM" - - -def test_auditevent_2(base_settings): - """No. 2 tests collection for AuditEvent. - Test File: audit-event-example-logout.json - """ - filename = base_settings["unittest_data_dir"] / "audit-event-example-logout.json" - inst = auditevent.AuditEvent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AuditEvent" == inst.resource_type - - impl_auditevent_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AuditEvent" == data["resourceType"] - - inst2 = auditevent.AuditEvent(**data) - impl_auditevent_2(inst2) - - -def impl_auditevent_3(inst): - assert inst.action == "R" - assert inst.agent[0].altId == "601847123" - assert inst.agent[0].name == "Grahame Grieve" - assert inst.agent[0].requestor is True - assert inst.agent[0].type.coding[0].code == "humanuser" - assert inst.agent[0].type.coding[0].display == "human user" - assert inst.agent[0].type.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/extra-security-role-" "type" - ) - assert inst.agent[0].who.identifier.value == "95" - assert inst.agent[1].altId == "6580" - assert inst.agent[1].network.address == "Workstation1.ehr.familyclinic.com" - assert inst.agent[1].network.type == "1" - assert inst.agent[1].requestor is False - assert inst.agent[1].type.coding[0].code == "110153" - assert inst.agent[1].type.coding[0].display == "Source Role ID" - assert ( - inst.agent[1].type.coding[0].system - == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.agent[1].who.identifier.system == "urn:oid:2.16.840.1.113883.4.2" - assert inst.agent[1].who.identifier.value == "2.16.840.1.113883.4.2" - assert inst.entity[0].lifecycle.code == "6" - assert inst.entity[0].lifecycle.display == "Access / Use" - assert ( - inst.entity[0].lifecycle.system - == "http://terminology.hl7.org/CodeSystem/dicom-audit-lifecycle" - ) - assert inst.entity[0].type.code == "2" - assert inst.entity[0].type.display == "System Object" - assert ( - inst.entity[0].type.system - == "http://terminology.hl7.org/CodeSystem/audit-entity-type" - ) - assert inst.entity[0].what.reference == "Patient/example/_history/1" - assert inst.id == "example-rest" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "0" - assert inst.recorded == fhirtypes.Instant.validate("2013-06-20T23:42:24Z") - assert ( - inst.source.observer.identifier.value == "hl7connect.healthintersections.com.au" - ) - assert inst.source.site == "Cloud" - assert inst.source.type[0].code == "3" - assert inst.source.type[0].display == "Web Server" - assert ( - inst.source.type[0].system - == "http://terminology.hl7.org/CodeSystem/security-source-type" - ) - assert inst.subtype[0].code == "vread" - assert inst.subtype[0].display == "vread" - assert inst.subtype[0].system == "http://hl7.org/fhir/restful-interaction" - assert inst.text.status == "generated" - assert inst.type.code == "rest" - assert inst.type.display == "Restful Operation" - assert inst.type.system == "http://terminology.hl7.org/CodeSystem/audit-event-type" - - -def test_auditevent_3(base_settings): - """No. 3 tests collection for AuditEvent. - Test File: audit-event-example-vread.json - """ - filename = base_settings["unittest_data_dir"] / "audit-event-example-vread.json" - inst = auditevent.AuditEvent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AuditEvent" == inst.resource_type - - impl_auditevent_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AuditEvent" == data["resourceType"] - - inst2 = auditevent.AuditEvent(**data) - impl_auditevent_3(inst2) - - -def impl_auditevent_4(inst): - assert inst.action == "R" - assert inst.agent[0].requestor is False - assert inst.agent[0].type.coding[0].code == "110153" - assert inst.agent[0].type.coding[0].display == "Source Role ID" - assert ( - inst.agent[0].type.coding[0].system - == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.agent[0].who.display == "ExportToMedia.app" - assert inst.agent[1].altId == "601847123" - assert inst.agent[1].name == "Grahame Grieve" - assert inst.agent[1].requestor is True - assert inst.agent[1].type.coding[0].code == "humanuser" - assert inst.agent[1].type.coding[0].display == "human user" - assert inst.agent[1].type.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/extra-security-role-" "type" - ) - assert inst.agent[1].who.identifier.value == "95" - assert inst.agent[2].media.code == "110033" - assert inst.agent[2].media.display == "DVD" - assert inst.agent[2].media.system == "http://dicom.nema.org/resources/ontology/DCM" - assert inst.agent[2].name == "Media title: Hello World" - assert inst.agent[2].requestor is False - assert inst.agent[2].type.coding[0].code == "110154" - assert inst.agent[2].type.coding[0].display == "Destination Media" - assert ( - inst.agent[2].type.coding[0].system - == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.entity[0].role.code == "1" - assert inst.entity[0].role.display == "Patient" - assert ( - inst.entity[0].role.system - == "http://terminology.hl7.org/CodeSystem/object-role" - ) - assert inst.entity[0].type.code == "1" - assert inst.entity[0].type.display == "Person" - assert ( - inst.entity[0].type.system - == "http://terminology.hl7.org/CodeSystem/audit-entity-type" - ) - assert ( - inst.entity[0].what.identifier.value - == "e3cdfc81a0d24bd^^^&2.16.840.1.113883.4.2&ISO" - ) - assert inst.entity[1].role.code == "20" - assert inst.entity[1].role.display == "Job" - assert ( - inst.entity[1].role.system - == "http://terminology.hl7.org/CodeSystem/object-role" - ) - assert inst.entity[1].type.code == "2" - assert inst.entity[1].type.display == "System Object" - assert ( - inst.entity[1].type.system - == "http://terminology.hl7.org/CodeSystem/audit-entity-type" - ) - assert inst.entity[1].what.identifier.type.coding[0].code == "IHE XDS Metadata" - assert ( - inst.entity[1].what.identifier.type.coding[0].display - == "submission set classificationNode" - ) - assert ( - inst.entity[1].what.identifier.type.coding[0].system - == "urn:uuid:a54d6aa5-d40d-43f9-88c5-b4633d873bdd" - ) - assert ( - inst.entity[1].what.identifier.value - == "e3cdfc81a0d24bd^^^&2.16.840.1.113883.4.2&ISO" - ) - assert inst.entity[2].type.code == "2" - assert inst.entity[2].type.display == "System Object" - assert ( - inst.entity[2].type.system - == "http://terminology.hl7.org/CodeSystem/audit-entity-type" - ) - assert inst.entity[2].what.reference == "DocumentManifest/example" - assert inst.id == "example-media" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "0" - assert inst.recorded == fhirtypes.Instant.validate("2015-08-27T23:42:24Z") - assert inst.source.observer.display == "hl7connect.healthintersections.com.au" - assert inst.subtype[0].code == "ITI-32" - assert inst.subtype[0].display == "Distribute Document Set on Media" - assert inst.subtype[0].system == "urn:oid:1.3.6.1.4.1.19376.1.2" - assert inst.text.status == "generated" - assert inst.type.code == "110106" - assert inst.type.display == "Export" - assert inst.type.system == "http://dicom.nema.org/resources/ontology/DCM" - - -def test_auditevent_4(base_settings): - """No. 4 tests collection for AuditEvent. - Test File: audit-event-example-media.json - """ - filename = base_settings["unittest_data_dir"] / "audit-event-example-media.json" - inst = auditevent.AuditEvent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AuditEvent" == inst.resource_type - - impl_auditevent_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AuditEvent" == data["resourceType"] - - inst2 = auditevent.AuditEvent(**data) - impl_auditevent_4(inst2) - - -def impl_auditevent_5(inst): - assert inst.action == "E" - assert inst.agent[0].altId == "601847123" - assert inst.agent[0].name == "Grahame Grieve" - assert inst.agent[0].network.address == "127.0.0.1" - assert inst.agent[0].network.type == "2" - assert inst.agent[0].requestor is True - assert inst.agent[0].type.coding[0].code == "humanuser" - assert inst.agent[0].type.coding[0].display == "human user" - assert inst.agent[0].type.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/extra-security-role-" "type" - ) - assert inst.agent[0].who.identifier.value == "95" - assert inst.agent[1].altId == "6580" - assert inst.agent[1].network.address == "Workstation1.ehr.familyclinic.com" - assert inst.agent[1].network.type == "1" - assert inst.agent[1].requestor is False - assert inst.agent[1].type.coding[0].code == "110153" - assert inst.agent[1].type.coding[0].display == "Source Role ID" - assert ( - inst.agent[1].type.coding[0].system - == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.agent[1].who.identifier.system == "urn:oid:2.16.840.1.113883.4.2" - assert inst.agent[1].who.identifier.value == "2.16.840.1.113883.4.2" - assert inst.id == "example-login" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "0" - assert inst.recorded == fhirtypes.Instant.validate("2013-06-20T23:41:23Z") - assert ( - inst.source.observer.identifier.value == "hl7connect.healthintersections.com.au" - ) - assert inst.source.site == "Cloud" - assert inst.source.type[0].code == "3" - assert inst.source.type[0].display == "Web Server" - assert ( - inst.source.type[0].system - == "http://terminology.hl7.org/CodeSystem/security-source-type" - ) - assert inst.subtype[0].code == "110122" - assert inst.subtype[0].display == "Login" - assert inst.subtype[0].system == "http://dicom.nema.org/resources/ontology/DCM" - assert inst.text.status == "generated" - assert inst.type.code == "110114" - assert inst.type.display == "User Authentication" - assert inst.type.system == "http://dicom.nema.org/resources/ontology/DCM" - - -def test_auditevent_5(base_settings): - """No. 5 tests collection for AuditEvent. - Test File: audit-event-example-login.json - """ - filename = base_settings["unittest_data_dir"] / "audit-event-example-login.json" - inst = auditevent.AuditEvent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AuditEvent" == inst.resource_type - - impl_auditevent_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AuditEvent" == data["resourceType"] - - inst2 = auditevent.AuditEvent(**data) - impl_auditevent_5(inst2) - - -def impl_auditevent_6(inst): - assert inst.action == "E" - assert inst.agent[0].altId == "6580" - assert inst.agent[0].network.address == "Workstation1.ehr.familyclinic.com" - assert inst.agent[0].network.type == "1" - assert inst.agent[0].requestor is False - assert inst.agent[0].type.coding[0].code == "110153" - assert inst.agent[0].type.coding[0].display == "Source Role ID" - assert ( - inst.agent[0].type.coding[0].system - == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.agent[0].who.identifier.system == "urn:oid:2.16.840.1.113883.4.2" - assert inst.agent[0].who.identifier.value == "2.16.840.1.113883.4.2" - assert inst.agent[1].altId == "601847123" - assert inst.agent[1].name == "Grahame Grieve" - assert inst.agent[1].requestor is True - assert inst.agent[1].type.coding[0].code == "humanuser" - assert inst.agent[1].type.coding[0].display == "human user" - assert inst.agent[1].type.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/extra-security-role-" "type" - ) - assert inst.agent[1].who.identifier.value == "95" - assert inst.entity[0].role.code == "1" - assert inst.entity[0].role.display == "Patient" - assert ( - inst.entity[0].role.system - == "http://terminology.hl7.org/CodeSystem/object-role" - ) - assert inst.entity[0].type.code == "1" - assert inst.entity[0].type.display == "Person" - assert ( - inst.entity[0].type.system - == "http://terminology.hl7.org/CodeSystem/audit-entity-type" - ) - assert ( - inst.entity[0].what.identifier.value - == "e3cdfc81a0d24bd^^^&2.16.840.1.113883.4.2&ISO" - ) - assert inst.entity[1].detail[0].type == "MSH-10" - assert inst.entity[1].detail[0].valueBase64Binary == bytes_validator( - "MS4yLjg0MC4xMTQzNTAuMS4xMy4wLjEuNy4xLjE=" - ) - assert inst.entity[1].role.code == "24" - assert inst.entity[1].role.display == "Query" - assert ( - inst.entity[1].role.system - == "http://terminology.hl7.org/CodeSystem/object-role" - ) - assert inst.entity[1].type.code == "2" - assert inst.entity[1].type.display == "System Object" - assert ( - inst.entity[1].type.system - == "http://terminology.hl7.org/CodeSystem/audit-entity-type" - ) - assert inst.id == "example-pixQuery" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "0" - assert inst.recorded == fhirtypes.Instant.validate("2015-08-26T23:42:24Z") - assert inst.source.observer.display == "hl7connect.healthintersections.com.au" - assert inst.subtype[0].code == "ITI-9" - assert inst.subtype[0].display == "PIX Query" - assert inst.subtype[0].system == "urn:oid:1.3.6.1.4.1.19376.1.2" - assert inst.text.status == "generated" - assert inst.type.code == "110112" - assert inst.type.display == "Query" - assert inst.type.system == "http://dicom.nema.org/resources/ontology/DCM" - - -def test_auditevent_6(base_settings): - """No. 6 tests collection for AuditEvent. - Test File: audit-event-example-pixQuery.json - """ - filename = base_settings["unittest_data_dir"] / "audit-event-example-pixQuery.json" - inst = auditevent.AuditEvent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AuditEvent" == inst.resource_type - - impl_auditevent_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AuditEvent" == data["resourceType"] - - inst2 = auditevent.AuditEvent(**data) - impl_auditevent_6(inst2) - - -def impl_auditevent_7(inst): - assert inst.action == "E" - assert inst.agent[0].network.address == "127.0.0.1" - assert inst.agent[0].network.type == "2" - assert inst.agent[0].requestor is False - assert inst.agent[0].role[0].text == "Service User (Logon)" - assert inst.agent[0].type.coding[0].code == "humanuser" - assert inst.agent[0].type.coding[0].display == "human user" - assert inst.agent[0].type.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/extra-security-role-" "type" - ) - assert inst.agent[0].who.identifier.value == "Grahame" - assert inst.agent[1].altId == "6580" - assert inst.agent[1].network.address == "Workstation1.ehr.familyclinic.com" - assert inst.agent[1].network.type == "1" - assert inst.agent[1].requestor is False - assert inst.agent[1].type.coding[0].code == "110153" - assert inst.agent[1].type.coding[0].display == "Source Role ID" - assert ( - inst.agent[1].type.coding[0].system - == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.agent[1].who.identifier.system == "urn:oid:2.16.840.1.113883.4.2" - assert inst.agent[1].who.identifier.value == "2.16.840.1.113883.4.2" - assert inst.entity[0].lifecycle.code == "6" - assert inst.entity[0].lifecycle.display == "Access / Use" - assert ( - inst.entity[0].lifecycle.system - == "http://terminology.hl7.org/CodeSystem/dicom-audit-lifecycle" - ) - assert inst.entity[0].name == "Grahame's Laptop" - assert inst.entity[0].role.code == "4" - assert inst.entity[0].role.display == "Domain Resource" - assert ( - inst.entity[0].role.system - == "http://terminology.hl7.org/CodeSystem/object-role" - ) - assert inst.entity[0].type.code == "4" - assert inst.entity[0].type.display == "Other" - assert ( - inst.entity[0].type.system - == "http://terminology.hl7.org/CodeSystem/audit-entity-type" - ) - assert inst.entity[0].what.identifier.type.coding[0].code == "SNO" - assert ( - inst.entity[0].what.identifier.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.entity[0].what.identifier.type.text == "Dell Serial Number" - assert inst.entity[0].what.identifier.value == "ABCDEF" - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "0" - assert inst.recorded == fhirtypes.Instant.validate("2012-10-25T22:04:27+11:00") - assert inst.source.observer.display == "Grahame's Laptop" - assert inst.source.site == "Development" - assert inst.source.type[0].code == "110122" - assert inst.source.type[0].display == "Login" - assert inst.source.type[0].system == "http://dicom.nema.org/resources/ontology/DCM" - assert inst.subtype[0].code == "110120" - assert inst.subtype[0].display == "Application Start" - assert inst.subtype[0].system == "http://dicom.nema.org/resources/ontology/DCM" - assert inst.text.div == ( - '
Application ' - "Start for under service login "Grahame" (id: " - "Grahame's Test HL7Connect)
" - ) - assert inst.text.status == "generated" - assert inst.type.code == "110100" - assert inst.type.display == "Application Activity" - assert inst.type.system == "http://dicom.nema.org/resources/ontology/DCM" - - -def test_auditevent_7(base_settings): - """No. 7 tests collection for AuditEvent. - Test File: auditevent-example.json - """ - filename = base_settings["unittest_data_dir"] / "auditevent-example.json" - inst = auditevent.AuditEvent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AuditEvent" == inst.resource_type - - impl_auditevent_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AuditEvent" == data["resourceType"] - - inst2 = auditevent.AuditEvent(**data) - impl_auditevent_7(inst2) - - -def impl_auditevent_8(inst): - assert inst.action == "R" - assert inst.agent[0].altId == "notMe" - assert inst.agent[0].location.reference == "Location/1" - assert inst.agent[0].name == "That guy everyone wishes would be caught" - assert inst.agent[0].network.address == "custodian.net" - assert inst.agent[0].network.type == "1" - assert inst.agent[0].policy[0] == "http://consent.com/yes" - assert inst.agent[0].requestor is True - assert inst.agent[0].type.coding[0].code == "110153" - assert inst.agent[0].type.coding[0].display == "Source Role ID" - assert ( - inst.agent[0].type.coding[0].system - == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.agent[0].who.identifier.value == "SomeIdiot@nowhere" - assert inst.agent[1].network.address == "marketing.land" - assert inst.agent[1].network.type == "1" - assert inst.agent[1].purposeOfUse[0].coding[0].code == "HMARKT" - assert inst.agent[1].purposeOfUse[0].coding[0].display == "healthcare marketing" - assert ( - inst.agent[1].purposeOfUse[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.agent[1].requestor is False - assert inst.agent[1].type.coding[0].code == "110152" - assert inst.agent[1].type.coding[0].display == "Destination Role ID" - assert ( - inst.agent[1].type.coding[0].system - == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.agent[1].who.display == "Where" - assert inst.agent[1].who.reference == "Practitioner/example" - assert inst.entity[0].role.code == "1" - assert inst.entity[0].role.display == "Patient" - assert ( - inst.entity[0].role.system - == "http://terminology.hl7.org/CodeSystem/object-role" - ) - assert inst.entity[0].type.code == "1" - assert inst.entity[0].type.display == "Person" - assert ( - inst.entity[0].type.system - == "http://terminology.hl7.org/CodeSystem/audit-entity-type" - ) - assert inst.entity[0].what.reference == "Patient/example" - assert inst.entity[1].description == "data about Everthing important" - assert inst.entity[1].lifecycle.code == "11" - assert inst.entity[1].lifecycle.display == "Disclosure" - assert ( - inst.entity[1].lifecycle.system - == "http://terminology.hl7.org/CodeSystem/dicom-audit-lifecycle" - ) - assert inst.entity[1].name == "Namne of What" - assert inst.entity[1].role.code == "4" - assert inst.entity[1].role.display == "Domain Resource" - assert ( - inst.entity[1].role.system - == "http://terminology.hl7.org/CodeSystem/object-role" - ) - assert inst.entity[1].securityLabel[0].code == "V" - assert inst.entity[1].securityLabel[0].display == "very restricted" - assert ( - inst.entity[1].securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-Confidentiality" - ) - assert inst.entity[1].securityLabel[1].code == "STD" - assert ( - inst.entity[1].securityLabel[1].display - == "sexually transmitted disease information sensitivity" - ) - assert ( - inst.entity[1].securityLabel[1].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.entity[1].securityLabel[2].code == "DELAU" - assert inst.entity[1].securityLabel[2].display == "delete after use" - assert ( - inst.entity[1].securityLabel[2].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.entity[1].type.code == "2" - assert inst.entity[1].type.display == "System Object" - assert ( - inst.entity[1].type.system - == "http://terminology.hl7.org/CodeSystem/audit-entity-type" - ) - assert inst.entity[1].what.identifier.value == "What.id" - assert inst.entity[1].what.reference == "Patient/example/_history/1" - assert inst.id == "example-disclosure" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "0" - assert inst.outcomeDesc == "Successful Disclosure" - assert inst.purposeOfEvent[0].coding[0].code == "HMARKT" - assert inst.purposeOfEvent[0].coding[0].display == "healthcare marketing" - assert ( - inst.purposeOfEvent[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.recorded == fhirtypes.Instant.validate("2013-09-22T00:08:00Z") - assert ( - inst.source.observer.display == "Watchers Accounting of Disclosures Application" - ) - assert inst.source.site == "Watcher" - assert inst.source.type[0].code == "4" - assert inst.source.type[0].display == "Application Server" - assert ( - inst.source.type[0].system - == "http://terminology.hl7.org/CodeSystem/security-source-type" - ) - assert inst.subtype[0].code == "Disclosure" - assert inst.subtype[0].display == "HIPAA disclosure" - assert inst.text.div == ( - '
Disclosure by ' - "some idiot, for marketing reasons, to places unknown, of a " - "Poor Sap, data about Everthing important.
" - ) - assert inst.text.status == "generated" - assert inst.type.code == "110106" - assert inst.type.display == "Export" - assert inst.type.system == "http://dicom.nema.org/resources/ontology/DCM" - - -def test_auditevent_8(base_settings): - """No. 8 tests collection for AuditEvent. - Test File: auditevent-example-disclosure.json - """ - filename = base_settings["unittest_data_dir"] / "auditevent-example-disclosure.json" - inst = auditevent.AuditEvent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AuditEvent" == inst.resource_type - - impl_auditevent_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AuditEvent" == data["resourceType"] - - inst2 = auditevent.AuditEvent(**data) - impl_auditevent_8(inst2) - - -def impl_auditevent_9(inst): - assert inst.action == "C" - assert inst.agent[0].altId == "601847123" - assert inst.agent[0].name == "Grahame Grieve" - assert inst.agent[0].requestor is True - assert inst.agent[0].type.coding[0].code == "humanuser" - assert inst.agent[0].type.coding[0].display == "human user" - assert inst.agent[0].type.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/extra-security-role-" "type" - ) - assert inst.agent[0].who.identifier.value == "95" - assert inst.agent[1].altId == "6580" - assert inst.agent[1].network.address == "Workstation1.ehr.familyclinic.com" - assert inst.agent[1].network.type == "1" - assert inst.agent[1].requestor is False - assert inst.agent[1].type.coding[0].code == "110153" - assert inst.agent[1].type.coding[0].display == "Source Role ID" - assert ( - inst.agent[1].type.coding[0].system - == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.agent[1].who.identifier.system == "urn:oid:2.16.840.1.113883.4.2" - assert inst.agent[1].who.identifier.value == "2.16.840.1.113883.4.2" - assert inst.contained[0].id == "o1" - assert inst.entity[0].detail[0].type == "requested transaction" - assert inst.entity[0].detail[0].valueString == "http POST ..... " - assert inst.entity[0].type.code == "2" - assert inst.entity[0].type.display == "System Object" - assert ( - inst.entity[0].type.system - == "http://terminology.hl7.org/CodeSystem/audit-entity-type" - ) - assert inst.entity[1].description == "transaction failed" - assert inst.entity[1].type.code == "OperationOutcome" - assert inst.entity[1].type.display == "OperationOutcome" - assert inst.entity[1].type.system == "http://hl7.org/fhir/resource-types" - assert inst.entity[1].what.reference == "#o1" - assert inst.id == "example-error" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "8" - assert inst.outcomeDesc == ( - "Invalid request to create an Operation resource on the " "Patient endpoint." - ) - assert inst.recorded == fhirtypes.Instant.validate("2017-09-07T23:42:24Z") - assert ( - inst.source.observer.identifier.value == "hl7connect.healthintersections.com.au" - ) - assert inst.source.site == "Cloud" - assert inst.source.type[0].code == "3" - assert inst.source.type[0].display == "Web Server" - assert ( - inst.source.type[0].system - == "http://terminology.hl7.org/CodeSystem/security-source-type" - ) - assert inst.subtype[0].code == "create" - assert inst.subtype[0].display == "create" - assert inst.subtype[0].system == "http://hl7.org/fhir/restful-interaction" - assert inst.text.status == "generated" - assert inst.type.code == "rest" - assert inst.type.display == "Restful Operation" - assert inst.type.system == "http://terminology.hl7.org/CodeSystem/audit-event-type" - - -def test_auditevent_9(base_settings): - """No. 9 tests collection for AuditEvent. - Test File: auditevent-example-error.json - """ - filename = base_settings["unittest_data_dir"] / "auditevent-example-error.json" - inst = auditevent.AuditEvent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "AuditEvent" == inst.resource_type - - impl_auditevent_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "AuditEvent" == data["resourceType"] - - inst2 = auditevent.AuditEvent(**data) - impl_auditevent_9(inst2) diff --git a/fhir/resources/tests/test_basic.py b/fhir/resources/tests/test_basic.py deleted file mode 100644 index 49e58d1c..00000000 --- a/fhir/resources/tests/test_basic.py +++ /dev/null @@ -1,182 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Basic -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import basic - - -def impl_basic_1(inst): - assert inst.code.coding[0].code == "UMLCLASSMODEL" - assert ( - inst.code.coding[0].system - == "http://example.org/do-not-use/fhir-codes#resourceTypes" - ) - assert inst.extension[0].extension[0].url == "name" - assert inst.extension[0].extension[0].valueString == "Class1" - assert inst.extension[0].extension[1].extension[0].url == "name" - assert inst.extension[0].extension[1].extension[0].valueString == "attribute1" - assert inst.extension[0].extension[1].extension[1].url == "minOccurs" - assert inst.extension[0].extension[1].extension[1].valueInteger == 1 - assert inst.extension[0].extension[1].extension[2].url == "maxOccurs" - assert inst.extension[0].extension[1].extension[2].valueCode == "*" - assert inst.extension[0].extension[1].url == "attribute" - assert inst.extension[0].extension[2].extension[0].url == "name" - assert inst.extension[0].extension[2].extension[0].valueString == "attribute2" - assert inst.extension[0].extension[2].extension[1].url == "minOccurs" - assert inst.extension[0].extension[2].extension[1].valueInteger == 0 - assert inst.extension[0].extension[2].extension[2].url == "maxOccurs" - assert inst.extension[0].extension[2].extension[2].valueInteger == 1 - assert inst.extension[0].extension[2].url == "attribute" - assert ( - inst.extension[0].url - == "http://example.org/do-not-use/fhir-extensions/UMLclass" - ) - assert inst.id == "classModel" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_basic_1(base_settings): - """No. 1 tests collection for Basic. - Test File: basic-example2.json - """ - filename = base_settings["unittest_data_dir"] / "basic-example2.json" - inst = basic.Basic.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Basic" == inst.resource_type - - impl_basic_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Basic" == data["resourceType"] - - inst2 = basic.Basic(**data) - impl_basic_1(inst2) - - -def impl_basic_2(inst): - assert inst.code.text == "Example Narrative Tester" - assert inst.id == "basic-example-narrative" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "additional" - - -def test_basic_2(base_settings): - """No. 2 tests collection for Basic. - Test File: basic-example-narrative.json - """ - filename = base_settings["unittest_data_dir"] / "basic-example-narrative.json" - inst = basic.Basic.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Basic" == inst.resource_type - - impl_basic_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Basic" == data["resourceType"] - - inst2 = basic.Basic(**data) - impl_basic_2(inst2) - - -def impl_basic_3(inst): - assert inst.author.reference == "Practitioner/example" - assert inst.code.coding[0].code == "referral" - assert ( - inst.code.coding[0].system - == "http://terminology.hl7.org/CodeSystem/basic-resource-type" - ) - assert inst.created == fhirtypes.Date.validate("2013-05-14") - assert inst.extension[0].url == ( - "http://example.org/do-not-use/fhir-" - "extensions/referral#requestingPractitioner" - ) - assert inst.extension[0].valueReference.display == "Dokter Bronsig" - assert inst.extension[0].valueReference.reference == "Practitioner/f201" - assert ( - inst.extension[1].url - == "http://example.org/do-not-use/fhir-extensions/referral#notes" - ) - assert inst.extension[1].valueString == ( - "The patient had fever peaks over the last couple of days. He" - " is worried about these peaks." - ) - assert inst.extension[2].url == ( - "http://example.org/do-not-use/fhir-" "extensions/referral#fulfillingEncounter" - ) - assert inst.extension[2].valueReference.reference == "Encounter/f201" - assert inst.id == "referral" - assert inst.identifier[0].system == "http://goodhealth.org/basic/identifiers" - assert inst.identifier[0].value == "19283746" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.modifierExtension[0].url == ( - "http://example.org/do-not-use/fhir-" "extensions/referral#referredForService" - ) - assert inst.modifierExtension[0].valueCodeableConcept.coding[0].code == "11429006" - assert ( - inst.modifierExtension[0].valueCodeableConcept.coding[0].display - == "Consultation" - ) - assert ( - inst.modifierExtension[0].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.modifierExtension[1].url == ( - "http://example.org/do-not-use/fhir-" "extensions/referral#targetDate" - ) - assert inst.modifierExtension[1].valuePeriod.end == fhirtypes.DateTime.validate( - "2013-04-15T11:15:33+10:00" - ) - assert inst.modifierExtension[1].valuePeriod.start == fhirtypes.DateTime.validate( - "2013-04-01T11:15:33+10:00" - ) - assert inst.modifierExtension[2].url == ( - "http://example.org/do-not-use/fhir-" "extensions/referral#status" - ) - assert inst.modifierExtension[2].valueCode == "complete" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - - -def test_basic_3(base_settings): - """No. 3 tests collection for Basic. - Test File: basic-example.json - """ - filename = base_settings["unittest_data_dir"] / "basic-example.json" - inst = basic.Basic.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Basic" == inst.resource_type - - impl_basic_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Basic" == data["resourceType"] - - inst2 = basic.Basic(**data) - impl_basic_3(inst2) diff --git a/fhir/resources/tests/test_binary.py b/fhir/resources/tests/test_binary.py deleted file mode 100644 index 4a1bd5b8..00000000 --- a/fhir/resources/tests/test_binary.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Binary -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import binary - - -def impl_binary_1(inst): - assert inst.contentType == "application/pdf" - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.securityContext.reference == "DocumentReference/example" - - -def test_binary_1(base_settings): - """No. 1 tests collection for Binary. - Test File: binary-example.json - """ - filename = base_settings["unittest_data_dir"] / "binary-example.json" - inst = binary.Binary.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Binary" == inst.resource_type - - impl_binary_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Binary" == data["resourceType"] - - inst2 = binary.Binary(**data) - impl_binary_1(inst2) - - -def impl_binary_2(inst): - assert inst.contentType == "image/jpeg" - assert inst.id == "f006" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - - -def test_binary_2(base_settings): - """No. 2 tests collection for Binary. - Test File: binary-f006.json - """ - filename = base_settings["unittest_data_dir"] / "binary-f006.json" - inst = binary.Binary.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Binary" == inst.resource_type - - impl_binary_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Binary" == data["resourceType"] - - inst2 = binary.Binary(**data) - impl_binary_2(inst2) diff --git a/fhir/resources/tests/test_biologicallyderivedproduct.py b/fhir/resources/tests/test_biologicallyderivedproduct.py deleted file mode 100644 index 9f0d976b..00000000 --- a/fhir/resources/tests/test_biologicallyderivedproduct.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/BiologicallyDerivedProduct -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import biologicallyderivedproduct - - -def impl_biologicallyderivedproduct_1(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_biologicallyderivedproduct_1(base_settings): - """No. 1 tests collection for BiologicallyDerivedProduct. - Test File: biologicallyderivedproduct-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "biologicallyderivedproduct-example.json" - ) - inst = biologicallyderivedproduct.BiologicallyDerivedProduct.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "BiologicallyDerivedProduct" == inst.resource_type - - impl_biologicallyderivedproduct_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "BiologicallyDerivedProduct" == data["resourceType"] - - inst2 = biologicallyderivedproduct.BiologicallyDerivedProduct(**data) - impl_biologicallyderivedproduct_1(inst2) diff --git a/fhir/resources/tests/test_bodystructure.py b/fhir/resources/tests/test_bodystructure.py deleted file mode 100644 index 8d3664f5..00000000 --- a/fhir/resources/tests/test_bodystructure.py +++ /dev/null @@ -1,152 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/BodyStructure -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import bodystructure - - -def impl_bodystructure_1(inst): - assert inst.description == "EDD 1/1/2017 confirmation by LMP" - assert inst.id == "fetus" - assert ( - inst.identifier[0].system == "http://goodhealth.org/bodystructure/identifiers" - ) - assert inst.identifier[0].value == "12345" - assert inst.location.coding[0].code == "83418008" - assert inst.location.coding[0].display == "Entire fetus (body structure)" - assert inst.location.coding[0].system == "http://snomed.info/sct" - assert inst.location.text == "Fetus" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_bodystructure_1(base_settings): - """No. 1 tests collection for BodyStructure. - Test File: bodystructure-example-fetus.json - """ - filename = base_settings["unittest_data_dir"] / "bodystructure-example-fetus.json" - inst = bodystructure.BodyStructure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "BodyStructure" == inst.resource_type - - impl_bodystructure_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "BodyStructure" == data["resourceType"] - - inst2 = bodystructure.BodyStructure(**data) - impl_bodystructure_1(inst2) - - -def impl_bodystructure_2(inst): - assert inst.description == "7 cm maximum diameter" - assert inst.id == "tumor" - assert ( - inst.identifier[0].system == "http://goodhealth.org/bodystructure/identifiers" - ) - assert inst.identifier[0].value == "12345" - assert inst.image[0].contentType == "application/dicom" - assert inst.image[0].url == ( - "http://imaging.acme.com/wado/server?requestType=WADO&wad" "o_details" - ) - assert inst.location.coding[0].code == "78961009" - assert inst.location.coding[0].display == "Splenic structure (body structure)" - assert inst.location.coding[0].system == "http://snomed.info/sct" - assert inst.location.text == "Spleen" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.morphology.coding[0].code == "4147007" - assert inst.morphology.coding[0].display == "Mass (morphologic abnormality)" - assert inst.morphology.coding[0].system == "http://snomed.info/sct" - assert inst.morphology.text == "Splenic mass" - assert inst.patient.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_bodystructure_2(base_settings): - """No. 2 tests collection for BodyStructure. - Test File: bodystructure-example-tumor.json - """ - filename = base_settings["unittest_data_dir"] / "bodystructure-example-tumor.json" - inst = bodystructure.BodyStructure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "BodyStructure" == inst.resource_type - - impl_bodystructure_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "BodyStructure" == data["resourceType"] - - inst2 = bodystructure.BodyStructure(**data) - impl_bodystructure_2(inst2) - - -def impl_bodystructure_3(inst): - assert inst.active is False - assert inst.description == "inner surface (volar) of the left forearm" - assert inst.id == "skin-patch" - assert ( - inst.identifier[0].system == "http://goodhealth.org/bodystructure/identifiers" - ) - assert inst.identifier[0].value == "12345" - assert inst.location.coding[0].code == "14975008" - assert inst.location.coding[0].display == "Forearm" - assert inst.location.coding[0].system == "http://snomed.info/sct" - assert inst.location.text == "Forearm" - assert inst.locationQualifier[0].coding[0].code == "419161000" - assert inst.locationQualifier[0].coding[0].display == "Unilateral left" - assert inst.locationQualifier[0].coding[0].system == "http://snomed.info/sct" - assert inst.locationQualifier[0].text == "Left" - assert inst.locationQualifier[1].coding[0].code == "263929005" - assert inst.locationQualifier[1].coding[0].display == "Volar" - assert inst.locationQualifier[1].coding[0].system == "http://snomed.info/sct" - assert inst.locationQualifier[1].text == "Volar" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.morphology.text == "Skin patch" - assert inst.patient.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_bodystructure_3(base_settings): - """No. 3 tests collection for BodyStructure. - Test File: bodystructure-example-skin-patch.json - """ - filename = ( - base_settings["unittest_data_dir"] / "bodystructure-example-skin-patch.json" - ) - inst = bodystructure.BodyStructure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "BodyStructure" == inst.resource_type - - impl_bodystructure_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "BodyStructure" == data["resourceType"] - - inst2 = bodystructure.BodyStructure(**data) - impl_bodystructure_3(inst2) diff --git a/fhir/resources/tests/test_bundle.py b/fhir/resources/tests/test_bundle.py deleted file mode 100644 index e0890c38..00000000 --- a/fhir/resources/tests/test_bundle.py +++ /dev/null @@ -1,424 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Bundle -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import bundle - - -def impl_bundle_1(inst): - assert inst.entry[0].resource.id == "warning" - assert inst.entry[0].search.mode == "outcome" - assert inst.id == "bundle-search-warning" - assert inst.link[0].relation == "self" - assert inst.link[0].url == ( - "https://example.org/fhir/Observation?patient.identifier=http" - "://example.com/fhir/identifier/mrn|123456" - ) - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2017-03-14T08:23:30+11:00" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.total == 0 - assert inst.type == "searchset" - - -def test_bundle_1(base_settings): - """No. 1 tests collection for Bundle. - Test File: bundle-search-warning.json - """ - filename = base_settings["unittest_data_dir"] / "bundle-search-warning.json" - inst = bundle.Bundle.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Bundle" == inst.resource_type - - impl_bundle_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Bundle" == data["resourceType"] - - inst2 = bundle.Bundle(**data) - impl_bundle_1(inst2) - - -def impl_bundle_2(inst): - assert inst.entry[0].fullUrl == "https://example.com/base/DiagnosticReport/f202" - assert inst.entry[0].resource.id == "f202" - assert inst.entry[1].fullUrl == "https://example.com/base/ServiceRequest/req" - assert inst.entry[1].resource.id == "req" - assert inst.id == "f202" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.type == "collection" - - -def test_bundle_2(base_settings): - """No. 2 tests collection for Bundle. - Test File: diagnosticreport-example-f202-bloodculture.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "diagnosticreport-example-f202-bloodculture.json" - ) - inst = bundle.Bundle.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Bundle" == inst.resource_type - - impl_bundle_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Bundle" == data["resourceType"] - - inst2 = bundle.Bundle(**data) - impl_bundle_2(inst2) - - -def impl_bundle_3(inst): - assert inst.entry[0].fullUrl == "urn:uuid:d9d296d8-5afd-42e1-a0ce-3344e0e003ed" - assert inst.entry[0].resource.id == "caf609cf-c3a7-4be3-a3aa-356b9bb69d4f" - assert inst.entry[1].fullUrl == "urn:uuid:03f9aa7d-b395-47b9-84e0-053678b6e4e3" - assert inst.entry[1].resource.id == "03f9aa7d-b395-47b9-84e0-053678b6e4e3" - assert inst.entry[2].fullUrl == "http://acme.com/ehr/fhir/Patient/pat1" - assert inst.entry[2].resource.id == "pat1" - assert inst.entry[3].fullUrl == "http://acme.com/ehr/fhir/Patient/pat12" - assert inst.entry[3].resource.id == "pat2" - assert inst.id == "3a0707d3-549e-4467-b8b8-5a2ab3800efe" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.timestamp == fhirtypes.Instant.validate("2015-07-14T11:15:33+10:00") - assert inst.type == "message" - - -def test_bundle_3(base_settings): - """No. 3 tests collection for Bundle. - Test File: message-response-link.json - """ - filename = base_settings["unittest_data_dir"] / "message-response-link.json" - inst = bundle.Bundle.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Bundle" == inst.resource_type - - impl_bundle_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Bundle" == data["resourceType"] - - inst2 = bundle.Bundle(**data) - impl_bundle_3(inst2) - - -def impl_bundle_4(inst): - assert inst.entry[0].fullUrl == "urn:uuid:3fdc72f4-a11d-4a9d-9260-a9f745779e1d" - assert inst.entry[0].request.method == "POST" - assert inst.entry[0].request.url == "DocumentReference" - assert inst.entry[0].resource.meta.lastUpdated == fhirtypes.Instant.validate( - "2013-07-01T13:11:33Z" - ) - assert inst.entry[1].fullUrl == "http://localhost:9556/svc/fhir/Patient/a2" - assert ( - inst.entry[1].request.ifNoneExist - == "Patient?identifier=http://acme.org/xds/patients!89765a87b" - ) - assert inst.entry[1].request.method == "POST" - assert inst.entry[1].request.url == "Patient" - assert inst.entry[1].resource.id == "a2" - assert inst.entry[1].resource.meta.lastUpdated == fhirtypes.Instant.validate( - "2013-07-01T13:11:33Z" - ) - assert inst.entry[2].fullUrl == "http://localhost:9556/svc/fhir/Practitioner/a3" - assert inst.entry[2].request.method == "POST" - assert inst.entry[2].request.url == "Practitioner" - assert inst.entry[2].resource.id == "a3" - assert inst.entry[2].resource.meta.lastUpdated == fhirtypes.Instant.validate( - "2013-07-01T13:11:33Z" - ) - assert inst.entry[3].fullUrl == "http://localhost:9556/svc/fhir/Practitioner/a4" - assert inst.entry[3].request.method == "POST" - assert inst.entry[3].request.url == "Practitioner" - assert inst.entry[3].resource.id == "a4" - assert inst.entry[3].resource.meta.lastUpdated == fhirtypes.Instant.validate( - "2013-07-01T13:11:33Z" - ) - assert inst.entry[4].fullUrl == ( - "http://localhost:9556/svc/fhir/Binary/1e404af3-077f-4bee-b7a" "6-a9be97e1ce32" - ) - assert inst.entry[4].request.method == "POST" - assert inst.entry[4].request.url == "Binary" - assert inst.entry[4].resource.id == "1e404af3-077f-4bee-b7a6-a9be97e1ce32" - assert inst.entry[4].resource.meta.lastUpdated == fhirtypes.Instant.validate( - "2013-07-01T13:11:33Z" - ) - assert inst.id == "xds" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate("2013-07-01T13:11:33Z") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.type == "transaction" - - -def test_bundle_4(base_settings): - """No. 4 tests collection for Bundle. - Test File: xds-example.json - """ - filename = base_settings["unittest_data_dir"] / "xds-example.json" - inst = bundle.Bundle.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Bundle" == inst.resource_type - - impl_bundle_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Bundle" == data["resourceType"] - - inst2 = bundle.Bundle(**data) - impl_bundle_4(inst2) - - -def impl_bundle_5(inst): - assert ( - inst.entry[0].fullUrl - == "http://hl7.org/fhir/SearchParameter/DomainResource-text" - ) - assert inst.entry[0].resource.id == "DomainResource-text" - assert ( - inst.entry[1].fullUrl == "http://hl7.org/fhir/SearchParameter/Resource-content" - ) - assert inst.entry[1].resource.id == "Resource-content" - assert inst.entry[2].fullUrl == "http://hl7.org/fhir/SearchParameter/Resource-id" - assert inst.entry[2].resource.id == "Resource-id" - assert ( - inst.entry[3].fullUrl - == "http://hl7.org/fhir/SearchParameter/Resource-lastUpdated" - ) - assert inst.entry[3].resource.id == "Resource-lastUpdated" - assert ( - inst.entry[4].fullUrl == "http://hl7.org/fhir/SearchParameter/Resource-profile" - ) - assert inst.entry[4].resource.id == "Resource-profile" - assert inst.entry[5].fullUrl == "http://hl7.org/fhir/SearchParameter/Resource-query" - assert inst.entry[5].resource.id == "Resource-query" - assert ( - inst.entry[6].fullUrl == "http://hl7.org/fhir/SearchParameter/Resource-security" - ) - assert inst.entry[6].resource.id == "Resource-security" - assert ( - inst.entry[7].fullUrl == "http://hl7.org/fhir/SearchParameter/Resource-source" - ) - assert inst.entry[7].resource.id == "Resource-source" - assert inst.entry[8].fullUrl == "http://hl7.org/fhir/SearchParameter/Resource-tag" - assert inst.entry[8].resource.id == "Resource-tag" - assert ( - inst.entry[9].fullUrl - == "http://hl7.org/fhir/SearchParameter/Account-identifier" - ) - assert inst.entry[9].resource.id == "Account-identifier" - assert inst.id == "searchParams" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.type == "collection" - - -def test_bundle_5(base_settings): - """No. 5 tests collection for Bundle. - Test File: search-parameters.json - """ - filename = base_settings["unittest_data_dir"] / "search-parameters.json" - inst = bundle.Bundle.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Bundle" == inst.resource_type - - impl_bundle_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Bundle" == data["resourceType"] - - inst2 = bundle.Bundle(**data) - impl_bundle_5(inst2) - - -def impl_bundle_6(inst): - assert inst.entry[0].fullUrl == "urn:uuid:267b18ce-3d37-4581-9baa-6fada338038b" - assert inst.entry[0].resource.id == "267b18ce-3d37-4581-9baa-6fada338038b" - assert inst.entry[1].fullUrl == "http://acme.com/ehr/fhir/Patient/pat1" - assert inst.entry[1].resource.id == "pat1" - assert inst.entry[2].fullUrl == "http://acme.com/ehr/fhir/Patient/pat12" - assert inst.entry[2].resource.id == "pat2" - assert inst.id == "10bb101f-a121-4264-a920-67be9cb82c74" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.timestamp == fhirtypes.Instant.validate("2015-07-14T11:15:33+10:00") - assert inst.type == "message" - - -def test_bundle_6(base_settings): - """No. 6 tests collection for Bundle. - Test File: message-request-link.json - """ - filename = base_settings["unittest_data_dir"] / "message-request-link.json" - inst = bundle.Bundle.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Bundle" == inst.resource_type - - impl_bundle_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Bundle" == data["resourceType"] - - inst2 = bundle.Bundle(**data) - impl_bundle_6(inst2) - - -def impl_bundle_7(inst): - assert inst.entry[0].fullUrl == "http://hl7.org/fhir/NamingSystem/tx-sct" - assert inst.entry[0].resource.id == "tx-sct" - assert inst.entry[1].fullUrl == "http://hl7.org/fhir/NamingSystem/tx-rxnorm" - assert inst.entry[1].resource.id == "tx-rxnorm" - assert inst.entry[2].fullUrl == "http://hl7.org/fhir/NamingSystem/tx-loinc" - assert inst.entry[2].resource.id == "tx-loinc" - assert inst.entry[3].fullUrl == "http://hl7.org/fhir/NamingSystem/tx-ucum" - assert inst.entry[3].resource.id == "tx-ucum" - assert inst.entry[4].fullUrl == "http://hl7.org/fhir/NamingSystem/tx-nci" - assert inst.entry[4].resource.id == "tx-nci" - assert inst.entry[5].fullUrl == "http://hl7.org/fhir/NamingSystem/tx-cpt" - assert inst.entry[5].resource.id == "tx-cpt" - assert inst.entry[6].fullUrl == "http://hl7.org/fhir/NamingSystem/tx-ndf-rt" - assert inst.entry[6].resource.id == "tx-ndf-rt" - assert inst.entry[7].fullUrl == "http://hl7.org/fhir/NamingSystem/tx-unii" - assert inst.entry[7].resource.id == "tx-unii" - assert inst.entry[8].fullUrl == "http://hl7.org/fhir/NamingSystem/tx-ndc" - assert inst.entry[8].resource.id == "tx-ndc" - assert inst.entry[9].fullUrl == "http://hl7.org/fhir/NamingSystem/tx-cvx" - assert inst.entry[9].resource.id == "tx-cvx" - assert inst.id == "terminologies" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.type == "collection" - - -def test_bundle_7(base_settings): - """No. 7 tests collection for Bundle. - Test File: namingsystem-terminologies.json - """ - filename = base_settings["unittest_data_dir"] / "namingsystem-terminologies.json" - inst = bundle.Bundle.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Bundle" == inst.resource_type - - impl_bundle_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Bundle" == data["resourceType"] - - inst2 = bundle.Bundle(**data) - impl_bundle_7(inst2) - - -def impl_bundle_8(inst): - assert ( - inst.entry[0].fullUrl - == "http://hl7.org/fhir/ConceptMap/cm-contact-point-use-v3" - ) - assert inst.entry[0].resource.id == "cm-contact-point-use-v3" - assert ( - inst.entry[1].fullUrl - == "http://hl7.org/fhir/ConceptMap/cm-contact-point-use-v2" - ) - assert inst.entry[1].resource.id == "cm-contact-point-use-v2" - assert inst.entry[2].fullUrl == "http://hl7.org/fhir/ConceptMap/cm-address-type-v3" - assert inst.entry[2].resource.id == "cm-address-type-v3" - assert inst.entry[3].fullUrl == "http://hl7.org/fhir/ConceptMap/cm-name-use-v2" - assert inst.entry[3].resource.id == "cm-name-use-v2" - assert inst.entry[4].fullUrl == "http://hl7.org/fhir/ConceptMap/cm-name-use-v3" - assert inst.entry[4].resource.id == "cm-name-use-v3" - assert inst.entry[5].fullUrl == "http://hl7.org/fhir/ConceptMap/cm-address-use-v3" - assert inst.entry[5].resource.id == "cm-address-use-v3" - assert ( - inst.entry[6].fullUrl - == "http://hl7.org/fhir/ConceptMap/cm-administrative-gender-v2" - ) - assert inst.entry[6].resource.id == "cm-administrative-gender-v2" - assert ( - inst.entry[7].fullUrl - == "http://hl7.org/fhir/ConceptMap/cm-administrative-gender-v3" - ) - assert inst.entry[7].resource.id == "cm-administrative-gender-v3" - assert inst.entry[8].fullUrl == ( - "http://hl7.org/fhir/ConceptMap/cm-document-reference-" "status-v3" - ) - assert inst.entry[8].resource.id == "cm-document-reference-status-v3" - assert inst.entry[9].fullUrl == "http://hl7.org/fhir/ConceptMap/cm-address-use-v2" - assert inst.entry[9].resource.id == "cm-address-use-v2" - assert inst.id == "conceptmaps" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.type == "collection" - - -def test_bundle_8(base_settings): - """No. 8 tests collection for Bundle. - Test File: conceptmaps.json - """ - filename = base_settings["unittest_data_dir"] / "conceptmaps.json" - inst = bundle.Bundle.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Bundle" == inst.resource_type - - impl_bundle_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Bundle" == data["resourceType"] - - inst2 = bundle.Bundle(**data) - impl_bundle_8(inst2) diff --git a/fhir/resources/tests/test_capabilitystatement.py b/fhir/resources/tests/test_capabilitystatement.py deleted file mode 100644 index 765f4215..00000000 --- a/fhir/resources/tests/test_capabilitystatement.py +++ /dev/null @@ -1,2457 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CapabilityStatement -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import capabilitystatement - - -def impl_capabilitystatement_1(inst): - assert inst.contact[0].name == "System Administrator" - assert inst.contact[0].telecom[0].system == "email" - assert inst.contact[0].telecom[0].value == "wile@acme.org" - assert inst.date == fhirtypes.DateTime.validate("2012-01-04T12:09:24+00:06") - assert inst.description == ( - "Sample capability statement showing new MessageDefinition " "structure" - ) - assert inst.experimental is True - assert inst.fhirVersion == "4.0.1" - assert inst.format[0] == "xml" - assert inst.format[1] == "json" - assert inst.id == "messagedefinition" - assert inst.implementation.description == "Acme Message endpoint" - assert inst.implementation.url == "http://acem.com/fhir/message-drop" - assert inst.kind == "instance" - assert ( - inst.messaging[0].documentation - == "ADT A08 equivalent for external system notifications" - ) - assert inst.messaging[0].endpoint[0].address == "mllp:10.1.1.10:9234" - assert inst.messaging[0].endpoint[0].protocol.code == "mllp" - assert ( - inst.messaging[0].endpoint[0].protocol.system - == "http://terminology.hl7.org/CodeSystem/message-transport" - ) - assert inst.messaging[0].reliableCache == 30 - assert ( - inst.messaging[0].supportedMessage[0].definition == "MessageDefinition/example" - ) - assert inst.messaging[0].supportedMessage[0].mode == "receiver" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "ACME Corporation" - assert inst.software.name == "EHR" - assert inst.status == "draft" - assert inst.text.status == "generated" - - -def test_capabilitystatement_1(base_settings): - """No. 1 tests collection for CapabilityStatement. - Test File: capabilitystatement-messagedefinition.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "capabilitystatement-messagedefinition.json" - ) - inst = capabilitystatement.CapabilityStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CapabilityStatement" == inst.resource_type - - impl_capabilitystatement_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CapabilityStatement" == data["resourceType"] - - inst2 = capabilitystatement.CapabilityStatement(**data) - impl_capabilitystatement_1(inst2) - - -def impl_capabilitystatement_2(inst): - assert inst.contact[0].name == "System Administrator" - assert inst.contact[0].telecom[0].system == "email" - assert inst.contact[0].telecom[0].value == "wile@acme.org" - assert inst.copyright == "Copyright © Acme Healthcare and GoodCorp EHR Systems" - assert inst.date == fhirtypes.DateTime.validate("2012-01-04T12:09:24+00:06") - assert inst.description == ( - "This is the FHIR capability statement for the main EHR at " - "ACME for the private interface - it does not describe the " - "public interface" - ) - assert ( - inst.document[0].documentation - == "Basic rules for all documents in the EHR system" - ) - assert inst.document[0].mode == "consumer" - assert inst.document[0].profile == ( - "http://fhir.hl7.org/base/Profilebc054d23-75e1-4dc6-aca5-838b" - "6b1ac81d/_history/b5fdd9fc-b021-4ea1-911a-721a60663796" - ) - assert inst.experimental is True - assert inst.fhirVersion == "4.0.1" - assert inst.format[0] == "xml" - assert inst.format[1] == "json" - assert inst.id == "example" - assert inst.implementation.description == "main EHR at ACME" - assert inst.implementation.url == "http://10.2.3.4/fhir" - assert inst.implementationGuide[0] == "http://hl7.org/fhir/us/lab" - assert inst.instantiates[0] == "http://ihe.org/fhir/CapabilityStatement/pixm-client" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America (the)" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.kind == "instance" - assert ( - inst.messaging[0].documentation - == "ADT A08 equivalent for external system notifications" - ) - assert inst.messaging[0].endpoint[0].address == "mllp://10.1.1.10:9234" - assert inst.messaging[0].endpoint[0].protocol.code == "mllp" - assert ( - inst.messaging[0].endpoint[0].protocol.system - == "http://terminology.hl7.org/CodeSystem/message-transport" - ) - assert inst.messaging[0].reliableCache == 30 - assert ( - inst.messaging[0].supportedMessage[0].definition == "MessageDefinition/example" - ) - assert inst.messaging[0].supportedMessage[0].mode == "receiver" - assert inst.name == "ACME-EHR" - assert inst.patchFormat[0] == "application/xml-patch+xml" - assert inst.patchFormat[1] == "application/json-patch+json" - assert inst.publisher == "ACME Corporation" - assert inst.purpose == ( - "Main EHR capability statement, published for contracting and" - " operational support" - ) - assert ( - inst.rest[0].compartment[0] - == "http://hl7.org/fhir/CompartmentDefinition/patient" - ) - assert inst.rest[0].documentation == "Main FHIR endpoint for acem health" - assert inst.rest[0].interaction[0].code == "transaction" - assert inst.rest[0].interaction[1].code == "history-system" - assert inst.rest[0].mode == "server" - assert inst.rest[0].resource[0].conditionalCreate is True - assert inst.rest[0].resource[0].conditionalDelete == "not-supported" - assert inst.rest[0].resource[0].conditionalRead == "full-support" - assert inst.rest[0].resource[0].conditionalUpdate is False - assert ( - inst.rest[0].resource[0].documentation - == "This server does not let the clients create identities." - ) - assert inst.rest[0].resource[0].interaction[0].code == "read" - assert inst.rest[0].resource[0].interaction[1].code == "vread" - assert ( - inst.rest[0].resource[0].interaction[1].documentation - == "Only supported for patient records since 12-Dec 2012" - ) - assert inst.rest[0].resource[0].interaction[2].code == "update" - assert inst.rest[0].resource[0].interaction[3].code == "history-instance" - assert inst.rest[0].resource[0].interaction[4].code == "create" - assert inst.rest[0].resource[0].interaction[5].code == "history-type" - assert inst.rest[0].resource[0].profile == ( - "http://registry.fhir.org/r4/StructureDefinition/7896271d-57f" - "6-4231-89dc-dcc91eab2416" - ) - assert inst.rest[0].resource[0].readHistory is True - assert inst.rest[0].resource[0].searchInclude[0] == "Organization" - assert ( - inst.rest[0].resource[0].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/Patient-identifier" - ) - assert ( - inst.rest[0].resource[0].searchParam[0].documentation - == "Only supports search by institution MRN" - ) - assert inst.rest[0].resource[0].searchParam[0].name == "identifier" - assert inst.rest[0].resource[0].searchParam[0].type == "token" - assert inst.rest[0].resource[0].searchParam[1].definition == ( - "http://hl7.org/fhir/SearchParameter/Patient-general-" "practitioner" - ) - assert inst.rest[0].resource[0].searchParam[1].name == "general-practitioner" - assert inst.rest[0].resource[0].searchParam[1].type == "reference" - assert inst.rest[0].resource[0].searchRevInclude[0] == "Person" - assert inst.rest[0].resource[0].supportedProfile[0] == ( - "http://registry.fhir.org/r4/StructureDefinition/00ab9e7a-06c" - "7-4f77-9234-4154ca1e3347" - ) - assert inst.rest[0].resource[0].type == "Patient" - assert inst.rest[0].resource[0].updateCreate is False - assert inst.rest[0].resource[0].versioning == "versioned-update" - assert inst.rest[0].security.cors is True - assert inst.rest[0].security.description == "See Smart on FHIR documentation" - assert inst.rest[0].security.service[0].coding[0].code == "SMART-on-FHIR" - assert inst.rest[0].security.service[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/restful-security-" "service" - ) - assert inst.software.name == "EHR" - assert inst.software.releaseDate == fhirtypes.DateTime.validate( - "2012-01-04T12:09:24+00:06" - ) - assert inst.software.version == "0.00.020.2134" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "ACME EHR capability statement" - assert inst.url == "urn:uuid:68D043B5-9ECF-4559-A57A-396E0D452311" - assert inst.useContext[0].code.code == "focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "positive" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://terminology.hl7.org/CodeSystem/variant-state" - ) - assert inst.version == "20130510" - - -def test_capabilitystatement_2(base_settings): - """No. 2 tests collection for CapabilityStatement. - Test File: capabilitystatement-example.json - """ - filename = base_settings["unittest_data_dir"] / "capabilitystatement-example.json" - inst = capabilitystatement.CapabilityStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CapabilityStatement" == inst.resource_type - - impl_capabilitystatement_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CapabilityStatement" == data["resourceType"] - - inst2 = capabilitystatement.CapabilityStatement(**data) - impl_capabilitystatement_2(inst2) - - -def impl_capabilitystatement_3(inst): - assert inst.contact[0].name == "FHIR Project" - assert inst.contact[0].telecom[0].system == "other" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2016-09-16T12:09:24+00:06") - assert inst.description == ( - "Basic conformance statement for a Measure Processor Service." - " A server can support more functionality than defined " - "here, but this is the minimum amount" - ) - assert inst.fhirVersion == "4.0.1" - assert inst.format[0] == "json" - assert inst.format[1] == "xml" - assert inst.id == "measure-processor" - assert inst.kind == "capability" - assert inst.name == "Measure Processor Service Conformance Statement" - assert inst.publisher == "HL7, Inc" - assert inst.rest[0].documentation == "RESTful Measure Processor Service" - assert inst.rest[0].mode == "server" - assert ( - inst.rest[0].operation[0].definition - == "OperationDefinition/Measure-evaluate-measure" - ) - assert inst.rest[0].operation[0].name == "evaluate-measure" - assert ( - inst.rest[0].operation[1].definition - == "OperationDefinition/Measure-data-requirements" - ) - assert inst.rest[0].operation[1].name == "data-requirements" - assert inst.rest[0].resource[0].interaction[0].code == "read" - assert inst.rest[0].resource[0].interaction[0].documentation == ( - "Read allows clients to get the logical definitions of the " "measures" - ) - assert inst.rest[0].resource[0].interaction[1].code == "search-type" - assert inst.rest[0].resource[0].interaction[1].documentation == ( - "Search allows clients to filter measures based on a provided" - " search parameter" - ) - assert inst.rest[0].resource[0].profile == "StructureDefinition/Measure" - assert ( - inst.rest[0].resource[0].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/Measure-identifier" - ) - assert inst.rest[0].resource[0].searchParam[0].name == "identifier" - assert inst.rest[0].resource[0].searchParam[0].type == "token" - assert ( - inst.rest[0].resource[0].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/Measure-status" - ) - assert inst.rest[0].resource[0].searchParam[1].name == "status" - assert inst.rest[0].resource[0].searchParam[1].type == "token" - assert ( - inst.rest[0].resource[0].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/Measure-version" - ) - assert inst.rest[0].resource[0].searchParam[2].name == "version" - assert inst.rest[0].resource[0].searchParam[2].type == "string" - assert inst.rest[0].resource[0].type == "Measure" - assert inst.rest[0].security.cors is True - assert inst.rest[0].security.service[0].coding[0].code == "Certificates" - assert inst.rest[0].security.service[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/restful-security-" "service" - ) - assert inst.software.name == "ACME Measure Processor Service" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/measure-processor" - - -def test_capabilitystatement_3(base_settings): - """No. 3 tests collection for CapabilityStatement. - Test File: capabilitystatement-measure-processor.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "capabilitystatement-measure-processor.json" - ) - inst = capabilitystatement.CapabilityStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CapabilityStatement" == inst.resource_type - - impl_capabilitystatement_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CapabilityStatement" == data["resourceType"] - - inst2 = capabilitystatement.CapabilityStatement(**data) - impl_capabilitystatement_3(inst2) - - -def impl_capabilitystatement_4(inst): - assert inst.contact[0].name == "FHIR Project" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2015-07-05T12:09:24+00:06") - assert inst.description == ( - "Basic capability statement for a Terminology Server. A " - "server can support more fucntionality than defined here, but" - " this is the minimum amount" - ) - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/capabilitystatement-" - "supported-system" - ) - assert inst.extension[0].valueUri == "http://loinc.org" - assert inst.fhirVersion == "4.0.1" - assert inst.format[0] == "json" - assert inst.format[1] == "xml" - assert inst.id == "terminology-server" - assert inst.kind == "capability" - assert inst.name == "Terminology Service Capability Statement" - assert inst.publisher == "HL7, Inc" - assert inst.rest[0].documentation == "RESTful Terminology Server" - assert inst.rest[0].mode == "server" - assert inst.rest[0].operation[0].definition == "OperationDefinition/ValueSet-expand" - assert inst.rest[0].operation[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/capabilitystatement-" "expectation" - ) - assert inst.rest[0].operation[0].extension[0].valueCode == "SHALL" - assert inst.rest[0].operation[0].name == "expand" - assert ( - inst.rest[0].operation[1].definition == "OperationDefinition/CodeSystem-lookup" - ) - assert inst.rest[0].operation[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/capabilitystatement-" "expectation" - ) - assert inst.rest[0].operation[1].extension[0].valueCode == "SHALL" - assert inst.rest[0].operation[1].name == "lookup" - assert ( - inst.rest[0].operation[2].definition - == "OperationDefinition/ValueSet-validate-code" - ) - assert inst.rest[0].operation[2].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/capabilitystatement-" "expectation" - ) - assert inst.rest[0].operation[2].extension[0].valueCode == "SHALL" - assert inst.rest[0].operation[2].name == "validate-code" - assert ( - inst.rest[0].operation[3].definition - == "OperationDefinition/ConceptMap-translate" - ) - assert inst.rest[0].operation[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/capabilitystatement-" "expectation" - ) - assert inst.rest[0].operation[3].extension[0].valueCode == "SHALL" - assert inst.rest[0].operation[3].name == "translate" - assert ( - inst.rest[0].operation[4].definition == "OperationDefinition/ConceptMap-closure" - ) - assert inst.rest[0].operation[4].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/capabilitystatement-" "expectation" - ) - assert inst.rest[0].operation[4].extension[0].valueCode == "SHOULD" - assert inst.rest[0].operation[4].name == "closure" - assert inst.rest[0].resource[0].interaction[0].code == "read" - assert inst.rest[0].resource[0].interaction[0].documentation == ( - "Read allows clients to get the logical definitions of the " "value sets" - ) - assert inst.rest[0].resource[0].interaction[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/capabilitystatement-" "expectation" - ) - assert inst.rest[0].resource[0].interaction[0].extension[0].valueCode == "SHALL" - assert inst.rest[0].resource[0].interaction[1].code == "search-type" - assert ( - inst.rest[0].resource[0].interaction[1].documentation - == "Search allows clients to find value sets on the server" - ) - assert inst.rest[0].resource[0].interaction[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/capabilitystatement-" "expectation" - ) - assert inst.rest[0].resource[0].interaction[1].extension[0].valueCode == "SHALL" - assert inst.rest[0].resource[0].profile == "StructureDefinition/ValueSet" - assert ( - inst.rest[0].resource[0].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/ValueSet-date" - ) - assert inst.rest[0].resource[0].searchParam[0].name == "date" - assert inst.rest[0].resource[0].searchParam[0].type == "date" - assert ( - inst.rest[0].resource[0].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/ValueSet-name" - ) - assert inst.rest[0].resource[0].searchParam[1].name == "name" - assert inst.rest[0].resource[0].searchParam[1].type == "string" - assert ( - inst.rest[0].resource[0].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/ValueSet-reference" - ) - assert inst.rest[0].resource[0].searchParam[2].name == "reference" - assert inst.rest[0].resource[0].searchParam[2].type == "token" - assert ( - inst.rest[0].resource[0].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/ValueSet-status" - ) - assert inst.rest[0].resource[0].searchParam[3].name == "status" - assert inst.rest[0].resource[0].searchParam[3].type == "token" - assert ( - inst.rest[0].resource[0].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/ValueSet-url" - ) - assert inst.rest[0].resource[0].searchParam[4].name == "url" - assert inst.rest[0].resource[0].searchParam[4].type == "uri" - assert ( - inst.rest[0].resource[0].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/ValueSet-version" - ) - assert inst.rest[0].resource[0].searchParam[5].name == "version" - assert inst.rest[0].resource[0].searchParam[5].type == "token" - assert inst.rest[0].resource[0].type == "ValueSet" - assert inst.rest[0].resource[1].interaction[0].code == "read" - assert inst.rest[0].resource[1].interaction[0].documentation == ( - "Read allows clients to get the logical definitions of the " "concept maps" - ) - assert inst.rest[0].resource[1].interaction[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/capabilitystatement-" "expectation" - ) - assert inst.rest[0].resource[1].interaction[0].extension[0].valueCode == "SHALL" - assert inst.rest[0].resource[1].interaction[1].code == "search-type" - assert ( - inst.rest[0].resource[1].interaction[1].documentation - == "Search allows clients to find concept maps on the server" - ) - assert inst.rest[0].resource[1].interaction[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/capabilitystatement-" "expectation" - ) - assert inst.rest[0].resource[1].interaction[1].extension[0].valueCode == "SHALL" - assert inst.rest[0].resource[1].profile == "StructureDefinition/ConceptMap" - assert ( - inst.rest[0].resource[1].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/ConceptMap-date" - ) - assert inst.rest[0].resource[1].searchParam[0].name == "date" - assert inst.rest[0].resource[1].searchParam[0].type == "date" - assert ( - inst.rest[0].resource[1].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/ConceptMap-name" - ) - assert inst.rest[0].resource[1].searchParam[1].name == "name" - assert inst.rest[0].resource[1].searchParam[1].type == "string" - assert ( - inst.rest[0].resource[1].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/ConceptMap-status" - ) - assert inst.rest[0].resource[1].searchParam[2].name == "status" - assert inst.rest[0].resource[1].searchParam[2].type == "token" - assert ( - inst.rest[0].resource[1].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/ConceptMap-source" - ) - assert inst.rest[0].resource[1].searchParam[3].name == "source" - assert inst.rest[0].resource[1].searchParam[3].type == "uri" - assert ( - inst.rest[0].resource[1].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/ConceptMap-target" - ) - assert inst.rest[0].resource[1].searchParam[4].name == "target" - assert inst.rest[0].resource[1].searchParam[4].type == "uri" - assert ( - inst.rest[0].resource[1].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/ConceptMap-url" - ) - assert inst.rest[0].resource[1].searchParam[5].name == "url" - assert inst.rest[0].resource[1].searchParam[5].type == "uri" - assert ( - inst.rest[0].resource[1].searchParam[6].definition - == "http://hl7.org/fhir/SearchParameter/ConceptMap-version" - ) - assert inst.rest[0].resource[1].searchParam[6].name == "version" - assert inst.rest[0].resource[1].searchParam[6].type == "token" - assert inst.rest[0].resource[1].type == "ConceptMap" - assert inst.rest[0].security.cors is True - assert inst.rest[0].security.service[0].coding[0].code == "Certificates" - assert inst.rest[0].security.service[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/restful-security-" "service" - ) - assert inst.software.name == "ACME Terminology Server" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/terminology-server" - assert inst.version == "4.0.1" - - -def test_capabilitystatement_4(base_settings): - """No. 4 tests collection for CapabilityStatement. - Test File: capabilitystatement-terminology-server.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "capabilitystatement-terminology-server.json" - ) - inst = capabilitystatement.CapabilityStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CapabilityStatement" == inst.resource_type - - impl_capabilitystatement_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CapabilityStatement" == data["resourceType"] - - inst2 = capabilitystatement.CapabilityStatement(**data) - impl_capabilitystatement_4(inst2) - - -def impl_capabilitystatement_5(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.experimental is True - assert inst.fhirVersion == "4.0.1" - assert inst.format[0] == "xml" - assert inst.format[1] == "json" - assert inst.id == "base2" - assert inst.kind == "capability" - assert inst.name == "Base FHIR Capability Statement (Empty)" - assert inst.publisher == "FHIR Project Team" - assert inst.rest[0].documentation == "An empty Capability Statement" - assert inst.rest[0].mode == "server" - assert inst.rest[0].resource[0].interaction[0].code == "read" - assert ( - inst.rest[0].resource[0].interaction[0].documentation - == "Read CapabilityStatement Resource" - ) - assert inst.rest[0].resource[0].type == "CapabilityStatement" - assert inst.rest[0].security.cors is True - assert inst.rest[0].security.description == ( - "This is the Capability Statement to declare that the server " - "supports SMART-on-FHIR. See the SMART-on-FHIR docs for the " - "extension that would go with such a server" - ) - assert inst.rest[0].security.service[0].coding[0].code == "SMART-on-FHIR" - assert inst.rest[0].security.service[0].coding[0].display == "SMART-on-FHIR" - assert inst.rest[0].security.service[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/restful-security-" "service" - ) - assert inst.rest[0].security.service[0].text == "See http://docs.smarthealthit.org/" - assert inst.software.name == "Insert your software name here..." - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/CapabilityStatement/base2" - assert inst.version == "4.0.1" - - -def test_capabilitystatement_5(base_settings): - """No. 5 tests collection for CapabilityStatement. - Test File: capabilitystatement-base2.json - """ - filename = base_settings["unittest_data_dir"] / "capabilitystatement-base2.json" - inst = capabilitystatement.CapabilityStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CapabilityStatement" == inst.resource_type - - impl_capabilitystatement_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CapabilityStatement" == data["resourceType"] - - inst2 = capabilitystatement.CapabilityStatement(**data) - impl_capabilitystatement_5(inst2) - - -def impl_capabilitystatement_6(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2013-06-18T12:09:24+00:06") - assert inst.description == ( - "Prototype Capability Statement for September 2013 " "Connectathon" - ) - assert inst.fhirVersion == "4.0.1" - assert inst.format[0] == "json" - assert inst.format[1] == "xml" - assert inst.id == "phr" - assert inst.kind == "capability" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "PHR Template" - assert inst.publisher == "FHIR Project" - assert inst.rest[0].documentation == ( - "Protoype server Capability Statement for September 2013 " "Connectathon" - ) - assert inst.rest[0].mode == "server" - assert inst.rest[0].resource[0].interaction[0].code == "read" - assert inst.rest[0].resource[0].interaction[1].code == "search-type" - assert inst.rest[0].resource[0].interaction[1].documentation == ( - "When a client searches patients with no search criteria, " - "they get a list of all patients they have access too. " - "Servers may elect to offer additional search parameters, but" - " this is not required" - ) - assert inst.rest[0].resource[0].type == "Patient" - assert inst.rest[0].resource[1].interaction[0].code == "read" - assert inst.rest[0].resource[1].interaction[1].code == "search-type" - assert inst.rest[0].resource[1].searchParam[0].documentation == ( - "_id parameter always supported. For the connectathon, " - "servers may elect which search parameters are supported" - ) - assert inst.rest[0].resource[1].searchParam[0].name == "_id" - assert inst.rest[0].resource[1].searchParam[0].type == "token" - assert inst.rest[0].resource[1].type == "DocumentReference" - assert inst.rest[0].resource[2].interaction[0].code == "read" - assert inst.rest[0].resource[2].interaction[1].code == "search-type" - assert ( - inst.rest[0].resource[2].searchParam[0].documentation - == "Standard _id parameter" - ) - assert inst.rest[0].resource[2].searchParam[0].name == "_id" - assert inst.rest[0].resource[2].searchParam[0].type == "token" - assert inst.rest[0].resource[2].type == "Condition" - assert inst.rest[0].resource[3].interaction[0].code == "read" - assert inst.rest[0].resource[3].interaction[1].code == "search-type" - assert ( - inst.rest[0].resource[3].searchParam[0].documentation - == "Standard _id parameter" - ) - assert inst.rest[0].resource[3].searchParam[0].name == "_id" - assert inst.rest[0].resource[3].searchParam[0].type == "token" - assert ( - inst.rest[0].resource[3].searchParam[1].documentation - == "which diagnostic discipline/department created the report" - ) - assert inst.rest[0].resource[3].searchParam[1].name == "service" - assert inst.rest[0].resource[3].searchParam[1].type == "token" - assert inst.rest[0].resource[3].type == "DiagnosticReport" - assert inst.rest[0].security.service[0].text == "OAuth" - assert inst.software.name == "ACME PHR Server" - assert inst.status == "draft" - assert inst.text.status == "generated" - - -def test_capabilitystatement_6(base_settings): - """No. 6 tests collection for CapabilityStatement. - Test File: capabilitystatement-phr-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "capabilitystatement-phr-example.json" - ) - inst = capabilitystatement.CapabilityStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CapabilityStatement" == inst.resource_type - - impl_capabilitystatement_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CapabilityStatement" == data["resourceType"] - - inst2 = capabilitystatement.CapabilityStatement(**data) - impl_capabilitystatement_6(inst2) - - -def impl_capabilitystatement_7(inst): - assert inst.contact[0].name == "FHIR Project" - assert inst.contact[0].telecom[0].system == "other" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2017-02-25T12:09:24+00:06") - assert inst.description == ( - "Basic conformance statement for a Knowledge Repository " - "Service. A server can support more functionality than " - "defined here, but this is the minimum amount" - ) - assert inst.fhirVersion == "4.0.1" - assert inst.format[0] == "json" - assert inst.format[1] == "xml" - assert inst.id == "knowledge-repository" - assert inst.kind == "capability" - assert inst.name == "Knowledge Repository Service Conformance Statement" - assert inst.publisher == "HL7, Inc" - assert inst.rest[0].documentation == "RESTful Knowledge Repository Service" - assert inst.rest[0].mode == "server" - assert ( - inst.rest[0].operation[0].definition - == "OperationDefinition/Library-data-requirements" - ) - assert inst.rest[0].operation[0].name == "data-requirements" - assert inst.rest[0].resource[0].interaction[0].code == "read" - assert inst.rest[0].resource[0].interaction[0].documentation == ( - "Read allows clients to get the logical definitions of the " "libraries" - ) - assert inst.rest[0].resource[0].interaction[1].code == "search-type" - assert inst.rest[0].resource[0].interaction[1].documentation == ( - "Search allows clients to filter libraries based on a " - "provided search parameter" - ) - assert inst.rest[0].resource[0].profile == "StructureDefinition/Library" - assert ( - inst.rest[0].resource[0].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/Library-description" - ) - assert inst.rest[0].resource[0].searchParam[0].name == "description" - assert inst.rest[0].resource[0].searchParam[0].type == "string" - assert ( - inst.rest[0].resource[0].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/Library-identifier" - ) - assert inst.rest[0].resource[0].searchParam[1].name == "identifier" - assert inst.rest[0].resource[0].searchParam[1].type == "token" - assert ( - inst.rest[0].resource[0].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/Library-status" - ) - assert inst.rest[0].resource[0].searchParam[2].name == "status" - assert inst.rest[0].resource[0].searchParam[2].type == "token" - assert ( - inst.rest[0].resource[0].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/Library-title" - ) - assert inst.rest[0].resource[0].searchParam[3].name == "title" - assert inst.rest[0].resource[0].searchParam[3].type == "string" - assert ( - inst.rest[0].resource[0].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/Library-topic" - ) - assert inst.rest[0].resource[0].searchParam[4].name == "topic" - assert inst.rest[0].resource[0].searchParam[4].type == "token" - assert ( - inst.rest[0].resource[0].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/Library-version" - ) - assert inst.rest[0].resource[0].searchParam[5].name == "version" - assert inst.rest[0].resource[0].searchParam[5].type == "string" - assert ( - inst.rest[0].resource[0].searchParam[6].definition - == "http://hl7.org/fhir/SearchParameter/Library-composed-of" - ) - assert inst.rest[0].resource[0].searchParam[6].name == "composed-of" - assert inst.rest[0].resource[0].searchParam[6].type == "reference" - assert ( - inst.rest[0].resource[0].searchParam[7].definition - == "http://hl7.org/fhir/SearchParameter/Library-depends-on" - ) - assert inst.rest[0].resource[0].searchParam[7].name == "depends-on" - assert inst.rest[0].resource[0].searchParam[7].type == "reference" - assert ( - inst.rest[0].resource[0].searchParam[8].definition - == "http://hl7.org/fhir/SearchParameter/Library-derived-from" - ) - assert inst.rest[0].resource[0].searchParam[8].name == "derived-from" - assert inst.rest[0].resource[0].searchParam[8].type == "reference" - assert ( - inst.rest[0].resource[0].searchParam[9].definition - == "http://hl7.org/fhir/SearchParameter/Library-predecessor" - ) - assert inst.rest[0].resource[0].searchParam[9].name == "predecessor" - assert inst.rest[0].resource[0].searchParam[9].type == "reference" - assert inst.rest[0].resource[0].type == "Library" - assert inst.rest[0].resource[1].interaction[0].code == "read" - assert inst.rest[0].resource[1].interaction[0].documentation == ( - "Read allows clients to get the logical definitions of the " "plan definitions" - ) - assert inst.rest[0].resource[1].interaction[1].code == "search-type" - assert inst.rest[0].resource[1].interaction[1].documentation == ( - "Search allows clients to filter plan definitions based on a " - "provided search parameter" - ) - assert inst.rest[0].resource[1].profile == "StructureDefinition/PlanDefinition" - assert inst.rest[0].resource[1].searchParam[0].definition == ( - "http://hl7.org/fhir/SearchParameter/PlanDefinition-" "description" - ) - assert inst.rest[0].resource[1].searchParam[0].name == "description" - assert inst.rest[0].resource[1].searchParam[0].type == "string" - assert inst.rest[0].resource[1].searchParam[1].definition == ( - "http://hl7.org/fhir/SearchParameter/PlanDefinition-" "identifier" - ) - assert inst.rest[0].resource[1].searchParam[1].name == "identifier" - assert inst.rest[0].resource[1].searchParam[1].type == "token" - assert ( - inst.rest[0].resource[1].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/PlanDefinition-status" - ) - assert inst.rest[0].resource[1].searchParam[2].name == "status" - assert inst.rest[0].resource[1].searchParam[2].type == "token" - assert ( - inst.rest[0].resource[1].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/PlanDefinition-title" - ) - assert inst.rest[0].resource[1].searchParam[3].name == "title" - assert inst.rest[0].resource[1].searchParam[3].type == "string" - assert ( - inst.rest[0].resource[1].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/PlanDefinition-topic" - ) - assert inst.rest[0].resource[1].searchParam[4].name == "topic" - assert inst.rest[0].resource[1].searchParam[4].type == "token" - assert ( - inst.rest[0].resource[1].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/PlanDefinition-version" - ) - assert inst.rest[0].resource[1].searchParam[5].name == "version" - assert inst.rest[0].resource[1].searchParam[5].type == "string" - assert inst.rest[0].resource[1].searchParam[6].definition == ( - "http://hl7.org/fhir/SearchParameter/PlanDefinition-composed-" "of" - ) - assert inst.rest[0].resource[1].searchParam[6].name == "composed-of" - assert inst.rest[0].resource[1].searchParam[6].type == "reference" - assert inst.rest[0].resource[1].searchParam[7].definition == ( - "http://hl7.org/fhir/SearchParameter/PlanDefinition-depends-" "on" - ) - assert inst.rest[0].resource[1].searchParam[7].name == "depends-on" - assert inst.rest[0].resource[1].searchParam[7].type == "reference" - assert inst.rest[0].resource[1].searchParam[8].definition == ( - "http://hl7.org/fhir/SearchParameter/PlanDefinition-derived-" "from" - ) - assert inst.rest[0].resource[1].searchParam[8].name == "derived-from" - assert inst.rest[0].resource[1].searchParam[8].type == "reference" - assert inst.rest[0].resource[1].searchParam[9].definition == ( - "http://hl7.org/fhir/SearchParameter/PlanDefinition-" "predecessor" - ) - assert inst.rest[0].resource[1].searchParam[9].name == "predecessor" - assert inst.rest[0].resource[1].searchParam[9].type == "reference" - assert inst.rest[0].resource[1].type == "PlanDefinition" - assert inst.rest[0].resource[2].interaction[0].code == "read" - assert inst.rest[0].resource[2].interaction[0].documentation == ( - "Read allows clients to get the logical definitions of the " - "activity definitions" - ) - assert inst.rest[0].resource[2].interaction[1].code == "search-type" - assert inst.rest[0].resource[2].interaction[1].documentation == ( - "Search allows clients to filter activity definitions based " - "on a provided search parameter" - ) - assert inst.rest[0].resource[2].profile == "StructureDefinition/ActivityDefinition" - assert inst.rest[0].resource[2].searchParam[0].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "description" - ) - assert inst.rest[0].resource[2].searchParam[0].name == "description" - assert inst.rest[0].resource[2].searchParam[0].type == "string" - assert inst.rest[0].resource[2].searchParam[1].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "identifier" - ) - assert inst.rest[0].resource[2].searchParam[1].name == "identifier" - assert inst.rest[0].resource[2].searchParam[1].type == "token" - assert inst.rest[0].resource[2].searchParam[2].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "status" - ) - assert inst.rest[0].resource[2].searchParam[2].name == "status" - assert inst.rest[0].resource[2].searchParam[2].type == "token" - assert ( - inst.rest[0].resource[2].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/ActivityDefinition-title" - ) - assert inst.rest[0].resource[2].searchParam[3].name == "title" - assert inst.rest[0].resource[2].searchParam[3].type == "string" - assert ( - inst.rest[0].resource[2].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/ActivityDefinition-topic" - ) - assert inst.rest[0].resource[2].searchParam[4].name == "topic" - assert inst.rest[0].resource[2].searchParam[4].type == "token" - assert inst.rest[0].resource[2].searchParam[5].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "version" - ) - assert inst.rest[0].resource[2].searchParam[5].name == "version" - assert inst.rest[0].resource[2].searchParam[5].type == "string" - assert inst.rest[0].resource[2].searchParam[6].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "composed-of" - ) - assert inst.rest[0].resource[2].searchParam[6].name == "composed-of" - assert inst.rest[0].resource[2].searchParam[6].type == "reference" - assert inst.rest[0].resource[2].searchParam[7].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "depends-on" - ) - assert inst.rest[0].resource[2].searchParam[7].name == "depends-on" - assert inst.rest[0].resource[2].searchParam[7].type == "reference" - assert inst.rest[0].resource[2].searchParam[8].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "derived-from" - ) - assert inst.rest[0].resource[2].searchParam[8].name == "derived-from" - assert inst.rest[0].resource[2].searchParam[8].type == "reference" - assert inst.rest[0].resource[2].searchParam[9].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "predecessor" - ) - assert inst.rest[0].resource[2].searchParam[9].name == "predecessor" - assert inst.rest[0].resource[2].searchParam[9].type == "reference" - assert inst.rest[0].resource[2].type == "ActivityDefinition" - assert inst.rest[0].resource[3].interaction[0].code == "read" - assert inst.rest[0].resource[3].interaction[0].documentation == ( - "Read allows clients to get the logical definitions of the " "measures" - ) - assert inst.rest[0].resource[3].interaction[1].code == "search-type" - assert inst.rest[0].resource[3].interaction[1].documentation == ( - "Search allows clients to filter measures based on a provided" - " search parameter" - ) - assert inst.rest[0].resource[3].profile == "StructureDefinition/Measure" - assert ( - inst.rest[0].resource[3].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/Measure-description" - ) - assert inst.rest[0].resource[3].searchParam[0].name == "description" - assert inst.rest[0].resource[3].searchParam[0].type == "string" - assert ( - inst.rest[0].resource[3].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/Measure-identifier" - ) - assert inst.rest[0].resource[3].searchParam[1].name == "identifier" - assert inst.rest[0].resource[3].searchParam[1].type == "token" - assert ( - inst.rest[0].resource[3].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/Measure-status" - ) - assert inst.rest[0].resource[3].searchParam[2].name == "status" - assert inst.rest[0].resource[3].searchParam[2].type == "token" - assert ( - inst.rest[0].resource[3].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/Measure-title" - ) - assert inst.rest[0].resource[3].searchParam[3].name == "title" - assert inst.rest[0].resource[3].searchParam[3].type == "string" - assert ( - inst.rest[0].resource[3].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/Measure-topic" - ) - assert inst.rest[0].resource[3].searchParam[4].name == "topic" - assert inst.rest[0].resource[3].searchParam[4].type == "token" - assert ( - inst.rest[0].resource[3].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/Measure-version" - ) - assert inst.rest[0].resource[3].searchParam[5].name == "version" - assert inst.rest[0].resource[3].searchParam[5].type == "string" - assert ( - inst.rest[0].resource[3].searchParam[6].definition - == "http://hl7.org/fhir/SearchParameter/Measure-composed-of" - ) - assert inst.rest[0].resource[3].searchParam[6].name == "composed-of" - assert inst.rest[0].resource[3].searchParam[6].type == "reference" - assert ( - inst.rest[0].resource[3].searchParam[7].definition - == "http://hl7.org/fhir/SearchParameter/Measure-depends-on" - ) - assert inst.rest[0].resource[3].searchParam[7].name == "depends-on" - assert inst.rest[0].resource[3].searchParam[7].type == "reference" - assert ( - inst.rest[0].resource[3].searchParam[8].definition - == "http://hl7.org/fhir/SearchParameter/Measure-derived-from" - ) - assert inst.rest[0].resource[3].searchParam[8].name == "derived-from" - assert inst.rest[0].resource[3].searchParam[8].type == "reference" - assert ( - inst.rest[0].resource[3].searchParam[9].definition - == "http://hl7.org/fhir/SearchParameter/Measure-predecessor" - ) - assert inst.rest[0].resource[3].searchParam[9].name == "predecessor" - assert inst.rest[0].resource[3].searchParam[9].type == "reference" - assert inst.rest[0].resource[3].type == "Measure" - assert inst.rest[0].resource[4].interaction[0].code == "read" - assert inst.rest[0].resource[4].interaction[0].documentation == ( - "Read allows clients to get the logical definitions of the " "measures" - ) - assert inst.rest[0].resource[4].interaction[1].code == "search-type" - assert inst.rest[0].resource[4].interaction[1].documentation == ( - "Search allows clients to filter measures based on a provided" - " search parameter" - ) - assert inst.rest[0].resource[4].profile == "StructureDefinition/Questionnaire" - assert ( - inst.rest[0].resource[4].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/Questionnaire-code" - ) - assert inst.rest[0].resource[4].searchParam[0].name == "code" - assert inst.rest[0].resource[4].searchParam[0].type == "token" - assert ( - inst.rest[0].resource[4].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/Questionnaire-context" - ) - assert inst.rest[0].resource[4].searchParam[1].name == "context" - assert inst.rest[0].resource[4].searchParam[1].type == "token" - assert ( - inst.rest[0].resource[4].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/Questionnaire-date" - ) - assert inst.rest[0].resource[4].searchParam[2].name == "date" - assert inst.rest[0].resource[4].searchParam[2].type == "date" - assert ( - inst.rest[0].resource[4].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/Questionnaire-identifier" - ) - assert inst.rest[0].resource[4].searchParam[3].name == "identifier" - assert inst.rest[0].resource[4].searchParam[3].type == "token" - assert ( - inst.rest[0].resource[4].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/Questionnaire-publisher" - ) - assert inst.rest[0].resource[4].searchParam[4].name == "publisher" - assert inst.rest[0].resource[4].searchParam[4].type == "string" - assert ( - inst.rest[0].resource[4].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/Questionnaire-status" - ) - assert inst.rest[0].resource[4].searchParam[5].name == "status" - assert inst.rest[0].resource[4].searchParam[5].type == "token" - assert ( - inst.rest[0].resource[4].searchParam[6].definition - == "http://hl7.org/fhir/SearchParameter/Questionnaire-title" - ) - assert inst.rest[0].resource[4].searchParam[6].name == "title" - assert inst.rest[0].resource[4].searchParam[6].type == "string" - assert ( - inst.rest[0].resource[4].searchParam[7].definition - == "http://hl7.org/fhir/SearchParameter/Questionnaire-version" - ) - assert inst.rest[0].resource[4].searchParam[7].name == "version" - assert inst.rest[0].resource[4].searchParam[7].type == "string" - assert inst.rest[0].resource[4].type == "Questionnaire" - assert inst.rest[0].security.cors is True - assert inst.rest[0].security.service[0].coding[0].code == "Certificates" - assert inst.rest[0].security.service[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/restful-security-" "service" - ) - assert inst.software.name == "ACME Knowledge Repository Service" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/knowledge-repository" - - -def test_capabilitystatement_7(base_settings): - """No. 7 tests collection for CapabilityStatement. - Test File: capabilitystatement-knowledge-repository.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "capabilitystatement-knowledge-repository.json" - ) - inst = capabilitystatement.CapabilityStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CapabilityStatement" == inst.resource_type - - impl_capabilitystatement_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CapabilityStatement" == data["resourceType"] - - inst2 = capabilitystatement.CapabilityStatement(**data) - impl_capabilitystatement_7(inst2) - - -def impl_capabilitystatement_8(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.experimental is True - assert inst.fhirVersion == "4.0.1" - assert inst.format[0] == "xml" - assert inst.format[1] == "json" - assert inst.id == "base" - assert inst.kind == "capability" - assert inst.name == "Base FHIR Capability Statement (Full)" - assert inst.publisher == "FHIR Project Team" - assert inst.rest[0].documentation == "All the functionality defined in FHIR" - assert inst.rest[0].interaction[0].code == "transaction" - assert inst.rest[0].interaction[0].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].interaction[1].code == "batch" - assert inst.rest[0].interaction[1].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].interaction[2].code == "history-system" - assert inst.rest[0].interaction[2].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].interaction[3].code == "search-system" - assert inst.rest[0].interaction[3].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].mode == "server" - assert ( - inst.rest[0].operation[0].definition - == "http://hl7.org/fhir/OperationDefinition/resource-validate" - ) - assert inst.rest[0].operation[0].name == "validate" - assert ( - inst.rest[0].operation[1].definition - == "http://hl7.org/fhir/OperationDefinition/resource-meta" - ) - assert inst.rest[0].operation[1].name == "meta" - assert ( - inst.rest[0].operation[2].definition - == "http://hl7.org/fhir/OperationDefinition/resource-meta-add" - ) - assert inst.rest[0].operation[2].name == "meta-add" - assert ( - inst.rest[0].operation[3].definition - == "http://hl7.org/fhir/OperationDefinition/resource-meta-delete" - ) - assert inst.rest[0].operation[3].name == "meta-delete" - assert ( - inst.rest[0].operation[4].definition - == "http://hl7.org/fhir/OperationDefinition/resource-convert" - ) - assert inst.rest[0].operation[4].name == "convert" - assert ( - inst.rest[0].operation[5].definition - == "http://hl7.org/fhir/OperationDefinition/resource-graphql" - ) - assert inst.rest[0].operation[5].name == "graphql" - assert ( - inst.rest[0].operation[6].definition - == "http://hl7.org/fhir/OperationDefinition/resource-graph" - ) - assert inst.rest[0].operation[6].name == "graph" - assert inst.rest[0].operation[7].definition == ( - "http://hl7.org/fhir/OperationDefinition/activitydefinition-" "apply" - ) - assert inst.rest[0].operation[7].name == "apply" - assert inst.rest[0].operation[8].definition == ( - "http://hl7.org/fhir/OperationDefinition/activitydefinition-" - "data-requirements" - ) - assert inst.rest[0].operation[8].name == "data-requirements" - assert inst.rest[0].operation[9].definition == ( - "http://hl7.org/fhir/OperationDefinition/capabilitystatement-" "subset" - ) - assert inst.rest[0].operation[9].name == "subset" - assert inst.rest[0].resource[0].conditionalCreate is True - assert inst.rest[0].resource[0].conditionalDelete == "multiple" - assert inst.rest[0].resource[0].conditionalUpdate is True - assert inst.rest[0].resource[0].interaction[0].code == "read" - assert inst.rest[0].resource[0].interaction[0].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[0].interaction[1].code == "vread" - assert inst.rest[0].resource[0].interaction[1].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[0].interaction[2].code == "update" - assert inst.rest[0].resource[0].interaction[2].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[0].interaction[3].code == "delete" - assert inst.rest[0].resource[0].interaction[3].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[0].interaction[4].code == "history-instance" - assert inst.rest[0].resource[0].interaction[4].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[0].interaction[5].code == "history-type" - assert inst.rest[0].resource[0].interaction[5].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[0].interaction[6].code == "create" - assert inst.rest[0].resource[0].interaction[6].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[0].interaction[7].code == "search-type" - assert inst.rest[0].resource[0].interaction[7].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert ( - inst.rest[0].resource[0].profile - == "http://hl7.org/fhir/StructureDefinition/Account" - ) - assert inst.rest[0].resource[0].referencePolicy[0] == "literal" - assert inst.rest[0].resource[0].referencePolicy[1] == "logical" - assert inst.rest[0].resource[0].searchInclude[0] == "Account.owner" - assert inst.rest[0].resource[0].searchInclude[1] == "Account.subject" - assert inst.rest[0].resource[0].searchInclude[2] == "Account.patient" - assert ( - inst.rest[0].resource[0].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/Account-owner" - ) - assert ( - inst.rest[0].resource[0].searchParam[0].documentation - == "Entity managing the Account" - ) - assert inst.rest[0].resource[0].searchParam[0].name == "owner" - assert inst.rest[0].resource[0].searchParam[0].type == "reference" - assert ( - inst.rest[0].resource[0].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/Account-identifier" - ) - assert inst.rest[0].resource[0].searchParam[1].documentation == "Account number" - assert inst.rest[0].resource[0].searchParam[1].name == "identifier" - assert inst.rest[0].resource[0].searchParam[1].type == "token" - assert ( - inst.rest[0].resource[0].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/Account-period" - ) - assert inst.rest[0].resource[0].searchParam[2].documentation == "Transaction window" - assert inst.rest[0].resource[0].searchParam[2].name == "period" - assert inst.rest[0].resource[0].searchParam[2].type == "date" - assert ( - inst.rest[0].resource[0].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/Account-subject" - ) - assert ( - inst.rest[0].resource[0].searchParam[3].documentation - == "The entity that caused the expenses" - ) - assert inst.rest[0].resource[0].searchParam[3].name == "subject" - assert inst.rest[0].resource[0].searchParam[3].type == "reference" - assert ( - inst.rest[0].resource[0].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/Account-patient" - ) - assert ( - inst.rest[0].resource[0].searchParam[4].documentation - == "The entity that caused the expenses" - ) - assert inst.rest[0].resource[0].searchParam[4].name == "patient" - assert inst.rest[0].resource[0].searchParam[4].type == "reference" - assert ( - inst.rest[0].resource[0].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/Account-name" - ) - assert ( - inst.rest[0].resource[0].searchParam[5].documentation == "Human-readable label" - ) - assert inst.rest[0].resource[0].searchParam[5].name == "name" - assert inst.rest[0].resource[0].searchParam[5].type == "string" - assert ( - inst.rest[0].resource[0].searchParam[6].definition - == "http://hl7.org/fhir/SearchParameter/Account-type" - ) - assert ( - inst.rest[0].resource[0].searchParam[6].documentation - == "E.g. patient, expense, depreciation" - ) - assert inst.rest[0].resource[0].searchParam[6].name == "type" - assert inst.rest[0].resource[0].searchParam[6].type == "token" - assert ( - inst.rest[0].resource[0].searchParam[7].definition - == "http://hl7.org/fhir/SearchParameter/Account-status" - ) - assert ( - inst.rest[0].resource[0].searchParam[7].documentation - == "active | inactive | entered-in-error | on-hold | unknown" - ) - assert inst.rest[0].resource[0].searchParam[7].name == "status" - assert inst.rest[0].resource[0].searchParam[7].type == "token" - assert inst.rest[0].resource[0].searchRevInclude[0] == "ChargeItem.account" - assert inst.rest[0].resource[0].searchRevInclude[1] == "Encounter.account" - assert inst.rest[0].resource[0].searchRevInclude[2] == "Invoice.account" - assert inst.rest[0].resource[0].type == "Account" - assert inst.rest[0].resource[1].conditionalCreate is True - assert inst.rest[0].resource[1].conditionalDelete == "multiple" - assert inst.rest[0].resource[1].conditionalUpdate is True - assert inst.rest[0].resource[1].interaction[0].code == "read" - assert inst.rest[0].resource[1].interaction[0].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[1].interaction[1].code == "vread" - assert inst.rest[0].resource[1].interaction[1].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[1].interaction[2].code == "update" - assert inst.rest[0].resource[1].interaction[2].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[1].interaction[3].code == "delete" - assert inst.rest[0].resource[1].interaction[3].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[1].interaction[4].code == "history-instance" - assert inst.rest[0].resource[1].interaction[4].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[1].interaction[5].code == "history-type" - assert inst.rest[0].resource[1].interaction[5].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[1].interaction[6].code == "create" - assert inst.rest[0].resource[1].interaction[6].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[1].interaction[7].code == "search-type" - assert inst.rest[0].resource[1].interaction[7].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert ( - inst.rest[0].resource[1].profile - == "http://hl7.org/fhir/StructureDefinition/ActivityDefinition" - ) - assert inst.rest[0].resource[1].referencePolicy[0] == "literal" - assert inst.rest[0].resource[1].referencePolicy[1] == "logical" - assert inst.rest[0].resource[1].searchInclude[0] == "ActivityDefinition.successor" - assert ( - inst.rest[0].resource[1].searchInclude[1] == "ActivityDefinition.derived-from" - ) - assert inst.rest[0].resource[1].searchInclude[2] == "ActivityDefinition.predecessor" - assert inst.rest[0].resource[1].searchInclude[3] == "ActivityDefinition.composed-of" - assert inst.rest[0].resource[1].searchInclude[4] == "ActivityDefinition.depends-on" - assert ( - inst.rest[0].resource[1].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/ActivityDefinition-date" - ) - assert ( - inst.rest[0].resource[1].searchParam[0].documentation - == "The activity definition publication date" - ) - assert inst.rest[0].resource[1].searchParam[0].name == "date" - assert inst.rest[0].resource[1].searchParam[0].type == "date" - assert inst.rest[0].resource[1].searchParam[1].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "identifier" - ) - assert ( - inst.rest[0].resource[1].searchParam[1].documentation - == "External identifier for the activity definition" - ) - assert inst.rest[0].resource[1].searchParam[1].name == "identifier" - assert inst.rest[0].resource[1].searchParam[1].type == "token" - assert inst.rest[0].resource[1].searchParam[2].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "successor" - ) - assert ( - inst.rest[0].resource[1].searchParam[2].documentation - == "What resource is being referenced" - ) - assert inst.rest[0].resource[1].searchParam[2].name == "successor" - assert inst.rest[0].resource[1].searchParam[2].type == "reference" - assert inst.rest[0].resource[1].searchParam[3].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "context-type-value" - ) - assert inst.rest[0].resource[1].searchParam[3].documentation == ( - "A use context type and value assigned to the activity " "definition" - ) - assert inst.rest[0].resource[1].searchParam[3].name == "context-type-value" - assert inst.rest[0].resource[1].searchParam[3].type == "composite" - assert inst.rest[0].resource[1].searchParam[4].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "jurisdiction" - ) - assert ( - inst.rest[0].resource[1].searchParam[4].documentation - == "Intended jurisdiction for the activity definition" - ) - assert inst.rest[0].resource[1].searchParam[4].name == "jurisdiction" - assert inst.rest[0].resource[1].searchParam[4].type == "token" - assert inst.rest[0].resource[1].searchParam[5].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "description" - ) - assert ( - inst.rest[0].resource[1].searchParam[5].documentation - == "The description of the activity definition" - ) - assert inst.rest[0].resource[1].searchParam[5].name == "description" - assert inst.rest[0].resource[1].searchParam[5].type == "string" - assert inst.rest[0].resource[1].searchParam[6].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "derived-from" - ) - assert ( - inst.rest[0].resource[1].searchParam[6].documentation - == "What resource is being referenced" - ) - assert inst.rest[0].resource[1].searchParam[6].name == "derived-from" - assert inst.rest[0].resource[1].searchParam[6].type == "reference" - assert inst.rest[0].resource[1].searchParam[7].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "context-type" - ) - assert ( - inst.rest[0].resource[1].searchParam[7].documentation - == "A type of use context assigned to the activity definition" - ) - assert inst.rest[0].resource[1].searchParam[7].name == "context-type" - assert inst.rest[0].resource[1].searchParam[7].type == "token" - assert inst.rest[0].resource[1].searchParam[8].definition == ( - "http://hl7.org/fhir/SearchParameter/ActivityDefinition-" "predecessor" - ) - assert ( - inst.rest[0].resource[1].searchParam[8].documentation - == "What resource is being referenced" - ) - assert inst.rest[0].resource[1].searchParam[8].name == "predecessor" - assert inst.rest[0].resource[1].searchParam[8].type == "reference" - assert ( - inst.rest[0].resource[1].searchParam[9].definition - == "http://hl7.org/fhir/SearchParameter/ActivityDefinition-title" - ) - assert ( - inst.rest[0].resource[1].searchParam[9].documentation - == "The human-friendly name of the activity definition" - ) - assert inst.rest[0].resource[1].searchParam[9].name == "title" - assert inst.rest[0].resource[1].searchParam[9].type == "string" - assert ( - inst.rest[0].resource[1].searchRevInclude[0] - == "CarePlan.instantiates-canonical" - ) - assert ( - inst.rest[0].resource[1].searchRevInclude[1] - == "Communication.instantiates-canonical" - ) - assert ( - inst.rest[0].resource[1].searchRevInclude[2] - == "DeviceRequest.instantiates-canonical" - ) - assert ( - inst.rest[0].resource[1].searchRevInclude[3] - == "FamilyMemberHistory.instantiates-canonical" - ) - assert inst.rest[0].resource[1].searchRevInclude[4] == "MessageDefinition.parent" - assert ( - inst.rest[0].resource[1].searchRevInclude[5] - == "NutritionOrder.instantiates-canonical" - ) - assert inst.rest[0].resource[1].searchRevInclude[6] == "PlanDefinition.definition" - assert ( - inst.rest[0].resource[1].searchRevInclude[7] - == "Procedure.instantiates-canonical" - ) - assert ( - inst.rest[0].resource[1].searchRevInclude[8] - == "ServiceRequest.instantiates-canonical" - ) - assert inst.rest[0].resource[1].type == "ActivityDefinition" - assert inst.rest[0].resource[2].conditionalCreate is True - assert inst.rest[0].resource[2].conditionalDelete == "multiple" - assert inst.rest[0].resource[2].conditionalUpdate is True - assert inst.rest[0].resource[2].interaction[0].code == "read" - assert inst.rest[0].resource[2].interaction[0].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[2].interaction[1].code == "vread" - assert inst.rest[0].resource[2].interaction[1].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[2].interaction[2].code == "update" - assert inst.rest[0].resource[2].interaction[2].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[2].interaction[3].code == "delete" - assert inst.rest[0].resource[2].interaction[3].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[2].interaction[4].code == "history-instance" - assert inst.rest[0].resource[2].interaction[4].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[2].interaction[5].code == "history-type" - assert inst.rest[0].resource[2].interaction[5].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[2].interaction[6].code == "create" - assert inst.rest[0].resource[2].interaction[6].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[2].interaction[7].code == "search-type" - assert inst.rest[0].resource[2].interaction[7].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert ( - inst.rest[0].resource[2].profile - == "http://hl7.org/fhir/StructureDefinition/AdverseEvent" - ) - assert inst.rest[0].resource[2].referencePolicy[0] == "literal" - assert inst.rest[0].resource[2].referencePolicy[1] == "logical" - assert inst.rest[0].resource[2].searchInclude[0] == "AdverseEvent.recorder" - assert inst.rest[0].resource[2].searchInclude[1] == "AdverseEvent.study" - assert inst.rest[0].resource[2].searchInclude[2] == "AdverseEvent.subject" - assert ( - inst.rest[0].resource[2].searchInclude[3] == "AdverseEvent.resultingcondition" - ) - assert inst.rest[0].resource[2].searchInclude[4] == "AdverseEvent.substance" - assert inst.rest[0].resource[2].searchInclude[5] == "AdverseEvent.location" - assert ( - inst.rest[0].resource[2].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/AdverseEvent-date" - ) - assert ( - inst.rest[0].resource[2].searchParam[0].documentation - == "When the event occurred" - ) - assert inst.rest[0].resource[2].searchParam[0].name == "date" - assert inst.rest[0].resource[2].searchParam[0].type == "date" - assert ( - inst.rest[0].resource[2].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/AdverseEvent-severity" - ) - assert ( - inst.rest[0].resource[2].searchParam[1].documentation - == "mild | moderate | severe" - ) - assert inst.rest[0].resource[2].searchParam[1].name == "severity" - assert inst.rest[0].resource[2].searchParam[1].type == "token" - assert ( - inst.rest[0].resource[2].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/AdverseEvent-recorder" - ) - assert ( - inst.rest[0].resource[2].searchParam[2].documentation - == "Who recorded the adverse event" - ) - assert inst.rest[0].resource[2].searchParam[2].name == "recorder" - assert inst.rest[0].resource[2].searchParam[2].type == "reference" - assert ( - inst.rest[0].resource[2].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/AdverseEvent-study" - ) - assert inst.rest[0].resource[2].searchParam[3].documentation == "AdverseEvent.study" - assert inst.rest[0].resource[2].searchParam[3].name == "study" - assert inst.rest[0].resource[2].searchParam[3].type == "reference" - assert ( - inst.rest[0].resource[2].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/AdverseEvent-actuality" - ) - assert inst.rest[0].resource[2].searchParam[4].documentation == "actual | potential" - assert inst.rest[0].resource[2].searchParam[4].name == "actuality" - assert inst.rest[0].resource[2].searchParam[4].type == "token" - assert ( - inst.rest[0].resource[2].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/AdverseEvent-seriousness" - ) - assert ( - inst.rest[0].resource[2].searchParam[5].documentation - == "Seriousness of the event" - ) - assert inst.rest[0].resource[2].searchParam[5].name == "seriousness" - assert inst.rest[0].resource[2].searchParam[5].type == "token" - assert ( - inst.rest[0].resource[2].searchParam[6].definition - == "http://hl7.org/fhir/SearchParameter/AdverseEvent-subject" - ) - assert ( - inst.rest[0].resource[2].searchParam[6].documentation - == "Subject impacted by event" - ) - assert inst.rest[0].resource[2].searchParam[6].name == "subject" - assert inst.rest[0].resource[2].searchParam[6].type == "reference" - assert inst.rest[0].resource[2].searchParam[7].definition == ( - "http://hl7.org/fhir/SearchParameter/AdverseEvent-" "resultingcondition" - ) - assert ( - inst.rest[0].resource[2].searchParam[7].documentation - == "Effect on the subject due to this event" - ) - assert inst.rest[0].resource[2].searchParam[7].name == "resultingcondition" - assert inst.rest[0].resource[2].searchParam[7].type == "reference" - assert ( - inst.rest[0].resource[2].searchParam[8].definition - == "http://hl7.org/fhir/SearchParameter/AdverseEvent-substance" - ) - assert ( - inst.rest[0].resource[2].searchParam[8].documentation - == "Refers to the specific entity that caused the adverse event" - ) - assert inst.rest[0].resource[2].searchParam[8].name == "substance" - assert inst.rest[0].resource[2].searchParam[8].type == "reference" - assert ( - inst.rest[0].resource[2].searchParam[9].definition - == "http://hl7.org/fhir/SearchParameter/AdverseEvent-location" - ) - assert ( - inst.rest[0].resource[2].searchParam[9].documentation - == "Location where adverse event occurred" - ) - assert inst.rest[0].resource[2].searchParam[9].name == "location" - assert inst.rest[0].resource[2].searchParam[9].type == "reference" - assert inst.rest[0].resource[2].type == "AdverseEvent" - assert inst.rest[0].resource[3].conditionalCreate is True - assert inst.rest[0].resource[3].conditionalDelete == "multiple" - assert inst.rest[0].resource[3].conditionalUpdate is True - assert inst.rest[0].resource[3].interaction[0].code == "read" - assert inst.rest[0].resource[3].interaction[0].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[3].interaction[1].code == "vread" - assert inst.rest[0].resource[3].interaction[1].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[3].interaction[2].code == "update" - assert inst.rest[0].resource[3].interaction[2].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[3].interaction[3].code == "delete" - assert inst.rest[0].resource[3].interaction[3].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[3].interaction[4].code == "history-instance" - assert inst.rest[0].resource[3].interaction[4].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[3].interaction[5].code == "history-type" - assert inst.rest[0].resource[3].interaction[5].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[3].interaction[6].code == "create" - assert inst.rest[0].resource[3].interaction[6].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[3].interaction[7].code == "search-type" - assert inst.rest[0].resource[3].interaction[7].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert ( - inst.rest[0].resource[3].profile - == "http://hl7.org/fhir/StructureDefinition/AllergyIntolerance" - ) - assert inst.rest[0].resource[3].referencePolicy[0] == "literal" - assert inst.rest[0].resource[3].referencePolicy[1] == "logical" - assert inst.rest[0].resource[3].searchInclude[0] == "AllergyIntolerance.recorder" - assert inst.rest[0].resource[3].searchInclude[1] == "AllergyIntolerance.asserter" - assert inst.rest[0].resource[3].searchInclude[2] == "AllergyIntolerance.patient" - assert inst.rest[0].resource[3].searchParam[0].definition == ( - "http://hl7.org/fhir/SearchParameter/AllergyIntolerance-" "severity" - ) - assert ( - inst.rest[0].resource[3].searchParam[0].documentation - == "mild | moderate | severe (of event as a whole)" - ) - assert inst.rest[0].resource[3].searchParam[0].name == "severity" - assert inst.rest[0].resource[3].searchParam[0].type == "token" - assert ( - inst.rest[0].resource[3].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/clinical-date" - ) - assert ( - inst.rest[0].resource[3].searchParam[1].documentation - == "Date first version of the resource instance was recorded" - ) - assert inst.rest[0].resource[3].searchParam[1].name == "date" - assert inst.rest[0].resource[3].searchParam[1].type == "date" - assert ( - inst.rest[0].resource[3].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/clinical-identifier" - ) - assert ( - inst.rest[0].resource[3].searchParam[2].documentation - == "External ids for this item" - ) - assert inst.rest[0].resource[3].searchParam[2].name == "identifier" - assert inst.rest[0].resource[3].searchParam[2].type == "token" - assert inst.rest[0].resource[3].searchParam[3].definition == ( - "http://hl7.org/fhir/SearchParameter/AllergyIntolerance-" "manifestation" - ) - assert ( - inst.rest[0].resource[3].searchParam[3].documentation - == "Clinical symptoms/signs associated with the Event" - ) - assert inst.rest[0].resource[3].searchParam[3].name == "manifestation" - assert inst.rest[0].resource[3].searchParam[3].type == "token" - assert inst.rest[0].resource[3].searchParam[4].definition == ( - "http://hl7.org/fhir/SearchParameter/AllergyIntolerance-" "recorder" - ) - assert ( - inst.rest[0].resource[3].searchParam[4].documentation - == "Who recorded the sensitivity" - ) - assert inst.rest[0].resource[3].searchParam[4].name == "recorder" - assert inst.rest[0].resource[3].searchParam[4].type == "reference" - assert ( - inst.rest[0].resource[3].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/clinical-code" - ) - assert ( - inst.rest[0].resource[3].searchParam[5].documentation - == "Code that identifies the allergy or intolerance" - ) - assert inst.rest[0].resource[3].searchParam[5].name == "code" - assert inst.rest[0].resource[3].searchParam[5].type == "token" - assert inst.rest[0].resource[3].searchParam[6].definition == ( - "http://hl7.org/fhir/SearchParameter/AllergyIntolerance-" "verification-status" - ) - assert ( - inst.rest[0].resource[3].searchParam[6].documentation - == "unconfirmed | confirmed | refuted | entered-in-error" - ) - assert inst.rest[0].resource[3].searchParam[6].name == "verification-status" - assert inst.rest[0].resource[3].searchParam[6].type == "token" - assert inst.rest[0].resource[3].searchParam[7].definition == ( - "http://hl7.org/fhir/SearchParameter/AllergyIntolerance-" "criticality" - ) - assert ( - inst.rest[0].resource[3].searchParam[7].documentation - == "low | high | unable-to-assess" - ) - assert inst.rest[0].resource[3].searchParam[7].name == "criticality" - assert inst.rest[0].resource[3].searchParam[7].type == "token" - assert inst.rest[0].resource[3].searchParam[8].definition == ( - "http://hl7.org/fhir/SearchParameter/AllergyIntolerance-" "clinical-status" - ) - assert ( - inst.rest[0].resource[3].searchParam[8].documentation - == "active | inactive | resolved" - ) - assert inst.rest[0].resource[3].searchParam[8].name == "clinical-status" - assert inst.rest[0].resource[3].searchParam[8].type == "token" - assert ( - inst.rest[0].resource[3].searchParam[9].definition - == "http://hl7.org/fhir/SearchParameter/clinical-type" - ) - assert ( - inst.rest[0].resource[3].searchParam[9].documentation - == "allergy | intolerance - Underlying mechanism (if known)" - ) - assert inst.rest[0].resource[3].searchParam[9].name == "type" - assert inst.rest[0].resource[3].searchParam[9].type == "token" - assert inst.rest[0].resource[3].searchRevInclude[0] == "ClinicalImpression.problem" - assert inst.rest[0].resource[3].type == "AllergyIntolerance" - assert inst.rest[0].resource[4].conditionalCreate is True - assert inst.rest[0].resource[4].conditionalDelete == "multiple" - assert inst.rest[0].resource[4].conditionalUpdate is True - assert inst.rest[0].resource[4].interaction[0].code == "read" - assert inst.rest[0].resource[4].interaction[0].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[4].interaction[1].code == "vread" - assert inst.rest[0].resource[4].interaction[1].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[4].interaction[2].code == "update" - assert inst.rest[0].resource[4].interaction[2].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[4].interaction[3].code == "delete" - assert inst.rest[0].resource[4].interaction[3].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[4].interaction[4].code == "history-instance" - assert inst.rest[0].resource[4].interaction[4].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[4].interaction[5].code == "history-type" - assert inst.rest[0].resource[4].interaction[5].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[4].interaction[6].code == "create" - assert inst.rest[0].resource[4].interaction[6].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[4].interaction[7].code == "search-type" - assert inst.rest[0].resource[4].interaction[7].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert ( - inst.rest[0].resource[4].profile - == "http://hl7.org/fhir/StructureDefinition/Appointment" - ) - assert inst.rest[0].resource[4].referencePolicy[0] == "literal" - assert inst.rest[0].resource[4].referencePolicy[1] == "logical" - assert inst.rest[0].resource[4].searchInclude[0] == "Appointment.practitioner" - assert inst.rest[0].resource[4].searchInclude[1] == "Appointment.slot" - assert inst.rest[0].resource[4].searchInclude[2] == "Appointment.actor" - assert inst.rest[0].resource[4].searchInclude[3] == "Appointment.based-on" - assert inst.rest[0].resource[4].searchInclude[4] == "Appointment.patient" - assert inst.rest[0].resource[4].searchInclude[5] == "Appointment.reason-reference" - assert inst.rest[0].resource[4].searchInclude[6] == "Appointment.supporting-info" - assert inst.rest[0].resource[4].searchInclude[7] == "Appointment.location" - assert ( - inst.rest[0].resource[4].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/Appointment-date" - ) - assert ( - inst.rest[0].resource[4].searchParam[0].documentation - == "Appointment date/time." - ) - assert inst.rest[0].resource[4].searchParam[0].name == "date" - assert inst.rest[0].resource[4].searchParam[0].type == "date" - assert ( - inst.rest[0].resource[4].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/Appointment-identifier" - ) - assert ( - inst.rest[0].resource[4].searchParam[1].documentation - == "An Identifier of the Appointment" - ) - assert inst.rest[0].resource[4].searchParam[1].name == "identifier" - assert inst.rest[0].resource[4].searchParam[1].type == "token" - assert ( - inst.rest[0].resource[4].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/Appointment-specialty" - ) - assert inst.rest[0].resource[4].searchParam[2].documentation == ( - "The specialty of a practitioner that would be required to " - "perform the service requested in this appointment" - ) - assert inst.rest[0].resource[4].searchParam[2].name == "specialty" - assert inst.rest[0].resource[4].searchParam[2].type == "token" - assert inst.rest[0].resource[4].searchParam[3].definition == ( - "http://hl7.org/fhir/SearchParameter/Appointment-service-" "category" - ) - assert inst.rest[0].resource[4].searchParam[3].documentation == ( - "A broad categorization of the service that is to be " - "performed during this appointment" - ) - assert inst.rest[0].resource[4].searchParam[3].name == "service-category" - assert inst.rest[0].resource[4].searchParam[3].type == "token" - assert ( - inst.rest[0].resource[4].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/Appointment-practitioner" - ) - assert inst.rest[0].resource[4].searchParam[4].documentation == ( - "One of the individuals of the appointment is this " "practitioner" - ) - assert inst.rest[0].resource[4].searchParam[4].name == "practitioner" - assert inst.rest[0].resource[4].searchParam[4].type == "reference" - assert ( - inst.rest[0].resource[4].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/Appointment-part-status" - ) - assert inst.rest[0].resource[4].searchParam[5].documentation == ( - "The Participation status of the subject, or other " - "participant on the appointment. Can be used to locate " - "participants that have not responded to meeting requests." - ) - assert inst.rest[0].resource[4].searchParam[5].name == "part-status" - assert inst.rest[0].resource[4].searchParam[5].type == "token" - assert inst.rest[0].resource[4].searchParam[6].definition == ( - "http://hl7.org/fhir/SearchParameter/Appointment-appointment-" "type" - ) - assert inst.rest[0].resource[4].searchParam[6].documentation == ( - "The style of appointment or patient that has been booked in " - "the slot (not service type)" - ) - assert inst.rest[0].resource[4].searchParam[6].name == "appointment-type" - assert inst.rest[0].resource[4].searchParam[6].type == "token" - assert ( - inst.rest[0].resource[4].searchParam[7].definition - == "http://hl7.org/fhir/SearchParameter/Appointment-service-type" - ) - assert inst.rest[0].resource[4].searchParam[7].documentation == ( - "The specific service that is to be performed during this " "appointment" - ) - assert inst.rest[0].resource[4].searchParam[7].name == "service-type" - assert inst.rest[0].resource[4].searchParam[7].type == "token" - assert ( - inst.rest[0].resource[4].searchParam[8].definition - == "http://hl7.org/fhir/SearchParameter/Appointment-slot" - ) - assert ( - inst.rest[0].resource[4].searchParam[8].documentation - == "The slots that this appointment is filling" - ) - assert inst.rest[0].resource[4].searchParam[8].name == "slot" - assert inst.rest[0].resource[4].searchParam[8].type == "reference" - assert ( - inst.rest[0].resource[4].searchParam[9].definition - == "http://hl7.org/fhir/SearchParameter/Appointment-reason-code" - ) - assert ( - inst.rest[0].resource[4].searchParam[9].documentation - == "Coded reason this appointment is scheduled" - ) - assert inst.rest[0].resource[4].searchParam[9].name == "reason-code" - assert inst.rest[0].resource[4].searchParam[9].type == "token" - assert ( - inst.rest[0].resource[4].searchRevInclude[0] - == "AppointmentResponse.appointment" - ) - assert inst.rest[0].resource[4].searchRevInclude[1] == "CarePlan.activity-reference" - assert inst.rest[0].resource[4].searchRevInclude[2] == "Encounter.appointment" - assert inst.rest[0].resource[4].searchRevInclude[3] == "ImagingStudy.basedon" - assert inst.rest[0].resource[4].type == "Appointment" - assert inst.rest[0].resource[5].conditionalCreate is True - assert inst.rest[0].resource[5].conditionalDelete == "multiple" - assert inst.rest[0].resource[5].conditionalUpdate is True - assert inst.rest[0].resource[5].interaction[0].code == "read" - assert inst.rest[0].resource[5].interaction[0].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[5].interaction[1].code == "vread" - assert inst.rest[0].resource[5].interaction[1].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[5].interaction[2].code == "update" - assert inst.rest[0].resource[5].interaction[2].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[5].interaction[3].code == "delete" - assert inst.rest[0].resource[5].interaction[3].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[5].interaction[4].code == "history-instance" - assert inst.rest[0].resource[5].interaction[4].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[5].interaction[5].code == "history-type" - assert inst.rest[0].resource[5].interaction[5].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[5].interaction[6].code == "create" - assert inst.rest[0].resource[5].interaction[6].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[5].interaction[7].code == "search-type" - assert inst.rest[0].resource[5].interaction[7].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert ( - inst.rest[0].resource[5].profile - == "http://hl7.org/fhir/StructureDefinition/AppointmentResponse" - ) - assert inst.rest[0].resource[5].referencePolicy[0] == "literal" - assert inst.rest[0].resource[5].referencePolicy[1] == "logical" - assert inst.rest[0].resource[5].searchInclude[0] == "AppointmentResponse.actor" - assert ( - inst.rest[0].resource[5].searchInclude[1] == "AppointmentResponse.practitioner" - ) - assert inst.rest[0].resource[5].searchInclude[2] == "AppointmentResponse.patient" - assert ( - inst.rest[0].resource[5].searchInclude[3] == "AppointmentResponse.appointment" - ) - assert inst.rest[0].resource[5].searchInclude[4] == "AppointmentResponse.location" - assert inst.rest[0].resource[5].searchParam[0].definition == ( - "http://hl7.org/fhir/SearchParameter/AppointmentResponse-" "actor" - ) - assert inst.rest[0].resource[5].searchParam[0].documentation == ( - "The Person, Location/HealthcareService or Device that this " - "appointment response replies for" - ) - assert inst.rest[0].resource[5].searchParam[0].name == "actor" - assert inst.rest[0].resource[5].searchParam[0].type == "reference" - assert inst.rest[0].resource[5].searchParam[1].definition == ( - "http://hl7.org/fhir/SearchParameter/AppointmentResponse-" "identifier" - ) - assert ( - inst.rest[0].resource[5].searchParam[1].documentation - == "An Identifier in this appointment response" - ) - assert inst.rest[0].resource[5].searchParam[1].name == "identifier" - assert inst.rest[0].resource[5].searchParam[1].type == "token" - assert inst.rest[0].resource[5].searchParam[2].definition == ( - "http://hl7.org/fhir/SearchParameter/AppointmentResponse-" "practitioner" - ) - assert ( - inst.rest[0].resource[5].searchParam[2].documentation - == "This Response is for this Practitioner" - ) - assert inst.rest[0].resource[5].searchParam[2].name == "practitioner" - assert inst.rest[0].resource[5].searchParam[2].type == "reference" - assert inst.rest[0].resource[5].searchParam[3].definition == ( - "http://hl7.org/fhir/SearchParameter/AppointmentResponse-" "part-status" - ) - assert ( - inst.rest[0].resource[5].searchParam[3].documentation - == "The participants acceptance status for this appointment" - ) - assert inst.rest[0].resource[5].searchParam[3].name == "part-status" - assert inst.rest[0].resource[5].searchParam[3].type == "token" - assert inst.rest[0].resource[5].searchParam[4].definition == ( - "http://hl7.org/fhir/SearchParameter/AppointmentResponse-" "patient" - ) - assert ( - inst.rest[0].resource[5].searchParam[4].documentation - == "This Response is for this Patient" - ) - assert inst.rest[0].resource[5].searchParam[4].name == "patient" - assert inst.rest[0].resource[5].searchParam[4].type == "reference" - assert inst.rest[0].resource[5].searchParam[5].definition == ( - "http://hl7.org/fhir/SearchParameter/AppointmentResponse-" "appointment" - ) - assert ( - inst.rest[0].resource[5].searchParam[5].documentation - == "The appointment that the response is attached to" - ) - assert inst.rest[0].resource[5].searchParam[5].name == "appointment" - assert inst.rest[0].resource[5].searchParam[5].type == "reference" - assert inst.rest[0].resource[5].searchParam[6].definition == ( - "http://hl7.org/fhir/SearchParameter/AppointmentResponse-" "location" - ) - assert ( - inst.rest[0].resource[5].searchParam[6].documentation - == "This Response is for this Location" - ) - assert inst.rest[0].resource[5].searchParam[6].name == "location" - assert inst.rest[0].resource[5].searchParam[6].type == "reference" - assert inst.rest[0].resource[5].searchRevInclude[0] == "ImagingStudy.basedon" - assert inst.rest[0].resource[5].type == "AppointmentResponse" - assert inst.rest[0].resource[6].conditionalCreate is True - assert inst.rest[0].resource[6].conditionalDelete == "multiple" - assert inst.rest[0].resource[6].conditionalUpdate is True - assert inst.rest[0].resource[6].interaction[0].code == "read" - assert inst.rest[0].resource[6].interaction[0].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[6].interaction[1].code == "vread" - assert inst.rest[0].resource[6].interaction[1].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[6].interaction[2].code == "update" - assert inst.rest[0].resource[6].interaction[2].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[6].interaction[3].code == "delete" - assert inst.rest[0].resource[6].interaction[3].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[6].interaction[4].code == "history-instance" - assert inst.rest[0].resource[6].interaction[4].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[6].interaction[5].code == "history-type" - assert inst.rest[0].resource[6].interaction[5].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[6].interaction[6].code == "create" - assert inst.rest[0].resource[6].interaction[6].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[6].interaction[7].code == "search-type" - assert inst.rest[0].resource[6].interaction[7].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert ( - inst.rest[0].resource[6].profile - == "http://hl7.org/fhir/StructureDefinition/AuditEvent" - ) - assert inst.rest[0].resource[6].referencePolicy[0] == "literal" - assert inst.rest[0].resource[6].referencePolicy[1] == "logical" - assert inst.rest[0].resource[6].searchInclude[0] == "AuditEvent.agent" - assert inst.rest[0].resource[6].searchInclude[1] == "AuditEvent.source" - assert inst.rest[0].resource[6].searchInclude[2] == "AuditEvent.patient" - assert inst.rest[0].resource[6].searchInclude[3] == "AuditEvent.entity" - assert ( - inst.rest[0].resource[6].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/AuditEvent-date" - ) - assert ( - inst.rest[0].resource[6].searchParam[0].documentation - == "Time when the event was recorded" - ) - assert inst.rest[0].resource[6].searchParam[0].name == "date" - assert inst.rest[0].resource[6].searchParam[0].type == "date" - assert ( - inst.rest[0].resource[6].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/AuditEvent-entity-type" - ) - assert ( - inst.rest[0].resource[6].searchParam[1].documentation - == "Type of entity involved" - ) - assert inst.rest[0].resource[6].searchParam[1].name == "entity-type" - assert inst.rest[0].resource[6].searchParam[1].type == "token" - assert ( - inst.rest[0].resource[6].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/AuditEvent-agent" - ) - assert inst.rest[0].resource[6].searchParam[2].documentation == "Identifier of who" - assert inst.rest[0].resource[6].searchParam[2].name == "agent" - assert inst.rest[0].resource[6].searchParam[2].type == "reference" - assert ( - inst.rest[0].resource[6].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/AuditEvent-address" - ) - assert ( - inst.rest[0].resource[6].searchParam[3].documentation - == "Identifier for the network access point of the user device" - ) - assert inst.rest[0].resource[6].searchParam[3].name == "address" - assert inst.rest[0].resource[6].searchParam[3].type == "string" - assert ( - inst.rest[0].resource[6].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/AuditEvent-entity-role" - ) - assert ( - inst.rest[0].resource[6].searchParam[4].documentation - == "What role the entity played" - ) - assert inst.rest[0].resource[6].searchParam[4].name == "entity-role" - assert inst.rest[0].resource[6].searchParam[4].type == "token" - assert ( - inst.rest[0].resource[6].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/AuditEvent-source" - ) - assert ( - inst.rest[0].resource[6].searchParam[5].documentation - == "The identity of source detecting the event" - ) - assert inst.rest[0].resource[6].searchParam[5].name == "source" - assert inst.rest[0].resource[6].searchParam[5].type == "reference" - assert ( - inst.rest[0].resource[6].searchParam[6].definition - == "http://hl7.org/fhir/SearchParameter/AuditEvent-type" - ) - assert ( - inst.rest[0].resource[6].searchParam[6].documentation - == "Type/identifier of event" - ) - assert inst.rest[0].resource[6].searchParam[6].name == "type" - assert inst.rest[0].resource[6].searchParam[6].type == "token" - assert ( - inst.rest[0].resource[6].searchParam[7].definition - == "http://hl7.org/fhir/SearchParameter/AuditEvent-altid" - ) - assert ( - inst.rest[0].resource[6].searchParam[7].documentation - == "Alternative User identity" - ) - assert inst.rest[0].resource[6].searchParam[7].name == "altid" - assert inst.rest[0].resource[6].searchParam[7].type == "token" - assert ( - inst.rest[0].resource[6].searchParam[8].definition - == "http://hl7.org/fhir/SearchParameter/AuditEvent-site" - ) - assert ( - inst.rest[0].resource[6].searchParam[8].documentation - == "Logical source location within the enterprise" - ) - assert inst.rest[0].resource[6].searchParam[8].name == "site" - assert inst.rest[0].resource[6].searchParam[8].type == "token" - assert ( - inst.rest[0].resource[6].searchParam[9].definition - == "http://hl7.org/fhir/SearchParameter/AuditEvent-agent-name" - ) - assert ( - inst.rest[0].resource[6].searchParam[9].documentation - == "Human friendly name for the agent" - ) - assert inst.rest[0].resource[6].searchParam[9].name == "agent-name" - assert inst.rest[0].resource[6].searchParam[9].type == "string" - assert inst.rest[0].resource[6].type == "AuditEvent" - assert inst.rest[0].resource[7].conditionalCreate is True - assert inst.rest[0].resource[7].conditionalDelete == "multiple" - assert inst.rest[0].resource[7].conditionalUpdate is True - assert inst.rest[0].resource[7].interaction[0].code == "read" - assert inst.rest[0].resource[7].interaction[0].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[7].interaction[1].code == "vread" - assert inst.rest[0].resource[7].interaction[1].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[7].interaction[2].code == "update" - assert inst.rest[0].resource[7].interaction[2].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[7].interaction[3].code == "delete" - assert inst.rest[0].resource[7].interaction[3].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[7].interaction[4].code == "history-instance" - assert inst.rest[0].resource[7].interaction[4].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[7].interaction[5].code == "history-type" - assert inst.rest[0].resource[7].interaction[5].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[7].interaction[6].code == "create" - assert inst.rest[0].resource[7].interaction[6].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[7].interaction[7].code == "search-type" - assert inst.rest[0].resource[7].interaction[7].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert ( - inst.rest[0].resource[7].profile - == "http://hl7.org/fhir/StructureDefinition/Basic" - ) - assert inst.rest[0].resource[7].referencePolicy[0] == "literal" - assert inst.rest[0].resource[7].referencePolicy[1] == "logical" - assert inst.rest[0].resource[7].searchInclude[0] == "Basic.subject" - assert inst.rest[0].resource[7].searchInclude[1] == "Basic.patient" - assert inst.rest[0].resource[7].searchInclude[2] == "Basic.author" - assert ( - inst.rest[0].resource[7].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/Basic-identifier" - ) - assert ( - inst.rest[0].resource[7].searchParam[0].documentation == "Business identifier" - ) - assert inst.rest[0].resource[7].searchParam[0].name == "identifier" - assert inst.rest[0].resource[7].searchParam[0].type == "token" - assert ( - inst.rest[0].resource[7].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/Basic-code" - ) - assert inst.rest[0].resource[7].searchParam[1].documentation == "Kind of Resource" - assert inst.rest[0].resource[7].searchParam[1].name == "code" - assert inst.rest[0].resource[7].searchParam[1].type == "token" - assert ( - inst.rest[0].resource[7].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/Basic-subject" - ) - assert ( - inst.rest[0].resource[7].searchParam[2].documentation - == "Identifies the focus of this resource" - ) - assert inst.rest[0].resource[7].searchParam[2].name == "subject" - assert inst.rest[0].resource[7].searchParam[2].type == "reference" - assert ( - inst.rest[0].resource[7].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/Basic-created" - ) - assert inst.rest[0].resource[7].searchParam[3].documentation == "When created" - assert inst.rest[0].resource[7].searchParam[3].name == "created" - assert inst.rest[0].resource[7].searchParam[3].type == "date" - assert ( - inst.rest[0].resource[7].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/Basic-patient" - ) - assert ( - inst.rest[0].resource[7].searchParam[4].documentation - == "Identifies the focus of this resource" - ) - assert inst.rest[0].resource[7].searchParam[4].name == "patient" - assert inst.rest[0].resource[7].searchParam[4].type == "reference" - assert ( - inst.rest[0].resource[7].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/Basic-author" - ) - assert inst.rest[0].resource[7].searchParam[5].documentation == "Who created" - assert inst.rest[0].resource[7].searchParam[5].name == "author" - assert inst.rest[0].resource[7].searchParam[5].type == "reference" - assert inst.rest[0].resource[7].type == "Basic" - assert inst.rest[0].resource[8].conditionalCreate is True - assert inst.rest[0].resource[8].conditionalDelete == "multiple" - assert inst.rest[0].resource[8].conditionalUpdate is True - assert inst.rest[0].resource[8].interaction[0].code == "read" - assert inst.rest[0].resource[8].interaction[0].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[8].interaction[1].code == "vread" - assert inst.rest[0].resource[8].interaction[1].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[8].interaction[2].code == "update" - assert inst.rest[0].resource[8].interaction[2].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[8].interaction[3].code == "delete" - assert inst.rest[0].resource[8].interaction[3].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[8].interaction[4].code == "history-instance" - assert inst.rest[0].resource[8].interaction[4].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[8].interaction[5].code == "history-type" - assert inst.rest[0].resource[8].interaction[5].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[8].interaction[6].code == "create" - assert inst.rest[0].resource[8].interaction[6].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[8].interaction[7].code == "search-type" - assert inst.rest[0].resource[8].interaction[7].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert ( - inst.rest[0].resource[8].profile - == "http://hl7.org/fhir/StructureDefinition/Binary" - ) - assert inst.rest[0].resource[8].referencePolicy[0] == "literal" - assert inst.rest[0].resource[8].referencePolicy[1] == "logical" - assert inst.rest[0].resource[8].type == "Binary" - assert inst.rest[0].resource[9].conditionalCreate is True - assert inst.rest[0].resource[9].conditionalDelete == "multiple" - assert inst.rest[0].resource[9].conditionalUpdate is True - assert inst.rest[0].resource[9].interaction[0].code == "read" - assert inst.rest[0].resource[9].interaction[0].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[9].interaction[1].code == "vread" - assert inst.rest[0].resource[9].interaction[1].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[9].interaction[2].code == "update" - assert inst.rest[0].resource[9].interaction[2].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[9].interaction[3].code == "delete" - assert inst.rest[0].resource[9].interaction[3].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[9].interaction[4].code == "history-instance" - assert inst.rest[0].resource[9].interaction[4].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[9].interaction[5].code == "history-type" - assert inst.rest[0].resource[9].interaction[5].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[9].interaction[6].code == "create" - assert inst.rest[0].resource[9].interaction[6].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[9].interaction[7].code == "search-type" - assert inst.rest[0].resource[9].interaction[7].documentation == ( - "Implemented per the specification (or Insert other doco " "here)" - ) - assert inst.rest[0].resource[9].profile == ( - "http://hl7.org/fhir/StructureDefinition/BiologicallyDerivedP" "roduct" - ) - assert inst.rest[0].resource[9].referencePolicy[0] == "literal" - assert inst.rest[0].resource[9].referencePolicy[1] == "logical" - assert inst.rest[0].resource[9].type == "BiologicallyDerivedProduct" - assert ( - inst.rest[0].searchParam[0].definition - == "http://hl7.org/fhir/SearchParameter/DomainResource-text" - ) - assert ( - inst.rest[0].searchParam[0].documentation - == "Search on the narrative of the resource" - ) - assert inst.rest[0].searchParam[0].name == "_text" - assert inst.rest[0].searchParam[0].type == "string" - assert ( - inst.rest[0].searchParam[1].definition - == "http://hl7.org/fhir/SearchParameter/id" - ) - assert inst.rest[0].searchParam[1].documentation == "some doco" - assert inst.rest[0].searchParam[1].name == "something" - assert inst.rest[0].searchParam[1].type == "string" - assert ( - inst.rest[0].searchParam[2].definition - == "http://hl7.org/fhir/SearchParameter/Resource-list" - ) - assert inst.rest[0].searchParam[2].documentation == ( - "Retrieval of resources that are referenced by a List " "resource" - ) - assert inst.rest[0].searchParam[2].name == "_list" - assert inst.rest[0].searchParam[2].type == "token" - assert ( - inst.rest[0].searchParam[3].definition - == "http://hl7.org/fhir/SearchParameter/Resource-has" - ) - assert ( - inst.rest[0].searchParam[3].documentation - == "Provides support for reverse chaining" - ) - assert inst.rest[0].searchParam[3].name == "_has" - assert inst.rest[0].searchParam[3].type == "composite" - assert ( - inst.rest[0].searchParam[4].definition - == "http://hl7.org/fhir/SearchParameter/Resource-type" - ) - assert ( - inst.rest[0].searchParam[4].documentation - == "Type of resource (when doing cross-resource search" - ) - assert inst.rest[0].searchParam[4].name == "_type" - assert inst.rest[0].searchParam[4].type == "token" - assert ( - inst.rest[0].searchParam[5].definition - == "http://hl7.org/fhir/SearchParameter/Resource-source" - ) - assert ( - inst.rest[0].searchParam[5].documentation - == "How to sort the resources when returning" - ) - assert inst.rest[0].searchParam[5].name == "_sort" - assert inst.rest[0].searchParam[5].type == "token" - assert ( - inst.rest[0].searchParam[6].definition - == "http://hl7.org/fhir/SearchParameter/Resource-count" - ) - assert inst.rest[0].searchParam[6].documentation == "How many resources to return" - assert inst.rest[0].searchParam[6].name == "_count" - assert inst.rest[0].searchParam[6].type == "number" - assert ( - inst.rest[0].searchParam[7].definition - == "http://hl7.org/fhir/SearchParameter/Resource-include" - ) - assert ( - inst.rest[0].searchParam[7].documentation - == "Control over returning additional resources (see spec)" - ) - assert inst.rest[0].searchParam[7].name == "_include" - assert inst.rest[0].searchParam[7].type == "token" - assert ( - inst.rest[0].searchParam[8].definition - == "http://hl7.org/fhir/SearchParameter/Resource-revinclude" - ) - assert ( - inst.rest[0].searchParam[8].documentation - == "Control over returning additional resources (see spec)" - ) - assert inst.rest[0].searchParam[8].name == "_revinclude" - assert inst.rest[0].searchParam[8].type == "token" - assert ( - inst.rest[0].searchParam[9].definition - == "http://hl7.org/fhir/SearchParameter/Resource-summary" - ) - assert ( - inst.rest[0].searchParam[9].documentation - == "What kind of information to return" - ) - assert inst.rest[0].searchParam[9].name == "_summary" - assert inst.rest[0].searchParam[9].type == "token" - assert inst.rest[0].security.cors is True - assert inst.rest[0].security.description == ( - "This is the Capability Statement to declare that the server " - "supports SMART-on-FHIR. See the SMART-on-FHIR docs for the " - "extension that would go with such a server" - ) - assert inst.rest[0].security.service[0].coding[0].code == "SMART-on-FHIR" - assert inst.rest[0].security.service[0].coding[0].display == "SMART-on-FHIR" - assert inst.rest[0].security.service[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/restful-security-" "service" - ) - assert inst.rest[0].security.service[0].text == "See http://docs.smarthealthit.org/" - assert inst.software.name == "Insert your software name here..." - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/CapabilityStatement/base" - assert inst.version == "4.0.1" - - -def test_capabilitystatement_8(base_settings): - """No. 8 tests collection for CapabilityStatement. - Test File: capabilitystatement-base.json - """ - filename = base_settings["unittest_data_dir"] / "capabilitystatement-base.json" - inst = capabilitystatement.CapabilityStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CapabilityStatement" == inst.resource_type - - impl_capabilitystatement_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CapabilityStatement" == data["resourceType"] - - inst2 = capabilitystatement.CapabilityStatement(**data) - impl_capabilitystatement_8(inst2) diff --git a/fhir/resources/tests/test_careplan.py b/fhir/resources/tests/test_careplan.py deleted file mode 100644 index 5b5f9cf8..00000000 --- a/fhir/resources/tests/test_careplan.py +++ /dev/null @@ -1,906 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CarePlan -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import careplan - - -def impl_careplan_1(inst): - assert inst.activity[0].detail.code.coding[0].code == "359615001" - assert inst.activity[0].detail.code.coding[0].display == "Partial lobectomy of lung" - assert inst.activity[0].detail.code.coding[0].system == "http://snomed.info/sct" - assert inst.activity[0].detail.doNotPerform is True - assert inst.activity[0].detail.kind == "ServiceRequest" - assert inst.activity[0].detail.performer[0].display == "M.I.M. Versteegh" - assert inst.activity[0].detail.performer[0].reference == "Practitioner/f003" - assert inst.activity[0].detail.scheduledString == "2011-07-07T09:30:10+01:00" - assert inst.activity[0].detail.status == "completed" - assert inst.addresses[0].display == "?????" - assert inst.addresses[0].reference == "Condition/f201" - assert inst.careTeam[0].reference == "#careteam" - assert inst.contained[0].id == "careteam" - assert inst.contained[1].id == "goal" - assert inst.goal[0].reference == "#goal" - assert inst.id == "f002" - assert ( - inst.identifier[0].system - == "http://www.bmc.nl/zorgportal/identifiers/careplans" - ) - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "CP2934" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2013-07-07T12:09:24+00:06") - assert inst.period.start == fhirtypes.DateTime.validate("2011-07-06T12:09:24+00:06") - assert inst.status == "completed" - assert inst.subject.display == "P. van de Heuvel" - assert inst.subject.reference == "Patient/f001" - assert inst.text.status == "generated" - - -def test_careplan_1(base_settings): - """No. 1 tests collection for CarePlan. - Test File: careplan-example-f002-lung.json - """ - filename = base_settings["unittest_data_dir"] / "careplan-example-f002-lung.json" - inst = careplan.CarePlan.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CarePlan" == inst.resource_type - - impl_careplan_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CarePlan" == data["resourceType"] - - inst2 = careplan.CarePlan(**data) - impl_careplan_1(inst2) - - -def impl_careplan_2(inst): - assert inst.activity[0].detail.code.coding[0].code == "367336001" - assert inst.activity[0].detail.code.coding[0].display == "Chemotherapy" - assert inst.activity[0].detail.code.coding[0].system == "http://snomed.info/sct" - assert inst.activity[0].detail.doNotPerform is False - assert inst.activity[0].detail.kind == "ServiceRequest" - assert inst.activity[0].detail.productReference.reference == "#tpf" - assert inst.activity[0].detail.status == "in-progress" - assert inst.activity[0].outcomeReference[0].display == "Roel's Chemotherapy" - assert inst.activity[0].outcomeReference[0].reference == "Procedure/f201" - assert inst.addresses[0].display == "Roel's head-neck tumor" - assert inst.addresses[0].reference == "Condition/f202" - assert inst.careTeam[0].reference == "#careteam" - assert inst.contained[0].id == "doce" - assert inst.contained[1].id == "cisp" - assert inst.contained[2].id == "fluo" - assert inst.contained[3].id == "tpf" - assert inst.contained[4].id == "careteam" - assert inst.contained[5].id == "goal" - assert inst.goal[0].reference == "#goal" - assert inst.id == "f202" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "active" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - - -def test_careplan_2(base_settings): - """No. 2 tests collection for CarePlan. - Test File: careplan-example-f202-malignancy.json - """ - filename = ( - base_settings["unittest_data_dir"] / "careplan-example-f202-malignancy.json" - ) - inst = careplan.CarePlan.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CarePlan" == inst.resource_type - - impl_careplan_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CarePlan" == data["resourceType"] - - inst2 = careplan.CarePlan(**data) - impl_careplan_2(inst2) - - -def impl_careplan_3(inst): - assert inst.id == "obesity-narrative" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "active" - assert inst.subject.display == "Peter James Chalmers" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "additional" - - -def test_careplan_3(base_settings): - """No. 3 tests collection for CarePlan. - Test File: careplan-example-obesity-narrative.json - """ - filename = ( - base_settings["unittest_data_dir"] / "careplan-example-obesity-narrative.json" - ) - inst = careplan.CarePlan.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CarePlan" == inst.resource_type - - impl_careplan_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CarePlan" == data["resourceType"] - - inst2 = careplan.CarePlan(**data) - impl_careplan_3(inst2) - - -def impl_careplan_4(inst): - assert inst.activity[0].detail.code.coding[0].code == "3141-9" - assert inst.activity[0].detail.code.coding[0].display == "Weight Measured" - assert inst.activity[0].detail.code.coding[0].system == "http://loinc.org" - assert inst.activity[0].detail.code.coding[1].code == "27113001" - assert inst.activity[0].detail.code.coding[1].display == "Body weight" - assert inst.activity[0].detail.code.coding[1].system == "http://snomed.info/sct" - assert inst.activity[0].detail.doNotPerform is False - assert inst.activity[0].detail.location.display == "Patient's home" - assert inst.activity[0].detail.performer[0].display == "Peter James Chalmers" - assert inst.activity[0].detail.performer[0].reference == "Patient/example" - assert inst.activity[0].detail.scheduledTiming.repeat.frequency == 1 - assert float(inst.activity[0].detail.scheduledTiming.repeat.period) == float(1) - assert inst.activity[0].detail.scheduledTiming.repeat.periodUnit == "d" - assert inst.activity[0].detail.status == "completed" - assert ( - inst.activity[0].detail.statusReason.text - == "Achieved weight loss to mitigate diabetes risk." - ) - assert inst.activity[0].outcomeCodeableConcept[0].coding[0].code == "161832001" - assert ( - inst.activity[0].outcomeCodeableConcept[0].coding[0].display - == "Progressive weight loss" - ) - assert ( - inst.activity[0].outcomeCodeableConcept[0].coding[0].system - == "http://snomed.info/sct" - ) - assert inst.activity[0].outcomeReference[0].display == "Weight Measured" - assert inst.activity[0].outcomeReference[0].reference == "Observation/example" - assert inst.addresses[0].display == "obesity" - assert inst.addresses[0].reference == "#p1" - assert inst.author.display == "Dr Adam Careful" - assert inst.author.reference == "Practitioner/example" - assert inst.basedOn[0].display == "Management of Type 2 Diabetes" - assert inst.careTeam[0].reference == "CareTeam/example" - assert inst.category[0].text == "Weight management plan" - assert inst.contained[0].id == "p1" - assert inst.created == fhirtypes.DateTime.validate("2016-01-01T12:09:24+00:06") - assert inst.description == "Manage obesity and weight loss" - assert inst.encounter.reference == "Encounter/home" - assert inst.goal[0].reference == "Goal/example" - assert inst.id == "example" - assert inst.identifier[0].value == "12345" - assert inst.instantiatesUri[0] == "http://example.org/protocol-for-obesity" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.partOf[0].display == "Overall wellness plan" - assert inst.period.end == fhirtypes.DateTime.validate("2017-06-01T12:09:24+00:06") - assert inst.replaces[0].display == "Plan from urgent care clinic" - assert inst.status == "active" - assert inst.subject.display == "Peter James Chalmers" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "additional" - - -def test_careplan_4(base_settings): - """No. 4 tests collection for CarePlan. - Test File: careplan-example.json - """ - filename = base_settings["unittest_data_dir"] / "careplan-example.json" - inst = careplan.CarePlan.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CarePlan" == inst.resource_type - - impl_careplan_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CarePlan" == data["resourceType"] - - inst2 = careplan.CarePlan(**data) - impl_careplan_4(inst2) - - -def impl_careplan_5(inst): - assert inst.activity[0].detail.code.coding[0].code == "284093001" - assert inst.activity[0].detail.code.coding[0].display == "Potassium supplementation" - assert inst.activity[0].detail.code.coding[0].system == "http://snomed.info/sct" - assert inst.activity[0].detail.dailyAmount.code == "258718000" - assert inst.activity[0].detail.dailyAmount.system == "http://snomed.info/sct" - assert inst.activity[0].detail.dailyAmount.unit == "mmol" - assert float(inst.activity[0].detail.dailyAmount.value) == float(80) - assert inst.activity[0].detail.doNotPerform is False - assert inst.activity[0].detail.kind == "NutritionOrder" - assert inst.activity[0].detail.productReference.display == "Potassium" - assert inst.activity[0].detail.productReference.reference == "Substance/f203" - assert inst.activity[0].detail.scheduledString == "daily" - assert inst.activity[0].detail.status == "completed" - assert inst.activity[1].detail.code.coding[0].code == "306005" - assert inst.activity[1].detail.code.coding[0].display == "Echography of kidney" - assert inst.activity[1].detail.code.coding[0].system == "http://snomed.info/sct" - assert inst.activity[1].detail.doNotPerform is False - assert inst.activity[1].detail.kind == "ServiceRequest" - assert inst.activity[1].detail.status == "completed" - assert inst.addresses[0].display == "Roel's renal insufficiency" - assert inst.addresses[0].reference == "Condition/f204" - assert inst.careTeam[0].reference == "#careteam" - assert inst.contained[0].id == "careteam" - assert inst.contained[1].id == "goal" - assert inst.goal[0].reference == "#goal" - assert inst.id == "f201" - assert inst.intent == "proposal" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2013-03-13T12:09:24+00:06") - assert inst.period.start == fhirtypes.DateTime.validate("2013-03-11T12:09:24+00:06") - assert inst.status == "draft" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - - -def test_careplan_5(base_settings): - """No. 5 tests collection for CarePlan. - Test File: careplan-example-f201-renal.json - """ - filename = base_settings["unittest_data_dir"] / "careplan-example-f201-renal.json" - inst = careplan.CarePlan.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CarePlan" == inst.resource_type - - impl_careplan_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CarePlan" == data["resourceType"] - - inst2 = careplan.CarePlan(**data) - impl_careplan_5(inst2) - - -def impl_careplan_6(inst): - assert inst.activity[0].detail.code.coding[0].code == "nursecon" - assert inst.activity[0].detail.code.coding[0].system == "http://example.org/local" - assert inst.activity[0].detail.code.text == "Nurse Consultation" - assert inst.activity[0].detail.doNotPerform is False - assert inst.activity[0].detail.kind == "Appointment" - assert inst.activity[0].detail.performer[0].display == "Nurse Nancy" - assert inst.activity[0].detail.performer[0].reference == "Practitioner/13" - assert inst.activity[0].detail.scheduledPeriod.end == fhirtypes.DateTime.validate( - "2013-01-01T10:50:00+00:00" - ) - assert inst.activity[0].detail.scheduledPeriod.start == fhirtypes.DateTime.validate( - "2013-01-01T10:38:00+00:00" - ) - assert inst.activity[0].detail.status == "completed" - assert inst.activity[0].outcomeReference[0].reference == "Encounter/example" - assert inst.activity[1].detail.code.coding[0].code == "doccon" - assert inst.activity[1].detail.code.coding[0].system == "http://example.org/local" - assert inst.activity[1].detail.code.text == "Doctor Consultation" - assert inst.activity[1].detail.doNotPerform is False - assert inst.activity[1].detail.kind == "Appointment" - assert inst.activity[1].detail.performer[0].display == "Doctor Dave" - assert inst.activity[1].detail.performer[0].reference == "Practitioner/14" - assert inst.activity[1].detail.status == "scheduled" - assert inst.addresses[0].display == "obesity" - assert inst.addresses[0].reference == "#p1" - assert inst.careTeam[0].reference == "#careteam" - assert inst.contained[0].id == "p1" - assert inst.contained[1].id == "careteam" - assert inst.contained[2].id == "goal" - assert inst.goal[0].reference == "#goal" - assert inst.id == "gpvisit" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.start == fhirtypes.DateTime.validate("2013-01-01T10:30:00+00:00") - assert inst.status == "active" - assert inst.subject.display == "Peter James Chalmers" - assert inst.subject.reference == "Patient/100" - assert inst.text.status == "additional" - - -def test_careplan_6(base_settings): - """No. 6 tests collection for CarePlan. - Test File: careplan-example-GPVisit.json - """ - filename = base_settings["unittest_data_dir"] / "careplan-example-GPVisit.json" - inst = careplan.CarePlan.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CarePlan" == inst.resource_type - - impl_careplan_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CarePlan" == data["resourceType"] - - inst2 = careplan.CarePlan(**data) - impl_careplan_6(inst2) - - -def impl_careplan_7(inst): - assert inst.activity[0].detail.description == ( - "Eve will review photos of high and low density foods and " - "share with her parents" - ) - assert inst.activity[0].detail.doNotPerform is False - assert ( - inst.activity[0].detail.extension[0].url - == "http://example.org/fhir/StructureDefinition/RevisionDate" - ) - assert inst.activity[0].detail.extension[0].valueDate == fhirtypes.Date.validate( - "2012-09-10" - ) - assert inst.activity[0].detail.goal[0].reference == "#g1" - assert inst.activity[0].detail.scheduledPeriod.start == fhirtypes.DateTime.validate( - "2012-09-10T12:09:24+00:06" - ) - assert inst.activity[0].detail.status == "not-started" - assert ( - inst.activity[0].progress[0].text == "Eve eats one meal a day with her parents" - ) - assert inst.activity[0].progress[0].time == fhirtypes.DateTime.validate( - "2012-09-10T12:09:24+00:06" - ) - assert inst.activity[1].detail.description == ( - "Eve will ask her dad to asist her to put the head of her bed" " on blocks" - ) - assert inst.activity[1].detail.doNotPerform is False - assert ( - inst.activity[1].detail.extension[0].url - == "http://example.org/fhir/StructureDefinition/RevisionDate" - ) - assert inst.activity[1].detail.extension[0].valueDate == fhirtypes.Date.validate( - "2012-09-10" - ) - assert inst.activity[1].detail.goal[0].reference == "#g1" - assert inst.activity[1].detail.kind == "CommunicationRequest" - assert inst.activity[1].detail.scheduledPeriod.start == fhirtypes.DateTime.validate( - "2012-09-10T12:09:24+00:06" - ) - assert inst.activity[1].detail.status == "not-started" - assert ( - inst.activity[1].progress[0].text - == "Eve will sleep in her bed more often than the couch" - ) - assert inst.activity[1].progress[0].time == fhirtypes.DateTime.validate( - "2012-09-10T12:09:24+00:06" - ) - assert ( - inst.activity[2].detail.description - == "Eve will reduce her intake of coffee and chocolate" - ) - assert inst.activity[2].detail.doNotPerform is False - assert ( - inst.activity[2].detail.extension[0].url - == "http://example.org/fhir/StructureDefinition/RevisionDate" - ) - assert inst.activity[2].detail.extension[0].valueDate == fhirtypes.Date.validate( - "2012-09-10" - ) - assert inst.activity[2].detail.goal[0].reference == "#g2" - assert inst.activity[2].detail.scheduledPeriod.start == fhirtypes.DateTime.validate( - "2012-09-10T12:09:24+00:06" - ) - assert inst.activity[2].detail.status == "in-progress" - assert inst.activity[3].detail.description == ( - "Eve will walk her friend's dog up and down a big hill 15-30 " - "minutes 3 days a week" - ) - assert inst.activity[3].detail.doNotPerform is False - assert ( - inst.activity[3].detail.extension[0].url - == "http://example.org/fhir/StructureDefinition/RevisionDate" - ) - assert inst.activity[3].detail.extension[0].valueDate == fhirtypes.Date.validate( - "2012-09-10" - ) - assert inst.activity[3].detail.goal[0].reference == "#g3" - assert inst.activity[3].detail.scheduledPeriod.start == fhirtypes.DateTime.validate( - "2012-08-27T12:09:24+00:06" - ) - assert inst.activity[3].detail.status == "in-progress" - assert ( - inst.activity[3].progress[0].text == "Eve would like to try for 5 days a week." - ) - assert inst.activity[3].progress[0].time == fhirtypes.DateTime.validate( - "2012-08-27T12:09:24+00:06" - ) - assert inst.activity[3].progress[1].text == "Eve is still walking the dogs." - assert inst.activity[3].progress[1].time == fhirtypes.DateTime.validate( - "2012-09-10T12:09:24+00:06" - ) - assert ( - inst.activity[4].detail.description - == "Eve will walk 3 blocks to her parents house twice a week" - ) - assert inst.activity[4].detail.doNotPerform is False - assert ( - inst.activity[4].detail.extension[0].url - == "http://example.org/fhir/StructureDefinition/RevisionDate" - ) - assert inst.activity[4].detail.extension[0].valueDate == fhirtypes.Date.validate( - "2012-09-10" - ) - assert inst.activity[4].detail.goal[0].reference == "#g3" - assert inst.activity[4].detail.scheduledPeriod.start == fhirtypes.DateTime.validate( - "2012-07-23T12:09:24+00:06" - ) - assert inst.activity[4].detail.status == "in-progress" - assert inst.activity[4].progress[0].text == "Eve walked 4 times the last week." - assert inst.activity[4].progress[0].time == fhirtypes.DateTime.validate( - "2012-08-13T12:09:24+00:06" - ) - assert inst.activity[4].progress[1].text == ( - "Eve did not walk to her parents the last week, but has plans" " to start again" - ) - assert inst.activity[4].progress[1].time == fhirtypes.DateTime.validate( - "2012-09-10T12:09:24+00:06" - ) - assert inst.activity[5].detail.description == ( - "Eve will use a calendar to check off after medications are " "taken" - ) - assert inst.activity[5].detail.doNotPerform is False - assert ( - inst.activity[5].detail.extension[0].url - == "http://example.org/fhir/StructureDefinition/RevisionDate" - ) - assert inst.activity[5].detail.extension[0].valueDate == fhirtypes.Date.validate( - "2012-08-13" - ) - assert inst.activity[5].detail.goal[0].reference == "#g4" - assert inst.activity[5].detail.scheduledPeriod.start == fhirtypes.DateTime.validate( - "2012-07-23T12:09:24+00:06" - ) - assert inst.activity[5].detail.status == "in-progress" - assert ( - inst.activity[6].detail.description - == "Eve will use her lights MWF after her shower for 3 minutes" - ) - assert inst.activity[6].detail.doNotPerform is False - assert ( - inst.activity[6].detail.extension[0].url - == "http://example.org/fhir/StructureDefinition/RevisionDate" - ) - assert inst.activity[6].detail.extension[0].valueDate == fhirtypes.Date.validate( - "2012-08-27" - ) - assert inst.activity[6].detail.goal[0].reference == "#g5" - assert inst.activity[6].detail.scheduledPeriod.start == fhirtypes.DateTime.validate( - "2012-07-23T12:09:24+00:06" - ) - assert inst.activity[6].detail.status == "in-progress" - assert inst.activity[6].progress[0].text == ( - "After restarting the vinegar soaks the psoriasis is improved" - " and Eve plans to treat the remainder with light treatments." - " She plans to start this week." - ) - assert inst.activity[6].progress[0].time == fhirtypes.DateTime.validate( - "2012-08-13T12:09:24+00:06" - ) - assert inst.activity[6].progress[1].text == ( - "Since her skin is improved Eve has not been using the light " - "treatment as often, maybe once a week. She would like to " - "increase to 3 times a week again" - ) - assert inst.activity[6].progress[1].time == fhirtypes.DateTime.validate( - "2012-08-27T12:09:24+00:06" - ) - assert inst.activity[7].detail.description == ( - "Eve will use a calendar of a chart to help her remember when" - " to take her medications" - ) - assert inst.activity[7].detail.doNotPerform is False - assert ( - inst.activity[7].detail.extension[0].url - == "http://example.org/fhir/StructureDefinition/RevisionDate" - ) - assert inst.activity[7].detail.extension[0].valueDate == fhirtypes.Date.validate( - "2012-09-10" - ) - assert inst.activity[7].detail.goal[0].reference == "#g4" - assert inst.activity[7].detail.scheduledPeriod.start == fhirtypes.DateTime.validate( - "2012-07-10T12:09:24+00:06" - ) - assert inst.activity[7].detail.status == "in-progress" - assert inst.activity[7].progress[0].text == ( - "Eve created a chart as a reminer to take the medications " - "that do not fit in her pill box" - ) - assert inst.activity[7].progress[0].time == fhirtypes.DateTime.validate( - "2012-07-23T12:09:24+00:06" - ) - assert inst.activity[8].detail.description == ( - "Eve will start using stretch bands and one step 2 days a " - "week Mon/Wed 6-7am and maybe Friday afternoon" - ) - assert inst.activity[8].detail.doNotPerform is False - assert ( - inst.activity[8].detail.extension[0].url - == "http://example.org/fhir/StructureDefinition/RevisionDate" - ) - assert inst.activity[8].detail.extension[0].valueDate == fhirtypes.Date.validate( - "2012-08-23" - ) - assert inst.activity[8].detail.goal[0].reference == "#g3" - assert inst.activity[8].detail.scheduledPeriod.start == fhirtypes.DateTime.validate( - "2012-07-23T12:09:24+00:06" - ) - assert inst.activity[8].detail.status == "on-hold" - assert inst.activity[8].progress[0].text == "Will be able to esume exercise." - assert inst.activity[8].progress[0].time == fhirtypes.DateTime.validate( - "2012-07-30T12:09:24+00:06" - ) - assert ( - inst.activity[8].progress[1].text - == "Eve prefers to focus on walking at this time" - ) - assert inst.activity[8].progress[1].time == fhirtypes.DateTime.validate( - "2012-08-13T12:09:24+00:06" - ) - assert inst.activity[9].detail.description == ( - "Eve will match a printed medication worksheet with the " - "medication bottles at home" - ) - assert inst.activity[9].detail.doNotPerform is False - assert ( - inst.activity[9].detail.extension[0].url - == "http://example.org/fhir/StructureDefinition/RevisionDate" - ) - assert inst.activity[9].detail.extension[0].valueDate == fhirtypes.Date.validate( - "2012-07-23" - ) - assert inst.activity[9].detail.goal[0].reference == "#g4" - assert inst.activity[9].detail.scheduledPeriod.start == fhirtypes.DateTime.validate( - "2012-07-10T12:09:24+00:06" - ) - assert inst.activity[9].detail.status == "completed" - assert inst.addresses[0].display == "GERDS" - assert inst.addresses[0].reference == "#p1" - assert inst.addresses[1].display == "Obesity" - assert inst.addresses[1].reference == "#p2" - assert inst.addresses[2].display == "Psoriasis" - assert inst.addresses[2].reference == "#p3" - assert inst.contained[0].id == "p1" - assert inst.contained[1].id == "p2" - assert inst.contained[2].id == "p3" - assert inst.contained[3].id == "g1" - assert inst.contained[4].id == "g2" - assert inst.contained[5].id == "g3" - assert inst.contained[6].id == "g4" - assert inst.contained[7].id == "g5" - assert inst.goal[0].reference == "#g1" - assert inst.goal[1].reference == "#g2" - assert inst.goal[2].reference == "#g3" - assert inst.goal[3].reference == "#g4" - assert inst.goal[4].reference == "#g5" - assert inst.id == "integrate" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == ( - "Patient family is not ready to commit to goal setting at " - "this time. Goal setting will be addressed in the future" - ) - assert inst.status == "active" - assert inst.subject.display == "Eve Everywoman" - assert inst.subject.reference == "Patient/1" - assert inst.text.status == "generated" - - -def test_careplan_7(base_settings): - """No. 7 tests collection for CarePlan. - Test File: careplan-example-integrated.json - """ - filename = base_settings["unittest_data_dir"] / "careplan-example-integrated.json" - inst = careplan.CarePlan.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CarePlan" == inst.resource_type - - impl_careplan_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CarePlan" == data["resourceType"] - - inst2 = careplan.CarePlan(**data) - impl_careplan_7(inst2) - - -def impl_careplan_8(inst): - assert inst.activity[0].detail.code.coding[0].code == "172960003" - assert ( - inst.activity[0].detail.code.coding[0].display - == "Incision of retropharyngeal abscess" - ) - assert inst.activity[0].detail.code.coding[0].system == "http://snomed.info/sct" - assert inst.activity[0].detail.doNotPerform is True - assert inst.activity[0].detail.kind == "ServiceRequest" - assert inst.activity[0].detail.performer[0].display == "E.M. van den broek" - assert inst.activity[0].detail.performer[0].reference == "Practitioner/f001" - assert inst.activity[0].detail.scheduledString == "2011-06-27T09:30:10+01:00" - assert inst.activity[0].detail.status == "completed" - assert inst.addresses[0].display == "?????" - assert inst.addresses[0].reference == "Condition/f201" - assert inst.careTeam[0].reference == "#careteam" - assert inst.contained[0].id == "careteam" - assert inst.contained[1].id == "goal" - assert inst.goal[0].reference == "#goal" - assert inst.id == "f003" - assert ( - inst.identifier[0].system - == "http://www.bmc.nl/zorgportal/identifiers/careplans" - ) - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "CP3953" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2013-03-08T09:30:10+01:00") - assert inst.period.start == fhirtypes.DateTime.validate("2013-03-08T09:00:10+01:00") - assert inst.status == "completed" - assert inst.subject.display == "P. van de Heuvel" - assert inst.subject.reference == "Patient/f001" - assert inst.text.status == "generated" - - -def test_careplan_8(base_settings): - """No. 8 tests collection for CarePlan. - Test File: careplan-example-f003-pharynx.json - """ - filename = base_settings["unittest_data_dir"] / "careplan-example-f003-pharynx.json" - inst = careplan.CarePlan.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CarePlan" == inst.resource_type - - impl_careplan_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CarePlan" == data["resourceType"] - - inst2 = careplan.CarePlan(**data) - impl_careplan_8(inst2) - - -def impl_careplan_9(inst): - assert inst.activity[0].detail.code.coding[0].code == "64915003" - assert inst.activity[0].detail.code.coding[0].display == "Operation on heart" - assert inst.activity[0].detail.code.coding[0].system == "http://snomed.info/sct" - assert inst.activity[0].detail.doNotPerform is True - assert inst.activity[0].detail.kind == "ServiceRequest" - assert inst.activity[0].detail.performer[0].display == "P. Voigt" - assert inst.activity[0].detail.performer[0].reference == "Practitioner/f002" - assert inst.activity[0].detail.scheduledString == "2011-06-27T09:30:10+01:00" - assert inst.activity[0].detail.status == "completed" - assert inst.addresses[0].display == "?????" - assert inst.addresses[0].reference == "Condition/f201" - assert inst.careTeam[0].reference == "#careteam" - assert inst.contained[0].id == "careteam" - assert inst.contained[1].id == "goal" - assert inst.goal[0].reference == "#goal" - assert inst.id == "f001" - assert ( - inst.identifier[0].system - == "http://www.bmc.nl/zorgportal/identifiers/careplans" - ) - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "CP2903" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2011-06-27T12:09:24+00:06") - assert inst.period.start == fhirtypes.DateTime.validate("2011-06-26T12:09:24+00:06") - assert inst.status == "completed" - assert inst.subject.display == "P. van de Heuvel" - assert inst.subject.reference == "Patient/f001" - assert inst.text.status == "generated" - - -def test_careplan_9(base_settings): - """No. 9 tests collection for CarePlan. - Test File: careplan-example-f001-heart.json - """ - filename = base_settings["unittest_data_dir"] / "careplan-example-f001-heart.json" - inst = careplan.CarePlan.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CarePlan" == inst.resource_type - - impl_careplan_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CarePlan" == data["resourceType"] - - inst2 = careplan.CarePlan(**data) - impl_careplan_9(inst2) - - -def impl_careplan_10(inst): - assert inst.activity[0].reference.display == "Prenatal vitamin MedicationRequest" - assert inst.activity[1].detail.code.coding[0].code == "1an" - assert ( - inst.activity[1].detail.code.coding[0].system == "http://example.org/mySystem" - ) - assert inst.activity[1].detail.code.text == "First Antenatal encounter" - assert inst.activity[1].detail.description == ( - "The first antenatal encounter. This is where a detailed " - "physical examination is performed. and the " - "pregnanacy discussed with the mother-to-be." - ) - assert inst.activity[1].detail.doNotPerform is False - assert inst.activity[1].detail.kind == "Appointment" - assert inst.activity[1].detail.performer[0].display == "Mavis Midwife" - assert inst.activity[1].detail.performer[0].reference == "#pr1" - assert inst.activity[ - 1 - ].detail.scheduledTiming.repeat.boundsPeriod.end == fhirtypes.DateTime.validate( - "2013-02-28T12:09:24+00:06" - ) - assert inst.activity[ - 1 - ].detail.scheduledTiming.repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2013-02-14T12:09:24+00:06" - ) - assert inst.activity[1].detail.status == "scheduled" - assert inst.activity[1].extension[0].url == ( - "http://example.org/fhir/StructureDefinition/careplan#andetai" "ls" - ) - assert ( - inst.activity[1].extension[0].valueUri - == "http://orionhealth.com/fhir/careplan/1andetails" - ) - assert inst.activity[2].detail.code.coding[0].code == "an" - assert ( - inst.activity[2].detail.code.coding[0].system == "http://example.org/mySystem" - ) - assert inst.activity[2].detail.code.text == "Follow-up Antenatal encounter" - assert inst.activity[2].detail.description == ( - "The second antenatal encounter. Discuss any issues that " - "arose from the first antenatal encounter" - ) - assert inst.activity[2].detail.doNotPerform is False - assert inst.activity[2].detail.kind == "Appointment" - assert inst.activity[2].detail.performer[0].display == "Mavis Midwife" - assert inst.activity[2].detail.performer[0].reference == "#pr1" - assert inst.activity[ - 2 - ].detail.scheduledTiming.repeat.boundsPeriod.end == fhirtypes.DateTime.validate( - "2013-03-14T12:09:24+00:06" - ) - assert inst.activity[ - 2 - ].detail.scheduledTiming.repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2013-03-01T12:09:24+00:06" - ) - assert inst.activity[2].detail.status == "not-started" - assert inst.activity[3].detail.code.coding[0].code == "del" - assert ( - inst.activity[3].detail.code.coding[0].system == "http://example.org/mySystem" - ) - assert inst.activity[3].detail.code.text == "Delivery" - assert inst.activity[3].detail.description == "The delivery." - assert inst.activity[3].detail.doNotPerform is False - assert inst.activity[3].detail.kind == "Appointment" - assert inst.activity[3].detail.performer[0].display == "Mavis Midwife" - assert inst.activity[3].detail.performer[0].reference == "#pr1" - assert inst.activity[ - 3 - ].detail.scheduledTiming.repeat.boundsPeriod.end == fhirtypes.DateTime.validate( - "2013-09-14T12:09:24+00:06" - ) - assert inst.activity[ - 3 - ].detail.scheduledTiming.repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2013-09-01T12:09:24+00:06" - ) - assert inst.activity[3].detail.status == "not-started" - assert inst.addresses[0].display == "pregnancy" - assert inst.addresses[0].reference == "#p1" - assert inst.careTeam[0].reference == "#careteam" - assert inst.contained[0].id == "p1" - assert inst.contained[1].id == "pr1" - assert inst.contained[2].id == "pr2" - assert inst.contained[3].id == "careteam" - assert inst.contained[4].id == "goal" - assert ( - inst.extension[0].url - == "http://example.org/fhir/StructureDefinition/careplan#lmp" - ) - assert inst.extension[0].valueDateTime == fhirtypes.DateTime.validate( - "2013-01-01T12:09:24+00:06" - ) - assert inst.goal[0].reference == "#goal" - assert inst.id == "preg" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2013-10-01T12:09:24+00:06") - assert inst.period.start == fhirtypes.DateTime.validate("2013-01-01T12:09:24+00:06") - assert inst.status == "active" - assert inst.subject.display == "Eve Everywoman" - assert inst.subject.reference == "Patient/1" - assert inst.text.status == "additional" - - -def test_careplan_10(base_settings): - """No. 10 tests collection for CarePlan. - Test File: careplan-example-pregnancy.json - """ - filename = base_settings["unittest_data_dir"] / "careplan-example-pregnancy.json" - inst = careplan.CarePlan.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CarePlan" == inst.resource_type - - impl_careplan_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CarePlan" == data["resourceType"] - - inst2 = careplan.CarePlan(**data) - impl_careplan_10(inst2) diff --git a/fhir/resources/tests/test_careteam.py b/fhir/resources/tests/test_careteam.py deleted file mode 100644 index 96c4d84b..00000000 --- a/fhir/resources/tests/test_careteam.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CareTeam -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import careteam - - -def impl_careteam_1(inst): - assert inst.category[0].coding[0].code == "LA27976-2" - assert inst.category[0].coding[0].display == "Encounter-focused care team" - assert inst.category[0].coding[0].system == "http://loinc.org" - assert inst.contained[0].id == "pr1" - assert inst.encounter.reference == "Encounter/example" - assert inst.id == "example" - assert inst.identifier[0].value == "12345" - assert inst.managingOrganization[0].reference == "Organization/f001" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Peter James Charlmers Care Plan for Inpatient Encounter" - assert inst.participant[0].member.display == "Peter James Chalmers" - assert inst.participant[0].member.reference == "Patient/example" - assert inst.participant[0].role[0].text == "responsiblePerson" - assert inst.participant[1].member.display == "Dorothy Dietition" - assert inst.participant[1].member.reference == "#pr1" - assert inst.participant[1].onBehalfOf.reference == "Organization/f001" - assert inst.participant[1].period.end == fhirtypes.DateTime.validate( - "2013-01-01T12:09:24+00:06" - ) - assert inst.participant[1].role[0].text == "adviser" - assert inst.period.end == fhirtypes.DateTime.validate("2013-01-01T12:09:24+00:06") - assert inst.status == "active" - assert inst.subject.display == "Peter James Chalmers" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == '
Care Team
' - assert inst.text.status == "generated" - - -def test_careteam_1(base_settings): - """No. 1 tests collection for CareTeam. - Test File: careteam-example.json - """ - filename = base_settings["unittest_data_dir"] / "careteam-example.json" - inst = careteam.CareTeam.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CareTeam" == inst.resource_type - - impl_careteam_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CareTeam" == data["resourceType"] - - inst2 = careteam.CareTeam(**data) - impl_careteam_1(inst2) diff --git a/fhir/resources/tests/test_catalogentry.py b/fhir/resources/tests/test_catalogentry.py deleted file mode 100644 index 2b643f88..00000000 --- a/fhir/resources/tests/test_catalogentry.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CatalogEntry -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import catalogentry - - -def impl_catalogentry_1(inst): - assert inst.id == "example" - assert inst.identifier[0].system == "http://example.com/identifier" - assert inst.identifier[0].value == "123" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.orderable is True - assert inst.referencedItem.reference == "Medication/123" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - assert inst.type.text == "Medication" - - -def test_catalogentry_1(base_settings): - """No. 1 tests collection for CatalogEntry. - Test File: catalogentry-example.json - """ - filename = base_settings["unittest_data_dir"] / "catalogentry-example.json" - inst = catalogentry.CatalogEntry.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CatalogEntry" == inst.resource_type - - impl_catalogentry_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CatalogEntry" == data["resourceType"] - - inst2 = catalogentry.CatalogEntry(**data) - impl_catalogentry_1(inst2) diff --git a/fhir/resources/tests/test_chargeitem.py b/fhir/resources/tests/test_chargeitem.py deleted file mode 100644 index 29dd64e8..00000000 --- a/fhir/resources/tests/test_chargeitem.py +++ /dev/null @@ -1,100 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ChargeItem -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import chargeitem - - -def impl_chargeitem_1(inst): - assert inst.account[0].reference == "Account/example" - assert inst.code.coding[0].code == "01510" - assert inst.code.coding[0].display == ( - "Zusatzpauschale für Beobachtung nach diagnostischer " "Koronarangiografie" - ) - assert inst.context.reference == "Encounter/example" - assert inst.definitionUri[0] == ( - "http://www.kbv.de/tools/ebm/html/01520_290436086082622081363" "2.html" - ) - assert inst.enteredDate == fhirtypes.DateTime.validate("2017-01-25T23:55:04+01:00") - assert inst.enterer.reference == "Practitioner/example" - assert float(inst.factorOverride) == float(0.8) - assert inst.id == "example" - assert inst.identifier[0].system == "http://myHospital.org/ChargeItems" - assert inst.identifier[0].value == "654321" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].authorReference.reference == "Practitioner/example" - assert inst.note[0].text == "The code is only applicable for periods longer than 4h" - assert inst.note[0].time == fhirtypes.DateTime.validate("2017-01-25T23:55:04+01:00") - assert inst.occurrencePeriod.end == fhirtypes.DateTime.validate( - "2017-01-25T12:35:00+01:00" - ) - assert inst.occurrencePeriod.start == fhirtypes.DateTime.validate( - "2017-01-25T08:00:00+01:00" - ) - assert inst.overrideReason == ( - "Patient is Cardiologist's golf buddy, so he gets a 20% " "discount!" - ) - assert inst.performer[0].actor.reference == "Practitioner/example" - assert inst.performer[0].function.coding[0].code == "17561000" - assert inst.performer[0].function.coding[0].display == "Cardiologist" - assert inst.performer[0].function.coding[0].system == "http://snomed.info/sct" - assert inst.performer[1].actor.reference == "Practitioner/example" - assert inst.performer[1].function.coding[0].code == "224542009" - assert inst.performer[1].function.coding[0].display == "Coronary Care Nurse" - assert inst.performer[1].function.coding[0].system == "http://snomed.info/sct" - assert ( - inst.performingOrganization.identifier.system - == "http://myhospital/NamingSystem/departments" - ) - assert inst.performingOrganization.identifier.value == "CARD_INTERMEDIATE_CARE" - assert inst.priceOverride.currency == "EUR" - assert float(inst.priceOverride.value) == float(40) - assert float(inst.quantity.value) == float(1) - assert inst.reason[0].coding[0].code == "123456" - assert inst.reason[0].coding[0].display == "DIAG-1" - assert inst.reason[0].coding[0].system == "http://hl7.org/fhir/sid/icd-10" - assert ( - inst.requestingOrganization.identifier.system - == "http://myhospital/NamingSystem/departments" - ) - assert inst.requestingOrganization.identifier.value == "CARD_U1" - assert inst.service[0].reference == "Procedure/example" - assert inst.status == "billable" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Example of ' - "ChargeItem Usage in Context of the German EBM Billing code " - "system
" - ) - assert inst.text.status == "generated" - - -def test_chargeitem_1(base_settings): - """No. 1 tests collection for ChargeItem. - Test File: chargeitem-example.json - """ - filename = base_settings["unittest_data_dir"] / "chargeitem-example.json" - inst = chargeitem.ChargeItem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ChargeItem" == inst.resource_type - - impl_chargeitem_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ChargeItem" == data["resourceType"] - - inst2 = chargeitem.ChargeItem(**data) - impl_chargeitem_1(inst2) diff --git a/fhir/resources/tests/test_chargeitemdefinition.py b/fhir/resources/tests/test_chargeitemdefinition.py deleted file mode 100644 index 90185fe6..00000000 --- a/fhir/resources/tests/test_chargeitemdefinition.py +++ /dev/null @@ -1,176 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ChargeItemDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import chargeitemdefinition - - -def impl_chargeitemdefinition_1(inst): - assert ( - inst.applicability[0].description - == "Verify ChargeItem pertains to Device 12345" - ) - assert ( - inst.applicability[0].expression - == "%context.service.suppliedItem='Device/12345'" - ) - assert inst.applicability[0].language == "text/fhirpath" - assert inst.description == "Financial details for custom made device" - assert inst.id == "device" - assert inst.instance[0].reference == "Device/12345" - assert inst.propertyGroup[0].priceComponent[0].amount.currency == "EUR" - assert float(inst.propertyGroup[0].priceComponent[0].amount.value) == float(67.44) - assert inst.propertyGroup[0].priceComponent[0].code.coding[0].code == "VK" - assert ( - inst.propertyGroup[0].priceComponent[0].code.coding[0].display - == "Verkaufspreis (netto)" - ) - assert ( - inst.propertyGroup[0].priceComponent[0].code.coding[0].system - == "http://fhir.de/CodeSystem/billing-attributes" - ) - assert inst.propertyGroup[0].priceComponent[0].type == "base" - assert inst.propertyGroup[1].applicability[0].description == "Gültigkeit Steuersatz" - assert ( - inst.propertyGroup[1].applicability[0].expression - == "%context.occurenceDateTime > '2018-04-01'" - ) - assert inst.propertyGroup[1].applicability[0].language == "text/fhirpath" - assert inst.propertyGroup[1].priceComponent[0].code.coding[0].code == "MWST" - assert ( - inst.propertyGroup[1].priceComponent[0].code.coding[0].display - == "Mehrwersteuersatz" - ) - assert ( - inst.propertyGroup[1].priceComponent[0].code.coding[0].system - == "http://fhir.de/CodeSystem/billing-attributes" - ) - assert float(inst.propertyGroup[1].priceComponent[0].factor) == float(1.19) - assert inst.propertyGroup[1].priceComponent[0].type == "tax" - assert inst.propertyGroup[2].applicability[0].description == "Gültigkeit Steuersatz" - assert ( - inst.propertyGroup[2].applicability[0].expression - == "%context.occurenceDateTime <= '2018-04-01'" - ) - assert inst.propertyGroup[2].applicability[0].language == "text/fhirpath" - assert inst.propertyGroup[2].priceComponent[0].code.coding[0].code == "MWST" - assert ( - inst.propertyGroup[2].priceComponent[0].code.coding[0].display - == "Mehrwersteuersatz" - ) - assert ( - inst.propertyGroup[2].priceComponent[0].code.coding[0].system - == "http://fhir.de/CodeSystem/billing-attributes" - ) - assert float(inst.propertyGroup[2].priceComponent[0].factor) == float(1.07) - assert inst.propertyGroup[2].priceComponent[0].type == "tax" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.url == "http://sap.org/ChargeItemDefinition/device-123" - - -def test_chargeitemdefinition_1(base_settings): - """No. 1 tests collection for ChargeItemDefinition. - Test File: chargeitemdefinition-device-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "chargeitemdefinition-device-example.json" - ) - inst = chargeitemdefinition.ChargeItemDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ChargeItemDefinition" == inst.resource_type - - impl_chargeitemdefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ChargeItemDefinition" == data["resourceType"] - - inst2 = chargeitemdefinition.ChargeItemDefinition(**data) - impl_chargeitemdefinition_1(inst2) - - -def impl_chargeitemdefinition_2(inst): - assert ( - inst.applicability[0].description - == "Excludes billing code 13250 for same Encounter" - ) - assert inst.applicability[0].expression == "[some CQL expression]" - assert inst.applicability[0].language == "text/cql" - assert inst.applicability[1].description == "Applies only once per Encounter" - assert inst.applicability[1].expression == "[some CQL expression]" - assert inst.applicability[1].language == "text/CQL" - assert inst.code.coding[0].code == "30110" - assert inst.code.coding[0].display == "Allergologiediagnostik I" - assert inst.code.coding[0].system == "http://fhir.de/CodingSystem/kbv/ebm" - assert inst.description == ( - "Allergologisch-diagnostischer Komplex zur Diagnostik " - "und/oder zum Ausschluss einer (Kontakt-)Allergie vom Spättyp" - " (Typ IV), einschl. Kosten" - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2018-06-30T11:15:33+10:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2018-04-01T11:15:33+10:00" - ) - assert inst.id == "ebm" - assert inst.propertyGroup[0].priceComponent[0].amount.currency == "EUR" - assert float(inst.propertyGroup[0].priceComponent[0].amount.value) == float(67.44) - assert inst.propertyGroup[0].priceComponent[0].code.coding[0].code == "gesamt-euro" - assert ( - inst.propertyGroup[0].priceComponent[0].code.coding[0].display - == "Gesamt (Euro)" - ) - assert ( - inst.propertyGroup[0].priceComponent[0].code.coding[0].system - == "http://fhir.de/CodeSystem/kbv/ebm-attribute" - ) - assert inst.propertyGroup[0].priceComponent[0].type == "base" - assert ( - inst.propertyGroup[0].priceComponent[1].code.coding[0].code == "gesamt-punkte" - ) - assert ( - inst.propertyGroup[0].priceComponent[1].code.coding[0].display - == "Gesamt (Punkte)" - ) - assert ( - inst.propertyGroup[0].priceComponent[1].code.coding[0].system - == "http://fhir.de/CodeSystem/kbv/ebm-attribute" - ) - assert float(inst.propertyGroup[0].priceComponent[1].factor) == float(633) - assert inst.propertyGroup[0].priceComponent[1].type == "informational" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.url == "http://fhir.de/ChargeItemDefinition/kbv/ebm-30110" - assert inst.version == "2-2018" - - -def test_chargeitemdefinition_2(base_settings): - """No. 2 tests collection for ChargeItemDefinition. - Test File: chargeitemdefinition-ebm-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "chargeitemdefinition-ebm-example.json" - ) - inst = chargeitemdefinition.ChargeItemDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ChargeItemDefinition" == inst.resource_type - - impl_chargeitemdefinition_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ChargeItemDefinition" == data["resourceType"] - - inst2 = chargeitemdefinition.ChargeItemDefinition(**data) - impl_chargeitemdefinition_2(inst2) diff --git a/fhir/resources/tests/test_claim.py b/fhir/resources/tests/test_claim.py deleted file mode 100644 index 9a273644..00000000 --- a/fhir/resources/tests/test_claim.py +++ /dev/null @@ -1,1276 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Claim -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import claim - - -def impl_claim_1(inst): - assert inst.accident.date == fhirtypes.Date.validate("2014-07-09") - assert inst.accident.locationAddress.text == "Grouse Mountain Ski Hill" - assert inst.accident.type.coding[0].code == "SPT" - assert inst.accident.type.coding[0].display == "Sporting Accident" - assert ( - inst.accident.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActIncidentCode" - ) - assert inst.billablePeriod.end == fhirtypes.DateTime.validate( - "2014-08-16T12:09:24+00:06" - ) - assert inst.billablePeriod.start == fhirtypes.DateTime.validate( - "2014-08-15T12:09:24+00:06" - ) - assert inst.careTeam[0].provider.reference == "Practitioner/example" - assert inst.careTeam[0].qualification.coding[0].code == "physician" - assert ( - inst.careTeam[0].qualification.coding[0].system - == "http://example.org/fhir/CodeSystem/provider-qualification" - ) - assert inst.careTeam[0].responsible is True - assert inst.careTeam[0].role.coding[0].code == "primary" - assert ( - inst.careTeam[0].role.coding[0].system - == "http://example.org/fhir/CodeSystem/claim-careteamrole" - ) - assert inst.careTeam[0].sequence == 1 - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.diagnosis[0].diagnosisCodeableConcept.coding[0].code == "654456" - assert inst.diagnosis[0].packageCode.coding[0].code == "400" - assert inst.diagnosis[0].packageCode.coding[0].display == "Head trauma - concussion" - assert inst.diagnosis[0].packageCode.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/ex-" "diagnosisrelatedgroup" - ) - assert inst.diagnosis[0].sequence == 1 - assert inst.diagnosis[0].type[0].coding[0].code == "admitting" - assert ( - inst.diagnosis[0].type[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-diagnosistype" - ) - assert ( - inst.enterer.identifier.system - == "http://jurisdiction.org/facilities/HOSP1234/users" - ) - assert inst.enterer.identifier.value == "UC1234" - assert inst.facility.identifier.system == "http://jurisdiction.org/facilities" - assert inst.facility.identifier.value == "HOSP1234" - assert inst.id == "960151" - assert inst.identifier[0].system == "http://happyhospital.com/claim" - assert inst.identifier[0].value == "96123451" - assert inst.insurance[0].businessArrangement == "BA987123" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is True - assert inst.insurance[0].preAuthRef[0] == "PA2014G56473" - assert inst.insurance[0].sequence == 1 - assert inst.insurer.reference == "Organization/2" - assert inst.item[0].careTeamSequence[0] == 1 - assert inst.item[0].net.currency == "USD" - assert float(inst.item[0].net.value) == float(125.0) - assert inst.item[0].productOrService.coding[0].code == "exam" - assert ( - inst.item[0].productOrService.coding[0].system - == "http://hl7.org/fhir/ex-serviceproduct" - ) - assert inst.item[0].sequence == 1 - assert inst.item[0].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.item[0].unitPrice.currency == "USD" - assert float(inst.item[0].unitPrice.value) == float(125.0) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/1" - assert inst.payee.type.coding[0].code == "provider" - assert inst.priority.coding[0].code == "normal" - assert inst.provider.identifier.system == "http://npid.org/providerid" - assert inst.provider.identifier.value == "NJ12345" - assert inst.status == "active" - assert inst.supportingInfo[0].category.coding[0].code == "employmentimpacted" - assert inst.supportingInfo[0].category.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/claiminformationcatego" "ry" - ) - assert inst.supportingInfo[0].sequence == 1 - assert inst.supportingInfo[0].timingPeriod.end == fhirtypes.DateTime.validate( - "2014-08-16T12:09:24+00:06" - ) - assert inst.supportingInfo[0].timingPeriod.start == fhirtypes.DateTime.validate( - "2014-08-16T12:09:24+00:06" - ) - assert inst.supportingInfo[1].category.coding[0].code == "hospitalized" - assert inst.supportingInfo[1].category.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/claiminformationcatego" "ry" - ) - assert inst.supportingInfo[1].sequence == 2 - assert inst.supportingInfo[1].timingPeriod.end == fhirtypes.DateTime.validate( - "2014-08-16T12:09:24+00:06" - ) - assert inst.supportingInfo[1].timingPeriod.start == fhirtypes.DateTime.validate( - "2014-08-15T12:09:24+00:06" - ) - assert inst.text.div == ( - '
A human-readable' - " rendering of the Claim
" - ) - assert inst.text.status == "generated" - assert inst.total.currency == "USD" - assert float(inst.total.value) == float(125.0) - assert inst.type.coding[0].code == "institutional" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claim_1(base_settings): - """No. 1 tests collection for Claim. - Test File: claim-example-institutional-rich.json - """ - filename = ( - base_settings["unittest_data_dir"] / "claim-example-institutional-rich.json" - ) - inst = claim.Claim.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Claim" == inst.resource_type - - impl_claim_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Claim" == data["resourceType"] - - inst2 = claim.Claim(**data) - impl_claim_1(inst2) - - -def impl_claim_2(inst): - assert inst.careTeam[0].provider.reference == "Practitioner/example" - assert inst.careTeam[0].sequence == 1 - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.diagnosis[0].diagnosisCodeableConcept.coding[0].code == "654456" - assert inst.diagnosis[0].sequence == 1 - assert inst.id == "860150" - assert inst.identifier[0].system == "http://happypdocs.com/claim" - assert inst.identifier[0].value == "8612345" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is True - assert inst.insurance[0].sequence == 1 - assert inst.insurer.reference == "Organization/2" - assert inst.item[0].careTeamSequence[0] == 1 - assert inst.item[0].net.currency == "USD" - assert float(inst.item[0].net.value) == float(75.0) - assert inst.item[0].productOrService.coding[0].code == "exam" - assert ( - inst.item[0].productOrService.coding[0].system - == "http://hl7.org/fhir/ex-serviceproduct" - ) - assert inst.item[0].sequence == 1 - assert inst.item[0].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.item[0].unitPrice.currency == "USD" - assert float(inst.item[0].unitPrice.value) == float(75.0) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/1" - assert inst.payee.type.coding[0].code == "provider" - assert inst.priority.coding[0].code == "normal" - assert inst.provider.reference == "Organization/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the Claim
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "professional" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claim_2(base_settings): - """No. 2 tests collection for Claim. - Test File: claim-example-professional.json - """ - filename = base_settings["unittest_data_dir"] / "claim-example-professional.json" - inst = claim.Claim.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Claim" == inst.resource_type - - impl_claim_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Claim" == data["resourceType"] - - inst2 = claim.Claim(**data) - impl_claim_2(inst2) - - -def impl_claim_3(inst): - assert inst.careTeam[0].provider.reference == "Practitioner/example" - assert inst.careTeam[0].sequence == 1 - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.diagnosis[0].diagnosisCodeableConcept.coding[0].code == "123456" - assert inst.diagnosis[0].sequence == 1 - assert inst.id == "100150" - assert inst.identifier[0].system == "http://happyvalley.com/claim" - assert inst.identifier[0].value == "12345" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is True - assert inst.insurance[0].identifier.system == "http://happyvalley.com/claim" - assert inst.insurance[0].identifier.value == "12345" - assert inst.insurance[0].sequence == 1 - assert inst.insurer.reference == "Organization/2" - assert inst.item[0].careTeamSequence[0] == 1 - assert inst.item[0].net.currency == "USD" - assert float(inst.item[0].net.value) == float(135.57) - assert inst.item[0].productOrService.coding[0].code == "1200" - assert inst.item[0].sequence == 1 - assert inst.item[0].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.item[0].unitPrice.currency == "USD" - assert float(inst.item[0].unitPrice.value) == float(135.57) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/1" - assert inst.payee.type.coding[0].code == "provider" - assert inst.priority.coding[0].code == "normal" - assert inst.provider.reference == "Organization/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the Oral Health Claim
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "oral" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claim_3(base_settings): - """No. 3 tests collection for Claim. - Test File: claim-example.json - """ - filename = base_settings["unittest_data_dir"] / "claim-example.json" - inst = claim.Claim.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Claim" == inst.resource_type - - impl_claim_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Claim" == data["resourceType"] - - inst2 = claim.Claim(**data) - impl_claim_3(inst2) - - -def impl_claim_4(inst): - assert inst.careTeam[0].provider.reference == "Practitioner/example" - assert inst.careTeam[0].sequence == 1 - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.diagnosis[0].diagnosisCodeableConcept.coding[0].code == "654321" - assert inst.diagnosis[0].sequence == 1 - assert inst.id == "660150" - assert inst.identifier[0].system == "http://happysight.com/claim" - assert inst.identifier[0].value == "6612345" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is True - assert inst.insurance[0].sequence == 1 - assert inst.insurer.reference == "Organization/2" - assert inst.item[0].careTeamSequence[0] == 1 - assert inst.item[0].net.currency == "USD" - assert float(inst.item[0].net.value) == float(80.0) - assert inst.item[0].productOrService.coding[0].code == "exam" - assert ( - inst.item[0].productOrService.coding[0].system - == "http://example.org/fhir/CodeSystem/ex-visionservice" - ) - assert inst.item[0].sequence == 1 - assert inst.item[0].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.item[0].unitPrice.currency == "USD" - assert float(inst.item[0].unitPrice.value) == float(80.0) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/1" - assert inst.payee.type.coding[0].code == "provider" - assert inst.priority.coding[0].code == "normal" - assert inst.provider.reference == "Organization/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the Vision Claim
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "vision" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claim_4(base_settings): - """No. 4 tests collection for Claim. - Test File: claim-example-vision.json - """ - filename = base_settings["unittest_data_dir"] / "claim-example-vision.json" - inst = claim.Claim.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Claim" == inst.resource_type - - impl_claim_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Claim" == data["resourceType"] - - inst2 = claim.Claim(**data) - impl_claim_4(inst2) - - -def impl_claim_5(inst): - assert inst.careTeam[0].provider.reference == "Practitioner/example" - assert inst.careTeam[0].sequence == 1 - assert inst.contained[0].id == "device-frame" - assert inst.contained[1].id == "device-lens" - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.diagnosis[0].diagnosisCodeableConcept.coding[0].code == "654321" - assert inst.diagnosis[0].sequence == 1 - assert inst.id == "660152" - assert inst.identifier[0].system == "http://happysight.com/claim" - assert inst.identifier[0].value == "6612347" - assert inst.insurance[0].claimResponse.reference == "ClaimResponse/R3500" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is False - assert inst.insurance[0].preAuthRef[0] == "PR7652387237" - assert inst.insurance[0].sequence == 1 - assert inst.insurance[1].coverage.reference == "Coverage/9876B1" - assert inst.insurance[1].focal is True - assert inst.insurance[1].preAuthRef[0] == "AB543GTD7567" - assert inst.insurance[1].sequence == 2 - assert inst.insurer.reference == "Organization/2" - assert inst.item[0].careTeamSequence[0] == 1 - assert inst.item[0].category.coding[0].code == "F6" - assert inst.item[0].category.coding[0].display == "Vision Coverage" - assert ( - inst.item[0].category.coding[0].system - == "http://example.org/fhir/CodeSystem/benefit-subcategory" - ) - assert inst.item[0].detail[0].category.coding[0].code == "F6" - assert inst.item[0].detail[0].category.coding[0].display == "Vision Coverage" - assert ( - inst.item[0].detail[0].category.coding[0].system - == "http://example.org/fhir/CodeSystem/benefit-subcategory" - ) - assert float(inst.item[0].detail[0].factor) == float(1.1) - assert inst.item[0].detail[0].modifier[0].coding[0].code == "rooh" - assert ( - inst.item[0].detail[0].modifier[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/modifiers" - ) - assert inst.item[0].detail[0].net.currency == "USD" - assert float(inst.item[0].detail[0].net.value) == float(110.0) - assert inst.item[0].detail[0].productOrService.coding[0].code == "frame" - assert ( - inst.item[0].detail[0].productOrService.coding[0].system - == "http://example.org/fhir/CodeSystem/ex-visionservice" - ) - assert inst.item[0].detail[0].revenue.coding[0].code == "0010" - assert inst.item[0].detail[0].revenue.coding[0].display == "Vision Clinic" - assert ( - inst.item[0].detail[0].revenue.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-revenue-center" - ) - assert inst.item[0].detail[0].sequence == 1 - assert inst.item[0].detail[0].udi[0].reference == "#device-frame" - assert inst.item[0].detail[0].unitPrice.currency == "USD" - assert float(inst.item[0].detail[0].unitPrice.value) == float(100.0) - assert inst.item[0].detail[1].category.coding[0].code == "F6" - assert inst.item[0].detail[1].category.coding[0].display == "Vision Coverage" - assert ( - inst.item[0].detail[1].category.coding[0].system - == "http://example.org/fhir/CodeSystem/benefit-subcategory" - ) - assert inst.item[0].detail[1].net.currency == "USD" - assert float(inst.item[0].detail[1].net.value) == float(110.0) - assert inst.item[0].detail[1].productOrService.coding[0].code == "lens" - assert ( - inst.item[0].detail[1].productOrService.coding[0].system - == "http://example.org/fhir/CodeSystem/ex-visionservice" - ) - assert inst.item[0].detail[1].programCode[0].coding[0].code == "none" - assert ( - inst.item[0].detail[1].programCode[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-programcode" - ) - assert float(inst.item[0].detail[1].quantity.value) == float(2) - assert inst.item[0].detail[1].revenue.coding[0].code == "0010" - assert inst.item[0].detail[1].revenue.coding[0].display == "Vision Clinic" - assert ( - inst.item[0].detail[1].revenue.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-revenue-center" - ) - assert inst.item[0].detail[1].sequence == 2 - assert inst.item[0].detail[1].subDetail[0].category.coding[0].code == "F6" - assert ( - inst.item[0].detail[1].subDetail[0].category.coding[0].display - == "Vision Coverage" - ) - assert ( - inst.item[0].detail[1].subDetail[0].category.coding[0].system - == "http://example.org/fhir/CodeSystem/benefit-subcategory" - ) - assert float(inst.item[0].detail[1].subDetail[0].factor) == float(1.1) - assert inst.item[0].detail[1].subDetail[0].modifier[0].coding[0].code == "rooh" - assert ( - inst.item[0].detail[1].subDetail[0].modifier[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/modifiers" - ) - assert inst.item[0].detail[1].subDetail[0].net.currency == "USD" - assert float(inst.item[0].detail[1].subDetail[0].net.value) == float(66.0) - assert inst.item[0].detail[1].subDetail[0].productOrService.coding[0].code == "lens" - assert ( - inst.item[0].detail[1].subDetail[0].productOrService.coding[0].system - == "http://example.org/fhir/CodeSystem/ex-visionservice" - ) - assert inst.item[0].detail[1].subDetail[0].programCode[0].coding[0].code == "none" - assert ( - inst.item[0].detail[1].subDetail[0].programCode[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-programcode" - ) - assert float(inst.item[0].detail[1].subDetail[0].quantity.value) == float(2) - assert inst.item[0].detail[1].subDetail[0].revenue.coding[0].code == "0010" - assert ( - inst.item[0].detail[1].subDetail[0].revenue.coding[0].display == "Vision Clinic" - ) - assert ( - inst.item[0].detail[1].subDetail[0].revenue.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-revenue-center" - ) - assert inst.item[0].detail[1].subDetail[0].sequence == 1 - assert inst.item[0].detail[1].subDetail[0].udi[0].reference == "#device-lens" - assert inst.item[0].detail[1].subDetail[0].unitPrice.currency == "USD" - assert float(inst.item[0].detail[1].subDetail[0].unitPrice.value) == float(30.0) - assert inst.item[0].detail[1].subDetail[1].category.coding[0].code == "F6" - assert ( - inst.item[0].detail[1].subDetail[1].category.coding[0].display - == "Vision Coverage" - ) - assert ( - inst.item[0].detail[1].subDetail[1].category.coding[0].system - == "http://example.org/fhir/CodeSystem/benefit-subcategory" - ) - assert float(inst.item[0].detail[1].subDetail[1].factor) == float(1.1) - assert inst.item[0].detail[1].subDetail[1].modifier[0].coding[0].code == "rooh" - assert ( - inst.item[0].detail[1].subDetail[1].modifier[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/modifiers" - ) - assert inst.item[0].detail[1].subDetail[1].net.currency == "USD" - assert float(inst.item[0].detail[1].subDetail[1].net.value) == float(33.0) - assert ( - inst.item[0].detail[1].subDetail[1].productOrService.coding[0].code - == "hardening" - ) - assert ( - inst.item[0].detail[1].subDetail[1].productOrService.coding[0].system - == "http://example.org/fhir/CodeSystem/ex-visionservice" - ) - assert float(inst.item[0].detail[1].subDetail[1].quantity.value) == float(2) - assert inst.item[0].detail[1].subDetail[1].revenue.coding[0].code == "0010" - assert ( - inst.item[0].detail[1].subDetail[1].revenue.coding[0].display == "Vision Clinic" - ) - assert ( - inst.item[0].detail[1].subDetail[1].revenue.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-revenue-center" - ) - assert inst.item[0].detail[1].subDetail[1].sequence == 2 - assert inst.item[0].detail[1].subDetail[1].unitPrice.currency == "USD" - assert float(inst.item[0].detail[1].subDetail[1].unitPrice.value) == float(15.0) - assert inst.item[0].detail[1].subDetail[2].category.coding[0].code == "F6" - assert ( - inst.item[0].detail[1].subDetail[2].category.coding[0].display - == "Vision Coverage" - ) - assert ( - inst.item[0].detail[1].subDetail[2].category.coding[0].system - == "http://example.org/fhir/CodeSystem/benefit-subcategory" - ) - assert float(inst.item[0].detail[1].subDetail[2].factor) == float(1.1) - assert inst.item[0].detail[1].subDetail[2].modifier[0].coding[0].code == "rooh" - assert ( - inst.item[0].detail[1].subDetail[2].modifier[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/modifiers" - ) - assert inst.item[0].detail[1].subDetail[2].net.currency == "USD" - assert float(inst.item[0].detail[1].subDetail[2].net.value) == float(11.0) - assert ( - inst.item[0].detail[1].subDetail[2].productOrService.coding[0].code - == "UV coating" - ) - assert ( - inst.item[0].detail[1].subDetail[2].productOrService.coding[0].system - == "http://example.org/fhir/CodeSystem/ex-visionservice" - ) - assert float(inst.item[0].detail[1].subDetail[2].quantity.value) == float(2) - assert inst.item[0].detail[1].subDetail[2].revenue.coding[0].code == "0010" - assert ( - inst.item[0].detail[1].subDetail[2].revenue.coding[0].display == "Vision Clinic" - ) - assert ( - inst.item[0].detail[1].subDetail[2].revenue.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-revenue-center" - ) - assert inst.item[0].detail[1].subDetail[2].sequence == 3 - assert inst.item[0].detail[1].subDetail[2].unitPrice.currency == "USD" - assert float(inst.item[0].detail[1].subDetail[2].unitPrice.value) == float(5.0) - assert inst.item[0].detail[1].unitPrice.currency == "USD" - assert float(inst.item[0].detail[1].unitPrice.value) == float(55.0) - assert inst.item[0].detail[2].category.coding[0].code == "F6" - assert inst.item[0].detail[2].category.coding[0].display == "Vision Coverage" - assert ( - inst.item[0].detail[2].category.coding[0].system - == "http://example.org/fhir/CodeSystem/benefit-subcategory" - ) - assert float(inst.item[0].detail[2].factor) == float(0.07) - assert inst.item[0].detail[2].net.currency == "USD" - assert float(inst.item[0].detail[2].net.value) == float(15.4) - assert inst.item[0].detail[2].productOrService.coding[0].code == "fst" - assert ( - inst.item[0].detail[2].productOrService.coding[0].system - == "http://example.org/fhir/CodeSystem/ex-visionservice" - ) - assert inst.item[0].detail[2].revenue.coding[0].code == "0010" - assert inst.item[0].detail[2].revenue.coding[0].display == "Vision Clinic" - assert ( - inst.item[0].detail[2].revenue.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-revenue-center" - ) - assert inst.item[0].detail[2].sequence == 3 - assert inst.item[0].detail[2].unitPrice.currency == "USD" - assert float(inst.item[0].detail[2].unitPrice.value) == float(220.0) - assert inst.item[0].modifier[0].coding[0].code == "rooh" - assert ( - inst.item[0].modifier[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/modifiers" - ) - assert inst.item[0].net.currency == "USD" - assert float(inst.item[0].net.value) == float(235.4) - assert inst.item[0].productOrService.coding[0].code == "glasses" - assert ( - inst.item[0].productOrService.coding[0].system - == "http://example.org/fhir/CodeSystem/ex-visionservice" - ) - assert inst.item[0].programCode[0].coding[0].code == "none" - assert ( - inst.item[0].programCode[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-programcode" - ) - assert inst.item[0].revenue.coding[0].code == "0010" - assert inst.item[0].revenue.coding[0].display == "Vision Clinic" - assert ( - inst.item[0].revenue.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-revenue-center" - ) - assert inst.item[0].sequence == 1 - assert inst.item[0].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.item[0].unitPrice.currency == "USD" - assert float(inst.item[0].unitPrice.value) == float(235.4) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/1" - assert inst.payee.type.coding[0].code == "provider" - assert inst.prescription.reference == "http://www.optdocs.com/prescription/12345" - assert inst.priority.coding[0].code == "normal" - assert inst.provider.reference == "Organization/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the Vision Claim for Glasses
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "vision" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claim_5(base_settings): - """No. 5 tests collection for Claim. - Test File: claim-example-vision-glasses-3tier.json - """ - filename = ( - base_settings["unittest_data_dir"] / "claim-example-vision-glasses-3tier.json" - ) - inst = claim.Claim.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Claim" == inst.resource_type - - impl_claim_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Claim" == data["resourceType"] - - inst2 = claim.Claim(**data) - impl_claim_5(inst2) - - -def impl_claim_6(inst): - assert inst.careTeam[0].provider.reference == "Practitioner/example" - assert inst.careTeam[0].sequence == 1 - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.diagnosis[0].diagnosisCodeableConcept.coding[0].code == "654456" - assert inst.diagnosis[0].sequence == 1 - assert ( - inst.enterer.identifier.system - == "http://jurisdiction.org/facilities/HOSP1234/users" - ) - assert inst.enterer.identifier.value == "UC1234" - assert inst.facility.identifier.system == "http://jurisdiction.org/facilities" - assert inst.facility.identifier.value == "HOSP1234" - assert inst.id == "960150" - assert inst.identifier[0].system == "http://happyhospital.com/claim" - assert inst.identifier[0].value == "9612345" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is True - assert inst.insurance[0].sequence == 1 - assert inst.insurer.reference == "Organization/2" - assert inst.item[0].careTeamSequence[0] == 1 - assert inst.item[0].encounter[0].reference == "Encounter/example" - assert inst.item[0].net.currency == "USD" - assert float(inst.item[0].net.value) == float(125.0) - assert inst.item[0].productOrService.coding[0].code == "exam" - assert ( - inst.item[0].productOrService.coding[0].system - == "http://hl7.org/fhir/ex-serviceproduct" - ) - assert inst.item[0].sequence == 1 - assert inst.item[0].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.item[0].unitPrice.currency == "USD" - assert float(inst.item[0].unitPrice.value) == float(125.0) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/1" - assert inst.payee.type.coding[0].code == "provider" - assert inst.priority.coding[0].code == "normal" - assert inst.procedure[0].date == fhirtypes.DateTime.validate( - "2014-08-16T11:15:33+10:00" - ) - assert inst.procedure[0].procedureCodeableConcept.coding[0].code == "SDI9901" - assert ( - inst.procedure[0].procedureCodeableConcept.text - == "Subcutaneous diagnostic implant" - ) - assert inst.procedure[0].sequence == 1 - assert inst.procedure[0].type[0].coding[0].code == "primary" - assert inst.procedure[0].udi[0].reference == "Device/example" - assert inst.provider.reference == "Organization/1" - assert inst.status == "active" - assert inst.subType.coding[0].code == "emergency" - assert ( - inst.subType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-claimsubtype" - ) - assert inst.text.div == ( - '
A human-readable' - " rendering of the Claim
" - ) - assert inst.text.status == "generated" - assert inst.total.currency == "USD" - assert float(inst.total.value) == float(125.0) - assert inst.type.coding[0].code == "institutional" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claim_6(base_settings): - """No. 6 tests collection for Claim. - Test File: claim-example-institutional.json - """ - filename = base_settings["unittest_data_dir"] / "claim-example-institutional.json" - inst = claim.Claim.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Claim" == inst.resource_type - - impl_claim_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Claim" == data["resourceType"] - - inst2 = claim.Claim(**data) - impl_claim_6(inst2) - - -def impl_claim_7(inst): - assert inst.careTeam[0].provider.reference == "#provider-1" - assert inst.careTeam[0].sequence == 1 - assert inst.contained[0].id == "org-insurer" - assert inst.contained[1].id == "org-org" - assert inst.contained[2].id == "provider-1" - assert inst.contained[3].id == "patient-1" - assert inst.contained[4].id == "coverage-1" - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.diagnosis[0].diagnosisCodeableConcept.coding[0].code == "123456" - assert inst.diagnosis[0].sequence == 1 - assert inst.id == "100152" - assert inst.identifier[0].system == "http://happyvalley.com/claim" - assert inst.identifier[0].value == "12347" - assert inst.insurance[0].coverage.reference == "#coverage-1" - assert inst.insurance[0].focal is True - assert inst.insurance[0].sequence == 1 - assert inst.insurer.reference == "#org-insurer" - assert inst.item[0].careTeamSequence[0] == 1 - assert inst.item[0].net.currency == "USD" - assert float(inst.item[0].net.value) == float(135.57) - assert inst.item[0].productOrService.coding[0].code == "1200" - assert inst.item[0].sequence == 1 - assert inst.item[0].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.item[0].unitPrice.currency == "USD" - assert float(inst.item[0].unitPrice.value) == float(135.57) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "#patient-1" - assert inst.payee.type.coding[0].code == "provider" - assert inst.priority.coding[0].code == "normal" - assert inst.provider.reference == "#org-org" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the Oral Health Claim
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "oral" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claim_7(base_settings): - """No. 7 tests collection for Claim. - Test File: claim-example-oral-contained.json - """ - filename = base_settings["unittest_data_dir"] / "claim-example-oral-contained.json" - inst = claim.Claim.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Claim" == inst.resource_type - - impl_claim_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Claim" == data["resourceType"] - - inst2 = claim.Claim(**data) - impl_claim_7(inst2) - - -def impl_claim_8(inst): - assert inst.careTeam[0].provider.reference == "Practitioner/example" - assert inst.careTeam[0].sequence == 1 - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.diagnosis[0].diagnosisCodeableConcept.coding[0].code == "654456" - assert inst.diagnosis[0].sequence == 1 - assert inst.id == "760151" - assert inst.identifier[0].system == "http://happypharma.com/claim" - assert inst.identifier[0].value == "7612345" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is True - assert inst.insurance[0].sequence == 1 - assert inst.insurer.reference == "Organization/2" - assert inst.item[0].careTeamSequence[0] == 1 - assert inst.item[0].detail[0].net.currency == "USD" - assert float(inst.item[0].detail[0].net.value) == float(45.0) - assert inst.item[0].detail[0].productOrService.coding[0].code == "drugcost" - assert ( - inst.item[0].detail[0].productOrService.coding[0].system - == "http://hl7.org/fhir/ex-pharmaservice" - ) - assert inst.item[0].detail[0].sequence == 1 - assert inst.item[0].detail[1].net.currency == "USD" - assert float(inst.item[0].detail[1].net.value) == float(9.0) - assert inst.item[0].detail[1].productOrService.coding[0].code == "markup" - assert ( - inst.item[0].detail[1].productOrService.coding[0].system - == "http://hl7.org/fhir/ex-pharmaservice" - ) - assert inst.item[0].detail[1].sequence == 2 - assert inst.item[0].detail[2].net.currency == "USD" - assert float(inst.item[0].detail[2].net.value) == float(36.0) - assert inst.item[0].detail[2].productOrService.coding[0].code == "dispensefee" - assert ( - inst.item[0].detail[2].productOrService.coding[0].system - == "http://hl7.org/fhir/ex-pharmaservice" - ) - assert inst.item[0].detail[2].sequence == 3 - assert inst.item[0].informationSequence[0] == 1 - assert inst.item[0].informationSequence[1] == 2 - assert inst.item[0].informationSequence[2] == 3 - assert inst.item[0].net.currency == "USD" - assert float(inst.item[0].net.value) == float(90.0) - assert inst.item[0].productOrService.coding[0].code == "562721" - assert ( - inst.item[0].productOrService.coding[0].display == "Alprazolam 0.25mg (Xanax)" - ) - assert ( - inst.item[0].productOrService.coding[0].system - == "http://www.nlm.nih.gov/research/umls/rxnorm" - ) - assert inst.item[0].quantity.code == "TAB" - assert inst.item[0].quantity.system == "http://unitsofmeasure.org" - assert inst.item[0].quantity.unit == "TAB" - assert float(inst.item[0].quantity.value) == float(90) - assert inst.item[0].sequence == 1 - assert inst.item[0].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert ( - inst.originalPrescription.reference - == "http://pharmacy.org/MedicationRequest/AB1202B" - ) - assert inst.patient.reference == "Patient/1" - assert inst.payee.type.coding[0].code == "provider" - assert ( - inst.prescription.reference == "http://pharmacy.org/MedicationRequest/AB1234G" - ) - assert inst.priority.coding[0].code == "stat" - assert inst.provider.reference == "Organization/1" - assert inst.status == "active" - assert inst.supportingInfo[0].category.coding[0].code == "pharmacyrefill" - assert inst.supportingInfo[0].code.coding[0].code == "new" - assert ( - inst.supportingInfo[0].code.coding[0].system - == "http://example.org/fhir/CodeSystem/pharmacy-refill" - ) - assert inst.supportingInfo[0].sequence == 1 - assert inst.supportingInfo[1].category.coding[0].code == "pharmacyinformation" - assert inst.supportingInfo[1].code.coding[0].code == "refillsremaining" - assert ( - inst.supportingInfo[1].code.coding[0].system - == "http://example.org/fhir/CodeSystem/pharmacy-information" - ) - assert inst.supportingInfo[1].sequence == 2 - assert float(inst.supportingInfo[1].valueQuantity.value) == float(2) - assert inst.supportingInfo[2].category.coding[0].code == "pharmacyinformation" - assert inst.supportingInfo[2].code.coding[0].code == "dayssupply" - assert ( - inst.supportingInfo[2].code.coding[0].system - == "http://example.org/fhir/CodeSystem/pharmacy-information" - ) - assert inst.supportingInfo[2].sequence == 3 - assert float(inst.supportingInfo[2].valueQuantity.value) == float(90) - assert inst.text.div == ( - '
A human-readable' - " rendering of the Pharmacy Claim
" - ) - assert inst.text.status == "generated" - assert inst.total.currency == "USD" - assert float(inst.total.value) == float(90.0) - assert inst.type.coding[0].code == "pharmacy" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claim_8(base_settings): - """No. 8 tests collection for Claim. - Test File: claim-example-pharmacy-medication.json - """ - filename = ( - base_settings["unittest_data_dir"] / "claim-example-pharmacy-medication.json" - ) - inst = claim.Claim.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Claim" == inst.resource_type - - impl_claim_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Claim" == data["resourceType"] - - inst2 = claim.Claim(**data) - impl_claim_8(inst2) - - -def impl_claim_9(inst): - assert inst.careTeam[0].provider.reference == "Practitioner/example" - assert inst.careTeam[0].sequence == 1 - assert inst.created == fhirtypes.DateTime.validate("2015-03-16T12:09:24+00:06") - assert inst.diagnosis[0].diagnosisCodeableConcept.coding[0].code == "123457" - assert ( - inst.diagnosis[0].diagnosisCodeableConcept.coding[0].system - == "http://hl7.org/fhir/sid/icd-10" - ) - assert inst.diagnosis[0].sequence == 1 - assert inst.fundsReserve.coding[0].code == "provider" - assert inst.id == "100153" - assert inst.identifier[0].system == "http://happyvalley.com/claim" - assert inst.identifier[0].value == "12355" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is True - assert inst.insurance[0].sequence == 1 - assert inst.insurer.reference == "Organization/2" - assert inst.item[0].careTeamSequence[0] == 1 - assert inst.item[0].detail[0].net.currency == "USD" - assert float(inst.item[0].detail[0].net.value) == float(1000.0) - assert inst.item[0].detail[0].productOrService.coding[0].code == "ORTHOEXAM" - assert ( - inst.item[0].detail[0].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.item[0].detail[0].sequence == 1 - assert inst.item[0].detail[0].unitPrice.currency == "USD" - assert float(inst.item[0].detail[0].unitPrice.value) == float(1000.0) - assert inst.item[0].detail[1].net.currency == "USD" - assert float(inst.item[0].detail[1].net.value) == float(1500.0) - assert inst.item[0].detail[1].productOrService.coding[0].code == "ORTHODIAG" - assert ( - inst.item[0].detail[1].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.item[0].detail[1].sequence == 2 - assert inst.item[0].detail[1].unitPrice.currency == "USD" - assert float(inst.item[0].detail[1].unitPrice.value) == float(1500.0) - assert inst.item[0].detail[2].net.currency == "USD" - assert float(inst.item[0].detail[2].net.value) == float(500.0) - assert inst.item[0].detail[2].productOrService.coding[0].code == "ORTHOINITIAL" - assert ( - inst.item[0].detail[2].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.item[0].detail[2].sequence == 3 - assert inst.item[0].detail[2].unitPrice.currency == "USD" - assert float(inst.item[0].detail[2].unitPrice.value) == float(500.0) - assert inst.item[0].detail[3].productOrService.coding[0].code == "ORTHOMONTHS" - assert ( - inst.item[0].detail[3].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert float(inst.item[0].detail[3].quantity.value) == float(24) - assert inst.item[0].detail[3].sequence == 4 - assert inst.item[0].detail[4].net.currency == "USD" - assert float(inst.item[0].detail[4].net.value) == float(250.0) - assert inst.item[0].detail[4].productOrService.coding[0].code == "ORTHOPERIODIC" - assert ( - inst.item[0].detail[4].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert float(inst.item[0].detail[4].quantity.value) == float(24) - assert inst.item[0].detail[4].sequence == 5 - assert inst.item[0].detail[4].unitPrice.currency == "USD" - assert float(inst.item[0].detail[4].unitPrice.value) == float(250.0) - assert inst.item[0].diagnosisSequence[0] == 1 - assert inst.item[0].net.currency == "USD" - assert float(inst.item[0].net.value) == float(9000.0) - assert inst.item[0].productOrService.coding[0].code == "ORTHPLAN" - assert ( - inst.item[0].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.item[0].sequence == 1 - assert inst.item[0].servicedDate == fhirtypes.Date.validate("2015-05-16") - assert inst.item[0].unitPrice.currency == "USD" - assert float(inst.item[0].unitPrice.value) == float(9000.0) - assert inst.item[1].bodySite.coding[0].code == "21" - assert ( - inst.item[1].bodySite.coding[0].system == "http://fdi.org/fhir/oraltoothcodes" - ) - assert inst.item[1].careTeamSequence[0] == 1 - assert inst.item[1].net.currency == "USD" - assert float(inst.item[1].net.value) == float(105.0) - assert inst.item[1].productOrService.coding[0].code == "21211" - assert ( - inst.item[1].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.item[1].sequence == 2 - assert inst.item[1].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.item[1].subSite[0].coding[0].code == "L" - assert ( - inst.item[1].subSite[0].coding[0].system - == "http://fdi.org/fhir/oralsurfacecodes" - ) - assert inst.item[1].unitPrice.currency == "USD" - assert float(inst.item[1].unitPrice.value) == float(105.0) - assert inst.item[2].bodySite.coding[0].code == "36" - assert ( - inst.item[2].bodySite.coding[0].system == "http://fdi.org/fhir/oraltoothcodes" - ) - assert inst.item[2].careTeamSequence[0] == 1 - assert inst.item[2].detail[0].net.currency == "USD" - assert float(inst.item[2].detail[0].net.value) == float(750.0) - assert inst.item[2].detail[0].productOrService.coding[0].code == "27211" - assert ( - inst.item[2].detail[0].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.item[2].detail[0].sequence == 1 - assert inst.item[2].detail[0].unitPrice.currency == "USD" - assert float(inst.item[2].detail[0].unitPrice.value) == float(750.0) - assert inst.item[2].detail[1].net.currency == "USD" - assert float(inst.item[2].detail[1].net.value) == float(350.0) - assert inst.item[2].detail[1].productOrService.coding[0].code == "lab" - assert ( - inst.item[2].detail[1].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.item[2].detail[1].sequence == 2 - assert inst.item[2].detail[1].unitPrice.currency == "USD" - assert float(inst.item[2].detail[1].unitPrice.value) == float(350.0) - assert inst.item[2].net.currency == "USD" - assert float(inst.item[2].net.value) == float(1100.0) - assert inst.item[2].productOrService.coding[0].code == "27211" - assert ( - inst.item[2].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.item[2].sequence == 3 - assert inst.item[2].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.item[2].unitPrice.currency == "USD" - assert float(inst.item[2].unitPrice.value) == float(1100.0) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/1" - assert inst.payee.type.coding[0].code == "provider" - assert inst.priority.coding[0].code == "normal" - assert inst.provider.reference == "Organization/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the Oral Health Claim
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "oral" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "preauthorization" - - -def test_claim_9(base_settings): - """No. 9 tests collection for Claim. - Test File: claim-example-oral-orthoplan.json - """ - filename = base_settings["unittest_data_dir"] / "claim-example-oral-orthoplan.json" - inst = claim.Claim.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Claim" == inst.resource_type - - impl_claim_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Claim" == data["resourceType"] - - inst2 = claim.Claim(**data) - impl_claim_9(inst2) - - -def impl_claim_10(inst): - assert inst.careTeam[0].provider.reference == "Practitioner/example" - assert inst.careTeam[0].sequence == 1 - assert inst.contained[0].id == "patient-1" - assert inst.contained[1].id == "coverage-1" - assert inst.created == fhirtypes.DateTime.validate("2015-10-16T00:00:00-07:00") - assert inst.diagnosis[0].diagnosisCodeableConcept.coding[0].code == "M96.1" - assert ( - inst.diagnosis[0].diagnosisCodeableConcept.coding[0].display - == "Postlaminectomy syndrome" - ) - assert ( - inst.diagnosis[0].diagnosisCodeableConcept.coding[0].system - == "http://hl7.org/fhir/sid/icd-10" - ) - assert inst.diagnosis[0].sequence == 1 - assert inst.diagnosis[1].diagnosisCodeableConcept.coding[0].code == "G89.4" - assert ( - inst.diagnosis[1].diagnosisCodeableConcept.coding[0].display - == "Chronic pain syndrome" - ) - assert ( - inst.diagnosis[1].diagnosisCodeableConcept.coding[0].system - == "http://hl7.org/fhir/sid/icd-10" - ) - assert inst.diagnosis[1].sequence == 2 - assert inst.diagnosis[2].diagnosisCodeableConcept.coding[0].code == "M53.88" - assert inst.diagnosis[2].diagnosisCodeableConcept.coding[0].display == ( - "Other specified dorsopathies, sacral and sacrococcygeal " "region" - ) - assert ( - inst.diagnosis[2].diagnosisCodeableConcept.coding[0].system - == "http://hl7.org/fhir/sid/icd-10" - ) - assert inst.diagnosis[2].sequence == 3 - assert inst.diagnosis[3].diagnosisCodeableConcept.coding[0].code == "M47.816" - assert inst.diagnosis[3].diagnosisCodeableConcept.coding[0].display == ( - "Spondylosis without myelopathy or radiculopathy, lumbar " "region" - ) - assert ( - inst.diagnosis[3].diagnosisCodeableConcept.coding[0].system - == "http://hl7.org/fhir/sid/icd-10" - ) - assert inst.diagnosis[3].sequence == 4 - assert inst.id == "MED-00050" - assert inst.identifier[0].system == "http://CedarArmsMedicalCenter.com/claim" - assert inst.identifier[0].value == "MED-00050" - assert inst.insurance[0].coverage.reference == "#coverage-1" - assert inst.insurance[0].focal is True - assert ( - inst.insurance[0].identifier.system == "http://CedarArmsMedicalCenter.com/claim" - ) - assert inst.insurance[0].identifier.value == "MED-00050" - assert inst.insurance[0].sequence == 1 - assert inst.insurer.display == "Humana Inc." - assert inst.insurer.identifier.system == "http://www.bindb.com/bin" - assert inst.insurer.identifier.value == "123456" - assert inst.item[0].careTeamSequence[0] == 1 - assert inst.item[0].diagnosisSequence[0] == 2 - assert inst.item[0].diagnosisSequence[1] == 4 - assert inst.item[0].informationSequence[0] == 1 - assert inst.item[0].locationCodeableConcept.coding[0].code == "24" - assert ( - inst.item[0].locationCodeableConcept.coding[0].display - == "Ambulatory Surgical Center" - ) - assert inst.item[0].locationCodeableConcept.coding[0].system == ( - "https://www.cms.gov/medicare/coding/place-of-service-" - "codes/place_of_service_code_set.html" - ) - assert inst.item[0].net.currency == "USD" - assert float(inst.item[0].net.value) == float(12500.0) - assert inst.item[0].productOrService.coding[0].code == "62264" - assert ( - inst.item[0].productOrService.coding[0].display - == "Surgical Procedures on the Spine and Spinal Cord" - ) - assert ( - inst.item[0].productOrService.coding[0].system - == "http://www.ama-assn.org/go/cpt" - ) - assert inst.item[0].sequence == 1 - assert inst.item[0].servicedDate == fhirtypes.Date.validate("2015-10-13") - assert inst.item[0].unitPrice.currency == "USD" - assert float(inst.item[0].unitPrice.value) == float(12500.0) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "#patient-1" - assert inst.payee.party.reference == "Organization/1" - assert inst.payee.type.coding[0].code == "provider" - assert ( - inst.payee.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/payeetype" - ) - assert inst.priority.coding[0].code == "normal" - assert inst.provider.reference == "Organization/1" - assert inst.status == "active" - assert inst.subType.coding[0].code == "831" - assert inst.subType.coding[0].system == "https://www.cms.gov/codes/billtype" - assert inst.supportingInfo[0].category.coding[0].code == "hospitalized" - assert inst.supportingInfo[0].category.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/claiminformationcatego" "ry" - ) - assert inst.supportingInfo[0].sequence == 1 - assert inst.supportingInfo[0].timingPeriod.end == fhirtypes.DateTime.validate( - "2015-10-05T00:00:00-07:00" - ) - assert inst.supportingInfo[0].timingPeriod.start == fhirtypes.DateTime.validate( - "2015-10-01T00:00:00-07:00" - ) - assert inst.supportingInfo[1].category.coding[0].code == "discharge" - assert inst.supportingInfo[1].category.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/claiminformationcatego" "ry" - ) - assert inst.supportingInfo[1].code.coding[0].code == "01" - assert ( - inst.supportingInfo[1].code.coding[0].display - == "Discharge to Home or Self Care" - ) - assert inst.supportingInfo[1].code.coding[0].system == ( - "https://www.cms.gov/Outreach-and-Education/Medicare-" - "Learning-Network-MLN/MLNMattersArticles/downloads/SE0801.pdf" - ) - assert inst.supportingInfo[1].sequence == 2 - assert inst.text.div == ( - '
A human-readable' - " rendering of a CMS 1500 Claim
" - ) - assert inst.text.status == "generated" - assert inst.total.currency == "USD" - assert float(inst.total.value) == float(12500.0) - assert inst.type.coding[0].code == "institutional" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claim_10(base_settings): - """No. 10 tests collection for Claim. - Test File: claim-example-cms1500-medical.json - """ - filename = base_settings["unittest_data_dir"] / "claim-example-cms1500-medical.json" - inst = claim.Claim.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Claim" == inst.resource_type - - impl_claim_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Claim" == data["resourceType"] - - inst2 = claim.Claim(**data) - impl_claim_10(inst2) diff --git a/fhir/resources/tests/test_claimresponse.py b/fhir/resources/tests/test_claimresponse.py deleted file mode 100644 index c840750d..00000000 --- a/fhir/resources/tests/test_claimresponse.py +++ /dev/null @@ -1,723 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ClaimResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import claimresponse - - -def impl_claimresponse_1(inst): - assert inst.addItem[0].adjudication[0].amount.currency == "USD" - assert float(inst.addItem[0].adjudication[0].amount.value) == float(250.0) - assert inst.addItem[0].adjudication[0].category.coding[0].code == "eligible" - assert inst.addItem[0].adjudication[1].amount.currency == "USD" - assert float(inst.addItem[0].adjudication[1].amount.value) == float(10.0) - assert inst.addItem[0].adjudication[1].category.coding[0].code == "copay" - assert inst.addItem[0].adjudication[2].category.coding[0].code == "eligpercent" - assert float(inst.addItem[0].adjudication[2].value) == float(100.0) - assert inst.addItem[0].adjudication[3].amount.currency == "USD" - assert float(inst.addItem[0].adjudication[3].amount.value) == float(240.0) - assert inst.addItem[0].adjudication[3].category.coding[0].code == "benefit" - assert inst.addItem[0].itemSequence[0] == 1 - assert inst.addItem[0].modifier[0].coding[0].code == "x" - assert inst.addItem[0].modifier[0].coding[0].display == "None" - assert ( - inst.addItem[0].modifier[0].coding[0].system - == "http://example.org/fhir/modifiers" - ) - assert inst.addItem[0].net.currency == "USD" - assert float(inst.addItem[0].net.value) == float(250.0) - assert inst.addItem[0].noteNumber[0] == 101 - assert inst.addItem[0].productOrService.coding[0].code == "1101" - assert ( - inst.addItem[0].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.addItem[1].adjudication[0].amount.currency == "USD" - assert float(inst.addItem[1].adjudication[0].amount.value) == float(800.0) - assert inst.addItem[1].adjudication[0].category.coding[0].code == "eligible" - assert inst.addItem[1].adjudication[1].category.coding[0].code == "eligpercent" - assert float(inst.addItem[1].adjudication[1].value) == float(100.0) - assert inst.addItem[1].adjudication[2].amount.currency == "USD" - assert float(inst.addItem[1].adjudication[2].amount.value) == float(800.0) - assert inst.addItem[1].adjudication[2].category.coding[0].code == "benefit" - assert inst.addItem[1].itemSequence[0] == 1 - assert inst.addItem[1].net.currency == "USD" - assert float(inst.addItem[1].net.value) == float(800.0) - assert inst.addItem[1].productOrService.coding[0].code == "2101" - assert ( - inst.addItem[1].productOrService.coding[0].display == "Radiograph, series (12)" - ) - assert ( - inst.addItem[1].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.disposition == ( - "The enclosed services are authorized for your provision " - "within 30 days of this notice." - ) - assert inst.id == "UR3503" - assert ( - inst.identifier[0].system - == "http://www.SocialBenefitsInc.com/fhir/ClaimResponse" - ) - assert inst.identifier[0].value == "UR3503" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is True - assert inst.insurance[0].sequence == 1 - assert inst.insurer.identifier.system == "http://www.jurisdiction.org/insurers" - assert inst.insurer.identifier.value == "444123" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "complete" - assert inst.patient.reference == "Patient/1" - assert inst.payeeType.coding[0].code == "provider" - assert ( - inst.payeeType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/payeetype" - ) - assert inst.preAuthRef == "18SS12345" - assert inst.processNote[0].language.coding[0].code == "en-CA" - assert inst.processNote[0].language.coding[0].system == "urn:ietf:bcp:47" - assert inst.processNote[0].number == 101 - assert inst.processNote[0].text == ( - "Please submit a Pre-Authorization request if a more " - "extensive examination or urgent services are required." - ) - assert inst.processNote[0].type == "print" - assert inst.requestor.reference == "Organization/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A sample ' - "unsolicited pre-authorization response which authorizes " - "basic dental services to be performed for a patient.
" - ) - assert inst.text.status == "generated" - assert inst.total[0].amount.currency == "USD" - assert float(inst.total[0].amount.value) == float(1050.0) - assert inst.total[0].category.coding[0].code == "submitted" - assert inst.total[1].amount.currency == "USD" - assert float(inst.total[1].amount.value) == float(1040.0) - assert inst.total[1].category.coding[0].code == "benefit" - assert inst.type.coding[0].code == "oral" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "preauthorization" - - -def test_claimresponse_1(base_settings): - """No. 1 tests collection for ClaimResponse. - Test File: claimresponse-example-unsolicited-preauth.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "claimresponse-example-unsolicited-preauth.json" - ) - inst = claimresponse.ClaimResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ClaimResponse" == inst.resource_type - - impl_claimresponse_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ClaimResponse" == data["resourceType"] - - inst2 = claimresponse.ClaimResponse(**data) - impl_claimresponse_1(inst2) - - -def impl_claimresponse_2(inst): - assert inst.addItem[0].adjudication[0].amount.currency == "USD" - assert float(inst.addItem[0].adjudication[0].amount.value) == float(100.0) - assert inst.addItem[0].adjudication[0].category.coding[0].code == "eligible" - assert inst.addItem[0].adjudication[1].amount.currency == "USD" - assert float(inst.addItem[0].adjudication[1].amount.value) == float(10.0) - assert inst.addItem[0].adjudication[1].category.coding[0].code == "copay" - assert inst.addItem[0].adjudication[2].category.coding[0].code == "eligpercent" - assert float(inst.addItem[0].adjudication[2].value) == float(80.0) - assert inst.addItem[0].adjudication[3].amount.currency == "USD" - assert float(inst.addItem[0].adjudication[3].amount.value) == float(72.0) - assert inst.addItem[0].adjudication[3].category.coding[0].code == "benefit" - assert inst.addItem[0].adjudication[3].reason.coding[0].code == "ar002" - assert ( - inst.addItem[0].adjudication[3].reason.coding[0].display == "Plan Limit Reached" - ) - assert ( - inst.addItem[0].adjudication[3].reason.coding[0].system - == "http://terminology.hl7.org/CodeSystem/adjudication-reason" - ) - assert inst.addItem[0].itemSequence[0] == 1 - assert inst.addItem[0].modifier[0].coding[0].code == "x" - assert inst.addItem[0].modifier[0].coding[0].display == "None" - assert ( - inst.addItem[0].modifier[0].coding[0].system - == "http://example.org/fhir/modifiers" - ) - assert inst.addItem[0].net.currency == "USD" - assert float(inst.addItem[0].net.value) == float(135.57) - assert inst.addItem[0].noteNumber[0] == 101 - assert inst.addItem[0].productOrService.coding[0].code == "1101" - assert ( - inst.addItem[0].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.addItem[1].adjudication[0].amount.currency == "USD" - assert float(inst.addItem[1].adjudication[0].amount.value) == float(35.57) - assert inst.addItem[1].adjudication[0].category.coding[0].code == "eligible" - assert inst.addItem[1].adjudication[1].category.coding[0].code == "eligpercent" - assert float(inst.addItem[1].adjudication[1].value) == float(80.0) - assert inst.addItem[1].adjudication[2].amount.currency == "USD" - assert float(inst.addItem[1].adjudication[2].amount.value) == float(28.47) - assert inst.addItem[1].adjudication[2].category.coding[0].code == "benefit" - assert inst.addItem[1].itemSequence[0] == 1 - assert inst.addItem[1].net.currency == "USD" - assert float(inst.addItem[1].net.value) == float(35.57) - assert inst.addItem[1].productOrService.coding[0].code == "2141" - assert inst.addItem[1].productOrService.coding[0].display == "Radiograph, bytewing" - assert ( - inst.addItem[1].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.addItem[2].adjudication[0].amount.currency == "USD" - assert float(inst.addItem[2].adjudication[0].amount.value) == float(350.0) - assert inst.addItem[2].adjudication[0].category.coding[0].code == "eligible" - assert inst.addItem[2].adjudication[1].category.coding[0].code == "eligpercent" - assert float(inst.addItem[2].adjudication[1].value) == float(80.0) - assert inst.addItem[2].adjudication[2].amount.currency == "USD" - assert float(inst.addItem[2].adjudication[2].amount.value) == float(270.0) - assert inst.addItem[2].adjudication[2].category.coding[0].code == "benefit" - assert inst.addItem[2].detailSequence[0] == 2 - assert inst.addItem[2].itemSequence[0] == 3 - assert inst.addItem[2].modifier[0].coding[0].code == "x" - assert inst.addItem[2].modifier[0].coding[0].display == "None" - assert ( - inst.addItem[2].modifier[0].coding[0].system - == "http://example.org/fhir/modifiers" - ) - assert inst.addItem[2].net.currency == "USD" - assert float(inst.addItem[2].net.value) == float(350.0) - assert inst.addItem[2].noteNumber[0] == 101 - assert inst.addItem[2].productOrService.coding[0].code == "expense" - assert ( - inst.addItem[2].productOrService.coding[0].system - == "http://example.org/fhir/oralservicecodes" - ) - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.disposition == "Claim settled as per contract." - assert inst.id == "R3503" - assert inst.identifier[0].system == "http://www.BenefitsInc.com/fhir/remittance" - assert inst.identifier[0].value == "R3503" - assert inst.insurer.identifier.system == "http://www.jurisdiction.org/insurers" - assert inst.insurer.identifier.value == "555123" - assert inst.item[0].adjudication[0].amount.currency == "USD" - assert float(inst.item[0].adjudication[0].amount.value) == float(0.0) - assert inst.item[0].adjudication[0].category.coding[0].code == "eligible" - assert inst.item[0].adjudication[1].amount.currency == "USD" - assert float(inst.item[0].adjudication[1].amount.value) == float(0.0) - assert inst.item[0].adjudication[1].category.coding[0].code == "benefit" - assert inst.item[0].itemSequence == 1 - assert inst.item[1].adjudication[0].amount.currency == "USD" - assert float(inst.item[1].adjudication[0].amount.value) == float(105.0) - assert inst.item[1].adjudication[0].category.coding[0].code == "eligible" - assert inst.item[1].adjudication[1].category.coding[0].code == "eligpercent" - assert float(inst.item[1].adjudication[1].value) == float(80.0) - assert inst.item[1].adjudication[2].amount.currency == "USD" - assert float(inst.item[1].adjudication[2].amount.value) == float(84.0) - assert inst.item[1].adjudication[2].category.coding[0].code == "benefit" - assert inst.item[1].itemSequence == 2 - assert inst.item[2].adjudication[0].amount.currency == "USD" - assert float(inst.item[2].adjudication[0].amount.value) == float(750.0) - assert inst.item[2].adjudication[0].category.coding[0].code == "eligible" - assert inst.item[2].adjudication[1].category.coding[0].code == "eligpercent" - assert float(inst.item[2].adjudication[1].value) == float(80.0) - assert inst.item[2].adjudication[2].amount.currency == "USD" - assert float(inst.item[2].adjudication[2].amount.value) == float(600.0) - assert inst.item[2].adjudication[2].category.coding[0].code == "benefit" - assert inst.item[2].detail[0].adjudication[0].amount.currency == "USD" - assert float(inst.item[2].detail[0].adjudication[0].amount.value) == float(750.0) - assert inst.item[2].detail[0].adjudication[0].category.coding[0].code == "eligible" - assert ( - inst.item[2].detail[0].adjudication[1].category.coding[0].code == "eligpercent" - ) - assert float(inst.item[2].detail[0].adjudication[1].value) == float(80.0) - assert inst.item[2].detail[0].adjudication[2].amount.currency == "USD" - assert float(inst.item[2].detail[0].adjudication[2].amount.value) == float(600.0) - assert inst.item[2].detail[0].adjudication[2].category.coding[0].code == "benefit" - assert inst.item[2].detail[0].detailSequence == 1 - assert inst.item[2].detail[1].adjudication[0].amount.currency == "USD" - assert float(inst.item[2].detail[1].adjudication[0].amount.value) == float(0.0) - assert inst.item[2].detail[1].adjudication[0].category.coding[0].code == "eligible" - assert inst.item[2].detail[1].adjudication[1].amount.currency == "USD" - assert float(inst.item[2].detail[1].adjudication[1].amount.value) == float(0.0) - assert inst.item[2].detail[1].adjudication[1].category.coding[0].code == "benefit" - assert inst.item[2].detail[1].detailSequence == 2 - assert inst.item[2].itemSequence == 3 - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "complete" - assert inst.patient.reference == "Patient/1" - assert inst.payeeType.coding[0].code == "provider" - assert ( - inst.payeeType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/payeetype" - ) - assert inst.payment.amount.currency == "USD" - assert float(inst.payment.amount.value) == float(100.47) - assert inst.payment.date == fhirtypes.Date.validate("2014-08-31") - assert ( - inst.payment.identifier.system - == "http://www.BenefitsInc.com/fhir/paymentidentifier" - ) - assert inst.payment.identifier.value == "201408-2-15507" - assert inst.payment.type.coding[0].code == "complete" - assert ( - inst.payment.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-paymenttype" - ) - assert inst.processNote[0].language.coding[0].code == "en-CA" - assert inst.processNote[0].language.coding[0].system == "urn:ietf:bcp:47" - assert inst.processNote[0].number == 101 - assert ( - inst.processNote[0].text - == "Package codes are not permitted. Codes replaced by Insurer." - ) - assert inst.processNote[0].type == "print" - assert inst.request.identifier.system == "http://happyvalley.com/claim" - assert inst.request.identifier.value == "12346" - assert inst.requestor.reference == "Organization/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the ClaimResponse to Claim Oral Average with " - "additional items
" - ) - assert inst.text.status == "generated" - assert inst.total[0].amount.currency == "USD" - assert float(inst.total[0].amount.value) == float(1340.57) - assert inst.total[0].category.coding[0].code == "submitted" - assert inst.total[1].amount.currency == "USD" - assert float(inst.total[1].amount.value) == float(1054.47) - assert inst.total[1].category.coding[0].code == "benefit" - assert inst.type.coding[0].code == "oral" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claimresponse_2(base_settings): - """No. 2 tests collection for ClaimResponse. - Test File: claimresponse-example-additem.json - """ - filename = base_settings["unittest_data_dir"] / "claimresponse-example-additem.json" - inst = claimresponse.ClaimResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ClaimResponse" == inst.resource_type - - impl_claimresponse_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ClaimResponse" == data["resourceType"] - - inst2 = claimresponse.ClaimResponse(**data) - impl_claimresponse_2(inst2) - - -def impl_claimresponse_3(inst): - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.disposition == "Claim settled as per contract." - assert inst.id == "R3500" - assert inst.identifier[0].system == "http://www.BenefitsInc.com/fhir/remittance" - assert inst.identifier[0].value == "R3500" - assert inst.insurer.identifier.system == "http://www.jurisdiction.org/insurers" - assert inst.insurer.identifier.value == "555123" - assert inst.item[0].adjudication[0].amount.currency == "USD" - assert float(inst.item[0].adjudication[0].amount.value) == float(135.57) - assert inst.item[0].adjudication[0].category.coding[0].code == "eligible" - assert inst.item[0].adjudication[1].amount.currency == "USD" - assert float(inst.item[0].adjudication[1].amount.value) == float(10.0) - assert inst.item[0].adjudication[1].category.coding[0].code == "copay" - assert inst.item[0].adjudication[2].category.coding[0].code == "eligpercent" - assert float(inst.item[0].adjudication[2].value) == float(80.0) - assert inst.item[0].adjudication[3].amount.currency == "USD" - assert float(inst.item[0].adjudication[3].amount.value) == float(90.47) - assert inst.item[0].adjudication[3].category.coding[0].code == "benefit" - assert inst.item[0].adjudication[3].reason.coding[0].code == "ar002" - assert inst.item[0].adjudication[3].reason.coding[0].display == "Plan Limit Reached" - assert ( - inst.item[0].adjudication[3].reason.coding[0].system - == "http://terminology.hl7.org/CodeSystem/adjudication-reason" - ) - assert inst.item[0].itemSequence == 1 - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "complete" - assert inst.patient.reference == "Patient/1" - assert inst.payeeType.coding[0].code == "provider" - assert ( - inst.payeeType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/payeetype" - ) - assert inst.payment.amount.currency == "USD" - assert float(inst.payment.amount.value) == float(100.47) - assert inst.payment.date == fhirtypes.Date.validate("2014-08-31") - assert ( - inst.payment.identifier.system - == "http://www.BenefitsInc.com/fhir/paymentidentifier" - ) - assert inst.payment.identifier.value == "201408-2-1569478" - assert inst.payment.type.coding[0].code == "complete" - assert ( - inst.payment.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-paymenttype" - ) - assert ( - inst.request.reference - == "http://www.BenefitsInc.com/fhir/oralhealthclaim/15476332402" - ) - assert inst.requestor.reference == "Organization/1" - assert inst.status == "active" - assert inst.subType.coding[0].code == "emergency" - assert ( - inst.subType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-claimsubtype" - ) - assert inst.text.div == ( - '
A human-readable' - " rendering of the ClaimResponse
" - ) - assert inst.text.status == "generated" - assert inst.total[0].amount.currency == "USD" - assert float(inst.total[0].amount.value) == float(135.57) - assert inst.total[0].category.coding[0].code == "submitted" - assert inst.total[1].amount.currency == "USD" - assert float(inst.total[1].amount.value) == float(90.47) - assert inst.total[1].category.coding[0].code == "benefit" - assert inst.type.coding[0].code == "oral" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claimresponse_3(base_settings): - """No. 3 tests collection for ClaimResponse. - Test File: claimresponse-example.json - """ - filename = base_settings["unittest_data_dir"] / "claimresponse-example.json" - inst = claimresponse.ClaimResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ClaimResponse" == inst.resource_type - - impl_claimresponse_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ClaimResponse" == data["resourceType"] - - inst2 = claimresponse.ClaimResponse(**data) - impl_claimresponse_3(inst2) - - -def impl_claimresponse_4(inst): - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.disposition == "Claim settled as per contract." - assert inst.id == "R3502" - assert inst.identifier[0].system == "http://thebenefitcompany.com/claimresponse" - assert inst.identifier[0].value == "CR6532875367" - assert inst.insurer.reference == "Organization/2" - assert inst.item[0].adjudication[0].amount.currency == "USD" - assert float(inst.item[0].adjudication[0].amount.value) == float(235.4) - assert inst.item[0].adjudication[0].category.coding[0].code == "eligible" - assert inst.item[0].adjudication[1].amount.currency == "USD" - assert float(inst.item[0].adjudication[1].amount.value) == float(20.0) - assert inst.item[0].adjudication[1].category.coding[0].code == "copay" - assert inst.item[0].adjudication[2].category.coding[0].code == "eligpercent" - assert float(inst.item[0].adjudication[2].value) == float(80.0) - assert inst.item[0].adjudication[3].amount.currency == "USD" - assert float(inst.item[0].adjudication[3].amount.value) == float(172.32) - assert inst.item[0].adjudication[3].category.coding[0].code == "benefit" - assert inst.item[0].detail[0].adjudication[0].amount.currency == "USD" - assert float(inst.item[0].detail[0].adjudication[0].amount.value) == float(100.0) - assert inst.item[0].detail[0].adjudication[0].category.coding[0].code == "eligible" - assert inst.item[0].detail[0].adjudication[1].amount.currency == "USD" - assert float(inst.item[0].detail[0].adjudication[1].amount.value) == float(20.0) - assert inst.item[0].detail[0].adjudication[1].category.coding[0].code == "copay" - assert ( - inst.item[0].detail[0].adjudication[2].category.coding[0].code == "eligpercent" - ) - assert float(inst.item[0].detail[0].adjudication[2].value) == float(80.0) - assert inst.item[0].detail[0].adjudication[3].amount.currency == "USD" - assert float(inst.item[0].detail[0].adjudication[3].amount.value) == float(80.0) - assert inst.item[0].detail[0].adjudication[3].category.coding[0].code == "benefit" - assert inst.item[0].detail[0].detailSequence == 1 - assert inst.item[0].detail[0].noteNumber[0] == 1 - assert inst.item[0].detail[1].adjudication[0].amount.currency == "USD" - assert float(inst.item[0].detail[1].adjudication[0].amount.value) == float(110.0) - assert inst.item[0].detail[1].adjudication[0].category.coding[0].code == "eligible" - assert ( - inst.item[0].detail[1].adjudication[1].category.coding[0].code == "eligpercent" - ) - assert float(inst.item[0].detail[1].adjudication[1].value) == float(80.0) - assert inst.item[0].detail[1].adjudication[2].amount.currency == "USD" - assert float(inst.item[0].detail[1].adjudication[2].amount.value) == float(88.0) - assert inst.item[0].detail[1].adjudication[2].category.coding[0].code == "benefit" - assert inst.item[0].detail[1].detailSequence == 2 - assert inst.item[0].detail[1].noteNumber[0] == 1 - assert inst.item[0].detail[1].subDetail[0].adjudication[0].amount.currency == "USD" - assert float( - inst.item[0].detail[1].subDetail[0].adjudication[0].amount.value - ) == float(60.0) - assert ( - inst.item[0].detail[1].subDetail[0].adjudication[0].category.coding[0].code - == "eligible" - ) - assert ( - inst.item[0].detail[1].subDetail[0].adjudication[1].category.coding[0].code - == "eligpercent" - ) - assert float(inst.item[0].detail[1].subDetail[0].adjudication[1].value) == float( - 80.0 - ) - assert inst.item[0].detail[1].subDetail[0].adjudication[2].amount.currency == "USD" - assert float( - inst.item[0].detail[1].subDetail[0].adjudication[2].amount.value - ) == float(48.0) - assert ( - inst.item[0].detail[1].subDetail[0].adjudication[2].category.coding[0].code - == "benefit" - ) - assert inst.item[0].detail[1].subDetail[0].noteNumber[0] == 1 - assert inst.item[0].detail[1].subDetail[0].subDetailSequence == 1 - assert inst.item[0].detail[1].subDetail[1].adjudication[0].amount.currency == "USD" - assert float( - inst.item[0].detail[1].subDetail[1].adjudication[0].amount.value - ) == float(30.0) - assert ( - inst.item[0].detail[1].subDetail[1].adjudication[0].category.coding[0].code - == "eligible" - ) - assert ( - inst.item[0].detail[1].subDetail[1].adjudication[1].category.coding[0].code - == "eligpercent" - ) - assert float(inst.item[0].detail[1].subDetail[1].adjudication[1].value) == float( - 80.0 - ) - assert inst.item[0].detail[1].subDetail[1].adjudication[2].amount.currency == "USD" - assert float( - inst.item[0].detail[1].subDetail[1].adjudication[2].amount.value - ) == float(24.0) - assert ( - inst.item[0].detail[1].subDetail[1].adjudication[2].category.coding[0].code - == "benefit" - ) - assert inst.item[0].detail[1].subDetail[1].subDetailSequence == 2 - assert inst.item[0].detail[1].subDetail[2].adjudication[0].amount.currency == "USD" - assert float( - inst.item[0].detail[1].subDetail[2].adjudication[0].amount.value - ) == float(10.0) - assert ( - inst.item[0].detail[1].subDetail[2].adjudication[0].category.coding[0].code - == "eligible" - ) - assert ( - inst.item[0].detail[1].subDetail[2].adjudication[1].category.coding[0].code - == "eligpercent" - ) - assert float(inst.item[0].detail[1].subDetail[2].adjudication[1].value) == float( - 80.0 - ) - assert inst.item[0].detail[1].subDetail[2].adjudication[2].amount.currency == "USD" - assert float( - inst.item[0].detail[1].subDetail[2].adjudication[2].amount.value - ) == float(8.0) - assert ( - inst.item[0].detail[1].subDetail[2].adjudication[2].category.coding[0].code - == "benefit" - ) - assert inst.item[0].detail[1].subDetail[2].noteNumber[0] == 1 - assert inst.item[0].detail[1].subDetail[2].subDetailSequence == 3 - assert inst.item[0].detail[2].adjudication[0].amount.currency == "USD" - assert float(inst.item[0].detail[2].adjudication[0].amount.value) == float(200.0) - assert inst.item[0].detail[2].adjudication[0].category.coding[0].code == "eligible" - assert ( - inst.item[0].detail[2].adjudication[1].category.coding[0].code == "eligpercent" - ) - assert float(inst.item[0].detail[2].adjudication[1].value) == float(80.0) - assert inst.item[0].detail[2].adjudication[2].amount.currency == "USD" - assert float(inst.item[0].detail[2].adjudication[2].amount.value) == float(14.0) - assert inst.item[0].detail[2].adjudication[2].category.coding[0].code == "benefit" - assert inst.item[0].detail[2].detailSequence == 3 - assert inst.item[0].detail[2].noteNumber[0] == 1 - assert inst.item[0].itemSequence == 1 - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "complete" - assert inst.patient.reference == "Patient/1" - assert inst.payeeType.coding[0].code == "provider" - assert ( - inst.payeeType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/payeetype" - ) - assert inst.payment.adjustment.currency == "USD" - assert float(inst.payment.adjustment.value) == float(75.0) - assert inst.payment.adjustmentReason.coding[0].code == "a002" - assert inst.payment.adjustmentReason.coding[0].display == "Prior Overpayment" - assert inst.payment.adjustmentReason.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/payment-adjustment-" "reason" - ) - assert inst.payment.amount.currency == "USD" - assert float(inst.payment.amount.value) == float(107.0) - assert inst.payment.date == fhirtypes.Date.validate("2014-08-16") - assert ( - inst.payment.identifier.system - == "http://thebenefitcompany.com/paymentidentifier" - ) - assert inst.payment.identifier.value == "201416-123456" - assert inst.payment.type.coding[0].code == "complete" - assert ( - inst.payment.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-paymenttype" - ) - assert inst.processNote[0].language.coding[0].code == "en-CA" - assert inst.processNote[0].language.coding[0].system == "urn:ietf:bcp:47" - assert inst.processNote[0].number == 1 - assert inst.processNote[0].text == "After hours surcharge declined" - assert inst.processNote[0].type == "display" - assert inst.request.identifier.system == "http://happysight.com/claim" - assert inst.request.identifier.value == "6612346" - assert inst.requestor.reference == "Organization/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the ClaimResponse
" - ) - assert inst.text.status == "generated" - assert inst.total[0].amount.currency == "USD" - assert float(inst.total[0].amount.value) == float(235.4) - assert inst.total[0].category.coding[0].code == "submitted" - assert inst.total[1].amount.currency == "USD" - assert float(inst.total[1].amount.value) == float(182.0) - assert inst.total[1].category.coding[0].code == "benefit" - assert inst.type.coding[0].code == "vision" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claimresponse_4(base_settings): - """No. 4 tests collection for ClaimResponse. - Test File: claimresponse-example-vision-3tier.json - """ - filename = ( - base_settings["unittest_data_dir"] / "claimresponse-example-vision-3tier.json" - ) - inst = claimresponse.ClaimResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ClaimResponse" == inst.resource_type - - impl_claimresponse_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ClaimResponse" == data["resourceType"] - - inst2 = claimresponse.ClaimResponse(**data) - impl_claimresponse_4(inst2) - - -def impl_claimresponse_5(inst): - assert inst.communicationRequest[0].reference == "CommunicationRequest/fm-solicit" - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T12:09:24+00:06") - assert inst.disposition == "Claim could not be processed" - assert inst.error[0].code.coding[0].code == "a002" - assert ( - inst.error[0].code.coding[0].system - == "http://terminology.hl7.org/CodeSystem/adjudication-error" - ) - assert inst.error[0].detailSequence == 2 - assert inst.error[0].itemSequence == 3 - assert inst.formCode.coding[0].code == "2" - assert ( - inst.formCode.coding[0].system - == "http://terminology.hl7.org/CodeSystem/forms-codes" - ) - assert inst.id == "R3501" - assert inst.identifier[0].system == "http://www.BenefitsInc.com/fhir/remittance" - assert inst.identifier[0].value == "R3501" - assert inst.insurer.identifier.system == "http://www.jurisdiction.org/insurers" - assert inst.insurer.identifier.value == "555123" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "error" - assert inst.patient.reference == "Patient/1" - assert inst.processNote[0].language.coding[0].code == "en-CA" - assert inst.processNote[0].language.coding[0].system == "urn:ietf:bcp:47" - assert inst.processNote[0].number == 1 - assert inst.processNote[0].text == "Invalid claim" - assert inst.processNote[0].type == "display" - assert inst.request.reference == "Claim/100156" - assert inst.requestor.reference == "Practitioner/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the ClaimResponse that demonstrates returning " - "errors
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "oral" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_claimresponse_5(base_settings): - """No. 5 tests collection for ClaimResponse. - Test File: claimresponse-example-2.json - """ - filename = base_settings["unittest_data_dir"] / "claimresponse-example-2.json" - inst = claimresponse.ClaimResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ClaimResponse" == inst.resource_type - - impl_claimresponse_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ClaimResponse" == data["resourceType"] - - inst2 = claimresponse.ClaimResponse(**data) - impl_claimresponse_5(inst2) diff --git a/fhir/resources/tests/test_clinicalimpression.py b/fhir/resources/tests/test_clinicalimpression.py deleted file mode 100644 index d0840d3f..00000000 --- a/fhir/resources/tests/test_clinicalimpression.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ClinicalImpression -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import clinicalimpression - - -def impl_clinicalimpression_1(inst): - assert inst.assessor.reference == "Practitioner/example" - assert inst.date == fhirtypes.DateTime.validate("2014-12-06T22:33:00+11:00") - assert inst.description == ( - "This 26 yo male patient is brought into ER by ambulance " - "after being involved in a motor vehicle accident" - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2014-12-06T22:33:00+11:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2014-12-06T20:00:00+11:00" - ) - assert inst.encounter.reference == "Encounter/example" - assert inst.finding[0].itemCodeableConcept.coding[0].code == "850.0" - assert ( - inst.finding[0].itemCodeableConcept.coding[0].system - == "http://hl7.org/fhir/sid/icd-9" - ) - assert inst.id == "example" - assert inst.identifier[0].value == "12345" - assert inst.investigation[0].code.text == "Initial Examination" - assert ( - inst.investigation[0].item[0].display - == "deep laceration of the scalp (left temporo-occipital)" - ) - assert inst.investigation[0].item[1].display == "decreased level of consciousness" - assert inst.investigation[0].item[2].display == "disoriented to time and place" - assert inst.investigation[0].item[3].display == "restless" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.problem[0].display == "MVA" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.summary == ( - "provisional diagnoses of laceration of head and traumatic " - "brain injury (TBI)" - ) - assert inst.text.status == "generated" - - -def test_clinicalimpression_1(base_settings): - """No. 1 tests collection for ClinicalImpression. - Test File: clinicalimpression-example.json - """ - filename = base_settings["unittest_data_dir"] / "clinicalimpression-example.json" - inst = clinicalimpression.ClinicalImpression.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ClinicalImpression" == inst.resource_type - - impl_clinicalimpression_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ClinicalImpression" == data["resourceType"] - - inst2 = clinicalimpression.ClinicalImpression(**data) - impl_clinicalimpression_1(inst2) diff --git a/fhir/resources/tests/test_codesystem.py b/fhir/resources/tests/test_codesystem.py deleted file mode 100644 index feebe020..00000000 --- a/fhir/resources/tests/test_codesystem.py +++ /dev/null @@ -1,905 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CodeSystem -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import codesystem - - -def impl_codesystem_1(inst): - assert inst.caseSensitive is True - assert inst.concept[0].code == "source" - assert inst.concept[0].definition == ( - "This structure describes an instance passed to the mapping " - "engine that is used a source of data." - ) - assert inst.concept[0].display == "Source Structure Definition" - assert inst.concept[1].code == "queried" - assert inst.concept[1].definition == ( - "This structure describes an instance that the mapping engine" - " may ask for that is used a source of data." - ) - assert inst.concept[1].display == "Queried Structure Definition" - assert inst.concept[2].code == "target" - assert inst.concept[2].definition == ( - "This structure describes an instance passed to the mapping " - "engine that is used a target of data." - ) - assert inst.concept[2].display == "Target Structure Definition" - assert inst.concept[3].code == "produced" - assert inst.concept[3].definition == ( - "This structure describes an instance that the mapping engine" - " may ask to create that is used a target of data." - ) - assert inst.concept[3].display == "Produced Structure Definition" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.content == "complete" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "How the referenced structure is used in this mapping." - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "fhir" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 2 - assert inst.id == "map-model-mode" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.4.676" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert inst.name == "StructureMapModelMode" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "StructureMapModelMode" - assert inst.url == "http://hl7.org/fhir/map-model-mode" - assert inst.valueSet == "http://hl7.org/fhir/ValueSet/map-model-mode" - assert inst.version == "4.0.1" - - -def test_codesystem_1(base_settings): - """No. 1 tests collection for CodeSystem. - Test File: codesystem-map-model-mode.json - """ - filename = base_settings["unittest_data_dir"] / "codesystem-map-model-mode.json" - inst = codesystem.CodeSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CodeSystem" == inst.resource_type - - impl_codesystem_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CodeSystem" == data["resourceType"] - - inst2 = codesystem.CodeSystem(**data) - impl_codesystem_1(inst2) - - -def impl_codesystem_2(inst): - assert inst.caseSensitive is True - assert inst.concept[0].code == "true" - assert inst.concept[0].definition == "Boolean true." - assert inst.concept[0].display == "true" - assert inst.concept[1].code == "false" - assert inst.concept[1].definition == "Boolean false." - assert inst.concept[1].display == "false" - assert inst.concept[2].code == "trace" - assert inst.concept[2].definition == ( - "The content is greater than zero, but too small to be " "quantified." - ) - assert inst.concept[2].display == "Trace Amount Detected" - assert inst.concept[3].code == "sufficient" - assert inst.concept[3].definition == ( - "The specific quantity is not known, but is known to be non-" - "zero and is not specified because it makes up the bulk of " - "the material." - ) - assert inst.concept[3].display == "Sufficient Quantity" - assert inst.concept[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/codesystem-concept-" "comments" - ) - assert inst.concept[3].extension[0].valueString == ( - "used in formulations (e.g. 'Add 10mg of ingredient X, 50mg " - "of ingredient Y, and sufficient quantity of water to 100mL.'" - " This code would be used to express the quantity of water. )" - ) - assert inst.concept[4].code == "withdrawn" - assert inst.concept[4].definition == "The value is no longer available." - assert inst.concept[4].display == "Value Withdrawn" - assert inst.concept[5].code == "nil-known" - assert ( - inst.concept[5].definition - == "The are no known applicable values in this context." - ) - assert inst.concept[5].display == "Nil Known" - assert inst.concept[5].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/codesystem-concept-" "comments" - ) - assert ( - inst.concept[5].extension[0].valueString - == "The existence of this subject to review" - ) - assert inst.content == "complete" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - "A set of generally useful codes defined so they can be " - "included in value sets." - ) - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "fhir" - assert inst.id == "special-values" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.4.1049" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert inst.name == "SpecialValues" - assert inst.status == "draft" - assert inst.text.status == "extensions" - assert inst.title == "SpecialValues" - assert inst.url == "http://terminology.hl7.org/CodeSystem/special-values" - assert inst.valueSet == "http://hl7.org/fhir/ValueSet/special-values" - assert inst.version == "4.0.1" - - -def test_codesystem_2(base_settings): - """No. 2 tests collection for CodeSystem. - Test File: codesystem-special-values.json - """ - filename = base_settings["unittest_data_dir"] / "codesystem-special-values.json" - inst = codesystem.CodeSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CodeSystem" == inst.resource_type - - impl_codesystem_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CodeSystem" == data["resourceType"] - - inst2 = codesystem.CodeSystem(**data) - impl_codesystem_2(inst2) - - -def impl_codesystem_3(inst): - assert inst.caseSensitive is True - assert inst.concept[0].code == "unknown" - assert ( - inst.concept[0].definition - == "The communication was not done due to an unknown reason." - ) - assert inst.concept[0].display == "Unknown" - assert inst.concept[1].code == "system-error" - assert ( - inst.concept[1].definition - == "The communication was not done due to a system error." - ) - assert inst.concept[1].display == "System Error" - assert inst.concept[2].code == "invalid-phone-number" - assert inst.concept[2].definition == ( - "The communication was not done due to an invalid phone " "number." - ) - assert inst.concept[2].display == "Invalid Phone Number" - assert inst.concept[3].code == "recipient-unavailable" - assert inst.concept[3].definition == ( - "The communication was not done due to the recipient being " "unavailable." - ) - assert inst.concept[3].display == "Recipient Unavailable" - assert inst.concept[4].code == "family-objection" - assert ( - inst.concept[4].definition - == "The communication was not done due to a family objection." - ) - assert inst.concept[4].display == "Family Objection" - assert inst.concept[5].code == "patient-objection" - assert ( - inst.concept[5].definition - == "The communication was not done due to a patient objection." - ) - assert inst.concept[5].display == "Patient Objection" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.content == "complete" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert ( - inst.description == "Codes for the reason why a communication did not happen." - ) - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "pc" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "draft" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 1 - assert inst.id == "communication-not-done-reason" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.4.1077" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert inst.name == "CommunicationNotDoneReason" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "CommunicationNotDoneReason" - assert inst.url == ( - "http://terminology.hl7.org/CodeSystem/communication-not-" "done-reason" - ) - assert inst.valueSet == "http://hl7.org/fhir/ValueSet/communication-not-done-reason" - assert inst.version == "4.0.1" - - -def test_codesystem_3(base_settings): - """No. 3 tests collection for CodeSystem. - Test File: codesystem-communication-not-done-reason.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "codesystem-communication-not-done-reason.json" - ) - inst = codesystem.CodeSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CodeSystem" == inst.resource_type - - impl_codesystem_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CodeSystem" == data["resourceType"] - - inst2 = codesystem.CodeSystem(**data) - impl_codesystem_3(inst2) - - -def impl_codesystem_4(inst): - assert inst.caseSensitive is True - assert inst.concept[0].code == "grouped-by" - assert inst.concept[0].display == "Grouped By" - assert inst.concept[1].code == "is-a" - assert inst.concept[1].display == "Is-A" - assert inst.concept[2].code == "part-of" - assert inst.concept[2].definition == ( - "Child elements list the individual parts of a composite " - "whole (e.g. body site)." - ) - assert inst.concept[2].display == "Part Of" - assert inst.concept[3].code == "classified-with" - assert inst.concept[3].display == "Classified With" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.content == "complete" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert ( - inst.description == "The meaning of the hierarchy of concepts in a code system." - ) - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "vocab" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "normative" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "normative-version" - ) - assert inst.extension[2].valueCode == "4.0.0" - assert inst.extension[3].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[3].valueInteger == 5 - assert inst.id == "codesystem-hierarchy-meaning" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.4.785" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert inst.name == "CodeSystemHierarchyMeaning" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "CodeSystemHierarchyMeaning" - assert inst.url == "http://hl7.org/fhir/codesystem-hierarchy-meaning" - assert inst.valueSet == "http://hl7.org/fhir/ValueSet/codesystem-hierarchy-meaning" - assert inst.version == "4.0.1" - - -def test_codesystem_4(base_settings): - """No. 4 tests collection for CodeSystem. - Test File: codesystem-codesystem-hierarchy-meaning.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "codesystem-codesystem-hierarchy-meaning.json" - ) - inst = codesystem.CodeSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CodeSystem" == inst.resource_type - - impl_codesystem_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CodeSystem" == data["resourceType"] - - inst2 = codesystem.CodeSystem(**data) - impl_codesystem_4(inst2) - - -def impl_codesystem_5(inst): - assert inst.caseSensitive is True - assert inst.concept[0].code == "continuous" - assert inst.concept[0].definition == ( - "A medication which is expected to be continued beyond the " - "present order and which the patient should be assumed to be " - "taking unless explicitly stopped." - ) - assert inst.concept[0].display == "Continuous long term therapy" - assert inst.concept[1].code == "acute" - assert inst.concept[1].definition == ( - "A medication which the patient is only expected to consume " - "for the duration of the current order and which is not " - "expected to be renewed." - ) - assert inst.concept[1].display == "Short course (acute) therapy" - assert inst.concept[2].code == "seasonal" - assert inst.concept[2].definition == ( - "A medication which is expected to be used on a part time " - "basis at certain times of the year" - ) - assert inst.concept[2].display == "Seasonal" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.content == "complete" - assert inst.description == "MedicationRequest Course of Therapy Codes" - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "phx" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "draft" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 1 - assert inst.id == "medicationrequest-course-of-therapy" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.4.1327" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablecodesystem" - ) - assert inst.name == "medicationRequest Course of Therapy Codes" - assert inst.publisher == "FHIR Project team" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "Medication request course of therapy codes" - assert inst.url == ( - "http://terminology.hl7.org/CodeSystem/medicationrequest-" "course-of-therapy" - ) - assert inst.valueSet == ( - "http://hl7.org/fhir/ValueSet/medicationrequest-course-of-" "therapy" - ) - assert inst.version == "4.0.1" - - -def test_codesystem_5(base_settings): - """No. 5 tests collection for CodeSystem. - Test File: codesystem-medicationrequest-course-of-therapy.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "codesystem-medicationrequest-course-of-therapy.json" - ) - inst = codesystem.CodeSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CodeSystem" == inst.resource_type - - impl_codesystem_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CodeSystem" == data["resourceType"] - - inst2 = codesystem.CodeSystem(**data) - impl_codesystem_5(inst2) - - -def impl_codesystem_6(inst): - assert inst.caseSensitive is True - assert inst.concept[0].code == "0" - assert inst.concept[0].definition == ( - "The operation completed successfully (whether with warnings " "or not)." - ) - assert inst.concept[0].display == "Success" - assert inst.concept[1].code == "4" - assert inst.concept[1].definition == ( - "The action was not successful due to some kind of minor " - "failure (often equivalent to an HTTP 400 response)." - ) - assert inst.concept[1].display == "Minor failure" - assert inst.concept[2].code == "8" - assert inst.concept[2].definition == ( - "The action was not successful due to some kind of unexpected" - " error (often equivalent to an HTTP 500 response)." - ) - assert inst.concept[2].display == "Serious failure" - assert inst.concept[3].code == "12" - assert inst.concept[3].definition == ( - "An error of such magnitude occurred that the system is no " - "longer available for use (i.e. the system died)." - ) - assert inst.concept[3].display == "Major failure" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.content == "complete" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "Indicates whether the event succeeded or failed." - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "sec" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 3 - assert inst.id == "audit-event-outcome" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.4.455" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert inst.name == "AuditEventOutcome" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "AuditEventOutcome" - assert inst.url == "http://hl7.org/fhir/audit-event-outcome" - assert inst.valueSet == "http://hl7.org/fhir/ValueSet/audit-event-outcome" - assert inst.version == "4.0.1" - - -def test_codesystem_6(base_settings): - """No. 6 tests collection for CodeSystem. - Test File: codesystem-audit-event-outcome.json - """ - filename = ( - base_settings["unittest_data_dir"] / "codesystem-audit-event-outcome.json" - ) - inst = codesystem.CodeSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CodeSystem" == inst.resource_type - - impl_codesystem_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CodeSystem" == data["resourceType"] - - inst2 = codesystem.CodeSystem(**data) - impl_codesystem_6(inst2) - - -def impl_codesystem_7(inst): - assert inst.caseSensitive is True - assert inst.concept[0].code == "disclosure-ca" - assert ( - inst.concept[0].definition == "Canadian health information disclosure policy." - ) - assert inst.concept[0].display == "Disclosure-CA" - assert inst.concept[1].code == "disclosure-us" - assert ( - inst.concept[1].definition - == "United States health information disclosure policy." - ) - assert inst.concept[1].display == "Disclosure-US" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.content == "complete" - assert inst.copyright == "This is an example set." - assert inst.description == "This value set includes sample Contract Subtype codes." - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "fm" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "draft" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 1 - assert inst.id == "contract-subtype" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.4.1198" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablecodesystem" - ) - assert inst.name == "ContractSubtypeCodes" - assert inst.publisher == "Financial Management" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "Contract Subtype Codes" - assert inst.url == "http://terminology.hl7.org/CodeSystem/contractsubtypecodes" - assert inst.valueSet == "http://hl7.org/fhir/ValueSet/contract-subtype" - assert inst.version == "4.0.1" - - -def test_codesystem_7(base_settings): - """No. 7 tests collection for CodeSystem. - Test File: codesystem-contract-subtype.json - """ - filename = base_settings["unittest_data_dir"] / "codesystem-contract-subtype.json" - inst = codesystem.CodeSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CodeSystem" == inst.resource_type - - impl_codesystem_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CodeSystem" == data["resourceType"] - - inst2 = codesystem.CodeSystem(**data) - impl_codesystem_7(inst2) - - -def impl_codesystem_8(inst): - assert inst.caseSensitive is True - assert inst.concept[0].code == "create" - assert inst.concept[0].definition == ( - "create(type : string) - type is passed through to the " - "application on the standard API, and must be known by it." - ) - assert inst.concept[0].display == "create" - assert inst.concept[1].code == "copy" - assert inst.concept[1].definition == "copy(source)." - assert inst.concept[1].display == "copy" - assert inst.concept[2].code == "truncate" - assert ( - inst.concept[2].definition - == "truncate(source, length) - source must be stringy type." - ) - assert inst.concept[2].display == "truncate" - assert inst.concept[3].code == "escape" - assert inst.concept[3].definition == ( - "escape(source, fmt1, fmt2) - change source from one kind of " - "escaping to another (plain, java, xml, json). note that this" - " is for when the string itself is escaped." - ) - assert inst.concept[3].display == "escape" - assert inst.concept[4].code == "cast" - assert inst.concept[4].definition == ( - "cast(source, type?) - case source from one type to another. " - "target type can be left as implicit if there is one and only" - " one target type known." - ) - assert inst.concept[4].display == "cast" - assert inst.concept[5].code == "append" - assert ( - inst.concept[5].definition == "append(source...) - source is element or string." - ) - assert inst.concept[5].display == "append" - assert inst.concept[6].code == "translate" - assert ( - inst.concept[6].definition - == "translate(source, uri_of_map) - use the translate operation." - ) - assert inst.concept[6].display == "translate" - assert inst.concept[7].code == "reference" - assert inst.concept[7].definition == ( - "reference(source : object) - return a string that references" - " the provided tree properly." - ) - assert inst.concept[7].display == "reference" - assert inst.concept[8].code == "dateOp" - assert ( - inst.concept[8].definition - == "Perform a date operation. *Parameters to be documented*." - ) - assert inst.concept[8].display == "dateOp" - assert inst.concept[9].code == "uuid" - assert ( - inst.concept[9].definition - == "Generate a random UUID (in lowercase). No Parameters." - ) - assert inst.concept[9].display == "uuid" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.content == "complete" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "How data is copied/created." - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "fhir" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 2 - assert inst.id == "map-transform" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.4.682" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert inst.name == "StructureMapTransform" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "StructureMapTransform" - assert inst.url == "http://hl7.org/fhir/map-transform" - assert inst.valueSet == "http://hl7.org/fhir/ValueSet/map-transform" - assert inst.version == "4.0.1" - - -def test_codesystem_8(base_settings): - """No. 8 tests collection for CodeSystem. - Test File: codesystem-map-transform.json - """ - filename = base_settings["unittest_data_dir"] / "codesystem-map-transform.json" - inst = codesystem.CodeSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CodeSystem" == inst.resource_type - - impl_codesystem_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CodeSystem" == data["resourceType"] - - inst2 = codesystem.CodeSystem(**data) - impl_codesystem_8(inst2) - - -def impl_codesystem_9(inst): - assert inst.caseSensitive is True - assert inst.concept[0].code == "registered" - assert inst.concept[0].definition == ( - "The existence of the imaging study is registered, but there " - "is nothing yet available." - ) - assert inst.concept[0].display == "Registered" - assert inst.concept[1].code == "available" - assert inst.concept[1].definition == ( - "At least one instance has been associated with this imaging " "study." - ) - assert inst.concept[1].display == "Available" - assert inst.concept[2].code == "cancelled" - assert inst.concept[2].definition == ( - "The imaging study is unavailable because the imaging study " - "was not started or not completed (also sometimes called " - '"aborted").' - ) - assert inst.concept[2].display == "Cancelled" - assert inst.concept[3].code == "entered-in-error" - assert inst.concept[3].display == "Entered in Error" - assert inst.concept[4].code == "unknown" - assert inst.concept[4].display == "Unknown" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.content == "complete" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "The status of the ImagingStudy." - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "ii" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 3 - assert inst.id == "imagingstudy-status" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.4.991" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert inst.name == "ImagingStudyStatus" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "ImagingStudyStatus" - assert inst.url == "http://hl7.org/fhir/imagingstudy-status" - assert inst.valueSet == "http://hl7.org/fhir/ValueSet/imagingstudy-status" - assert inst.version == "4.0.1" - - -def test_codesystem_9(base_settings): - """No. 9 tests collection for CodeSystem. - Test File: codesystem-imagingstudy-status.json - """ - filename = ( - base_settings["unittest_data_dir"] / "codesystem-imagingstudy-status.json" - ) - inst = codesystem.CodeSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CodeSystem" == inst.resource_type - - impl_codesystem_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CodeSystem" == data["resourceType"] - - inst2 = codesystem.CodeSystem(**data) - impl_codesystem_9(inst2) - - -def impl_codesystem_10(inst): - assert inst.caseSensitive is True - assert inst.concept[0].code == "benefit" - assert inst.concept[0].definition == "Maximum benefit allowable." - assert inst.concept[0].display == "Benefit" - assert inst.concept[1].code == "deductible" - assert ( - inst.concept[1].definition == "Cost to be incurred before benefits are applied" - ) - assert inst.concept[1].display == "Deductible" - assert inst.concept[2].code == "visit" - assert inst.concept[2].definition == "Service visit" - assert inst.concept[2].display == "Visit" - assert inst.concept[3].code == "room" - assert inst.concept[3].definition == "Type of room" - assert inst.concept[3].display == "Room" - assert inst.concept[4].code == "copay" - assert inst.concept[4].definition == "Copayment per service" - assert inst.concept[4].display == "Copayment per service" - assert inst.concept[5].code == "copay-percent" - assert inst.concept[5].definition == "Copayment percentage per service" - assert inst.concept[5].display == "Copayment Percent per service" - assert inst.concept[6].code == "copay-maximum" - assert inst.concept[6].definition == "Copayment maximum per service" - assert inst.concept[6].display == "Copayment maximum per service" - assert inst.concept[7].code == "vision-exam" - assert inst.concept[7].definition == "Vision Exam" - assert inst.concept[7].display == "Vision Exam" - assert inst.concept[8].code == "vision-glasses" - assert inst.concept[8].definition == "Frames and lenses" - assert inst.concept[8].display == "Vision Glasses" - assert inst.concept[9].code == "vision-contacts" - assert inst.concept[9].definition == "Contact Lenses" - assert inst.concept[9].display == "Vision Contacts Coverage" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.content == "complete" - assert inst.copyright == "This is an example set." - assert ( - inst.description - == "This value set includes a smattering of Benefit type codes." - ) - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "fm" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "draft" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 1 - assert inst.id == "benefit-type" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.4.1176" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablecodesystem" - ) - assert inst.name == "BenefitTypeCodes" - assert inst.publisher == "Financial Management" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "Benefit Type Codes" - assert inst.url == "http://terminology.hl7.org/CodeSystem/benefit-type" - assert inst.valueSet == "http://hl7.org/fhir/ValueSet/benefit-type" - assert inst.version == "4.0.1" - - -def test_codesystem_10(base_settings): - """No. 10 tests collection for CodeSystem. - Test File: codesystem-benefit-type.json - """ - filename = base_settings["unittest_data_dir"] / "codesystem-benefit-type.json" - inst = codesystem.CodeSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CodeSystem" == inst.resource_type - - impl_codesystem_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CodeSystem" == data["resourceType"] - - inst2 = codesystem.CodeSystem(**data) - impl_codesystem_10(inst2) diff --git a/fhir/resources/tests/test_communication.py b/fhir/resources/tests/test_communication.py deleted file mode 100644 index dc8afaf9..00000000 --- a/fhir/resources/tests/test_communication.py +++ /dev/null @@ -1,207 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Communication -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import communication - - -def impl_communication_1(inst): - assert inst.about[0].identifier.system == "http://happyvalley.com/claim" - assert inst.about[0].identifier.value == "12345" - assert ( - inst.about[1].identifier.system - == "http://www.BenefitsInc.com/fhir/claimresponse" - ) - assert inst.about[1].identifier.value == "R3500" - assert inst.category[0].coding[0].code == "SolicitedAttachment" - assert inst.category[0].coding[0].system == "http://acme.org/messagetypes" - assert inst.id == "fm-attachment" - assert inst.identifier[0].system == "http://www.providerco.com/communication" - assert inst.identifier[0].value == "12345" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.payload[0].contentAttachment.contentType == "application/pdf" - assert inst.payload[0].contentAttachment.creation == fhirtypes.DateTime.validate( - "2010-02-01T11:50:23-05:00" - ) - assert inst.payload[0].contentAttachment.data == bytes_validator("SGVsbG8=") - assert inst.payload[0].contentAttachment.title == "accident notes 20100201.pdf" - assert inst.payload[1].contentAttachment.contentType == "application/pdf" - assert inst.payload[1].contentAttachment.creation == fhirtypes.DateTime.validate( - "2010-02-01T10:57:34+01:00" - ) - assert inst.payload[1].contentAttachment.hash == bytes_validator("SGVsbG8gdGhlcmU=") - assert inst.payload[1].contentAttachment.size == 104274 - assert inst.payload[1].contentAttachment.url == "http://example.org/docs/AB12345" - assert inst.recipient[0].identifier.system == "http://www.jurisdiction.com/insurer" - assert inst.recipient[0].identifier.value == "123456" - assert ( - inst.sender.identifier.system == "http://www.jurisdiction.com/provideroffices" - ) - assert inst.sender.identifier.value == "3456" - assert inst.sent == fhirtypes.DateTime.validate("2016-06-12T18:01:10-08:00") - assert inst.status == "completed" - assert inst.subject.reference == "Patient/1" - assert inst.text.div == ( - '
Attachment which' - " is unsolicited
" - ) - assert inst.text.status == "generated" - - -def test_communication_1(base_settings): - """No. 1 tests collection for Communication. - Test File: communication-example-fm-attachment.json - """ - filename = ( - base_settings["unittest_data_dir"] / "communication-example-fm-attachment.json" - ) - inst = communication.Communication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Communication" == inst.resource_type - - impl_communication_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Communication" == data["resourceType"] - - inst2 = communication.Communication(**data) - impl_communication_1(inst2) - - -def impl_communication_2(inst): - assert inst.basedOn[0].reference == "#request" - assert inst.category[0].coding[0].code == "SolicitedAttachment" - assert inst.category[0].coding[0].system == "http://acme.org/messagetypes" - assert inst.contained[0].id == "provider" - assert inst.contained[1].id == "payor" - assert inst.contained[2].id == "request" - assert inst.id == "fm-solicited" - assert inst.identifier[0].system == "http://www.providerco.com/communication" - assert inst.identifier[0].value == "12345" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.payload[0].contentAttachment.contentType == "application/pdf" - assert inst.payload[0].contentAttachment.creation == fhirtypes.DateTime.validate( - "2010-02-01T11:50:23-05:00" - ) - assert inst.payload[0].contentAttachment.data == bytes_validator("SGVsbG8=") - assert inst.payload[0].contentAttachment.title == "accident notes 20100201.pdf" - assert inst.payload[1].contentAttachment.contentType == "application/pdf" - assert inst.payload[1].contentAttachment.creation == fhirtypes.DateTime.validate( - "2010-02-01T10:57:34+01:00" - ) - assert inst.payload[1].contentAttachment.hash == bytes_validator("SGVsbG8gdGhlcmU=") - assert inst.payload[1].contentAttachment.size == 104274 - assert ( - inst.payload[1].contentAttachment.url == "http://happyvalley.com/docs/AB12345" - ) - assert inst.recipient[0].reference == "#payor" - assert inst.sender.reference == "#provider" - assert inst.sent == fhirtypes.DateTime.validate("2016-06-12T18:01:10-08:00") - assert inst.status == "completed" - assert inst.subject.reference == "Patient/1" - assert inst.text.div == ( - '
Attachment in ' - "response to a Request
" - ) - assert inst.text.status == "generated" - - -def test_communication_2(base_settings): - """No. 2 tests collection for Communication. - Test File: communication-example-fm-solicited-attachment.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "communication-example-fm-solicited-attachment.json" - ) - inst = communication.Communication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Communication" == inst.resource_type - - impl_communication_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Communication" == data["resourceType"] - - inst2 = communication.Communication(**data) - impl_communication_2(inst2) - - -def impl_communication_3(inst): - assert inst.category[0].coding[0].code == "Alert" - assert inst.category[0].coding[0].system == "http://acme.org/messagetypes" - assert inst.category[0].text == "Alert" - assert inst.encounter.reference == "Encounter/example" - assert inst.id == "example" - assert inst.identifier[0].system == "urn:oid:1.3.4.5.6.7" - assert inst.identifier[0].type.text == "Paging System" - assert inst.identifier[0].value == "2345678901" - assert inst.instantiatesUri[0] == "http://example.org/hyperkalemia" - assert inst.medium[0].coding[0].code == "WRITTEN" - assert inst.medium[0].coding[0].display == "written" - assert ( - inst.medium[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationMode" - ) - assert inst.medium[0].text == "written" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.partOf[0].display == "Serum Potassium Observation" - assert inst.payload[0].contentString == ( - "Patient 1 has a very high serum potassium value (7.2 mmol/L " - "on 2014-Dec-12 at 5:55 pm)" - ) - assert inst.payload[1].contentReference.display == "Serum Potassium Observation" - assert inst.received == fhirtypes.DateTime.validate("2014-12-12T18:01:11-08:00") - assert inst.recipient[0].reference == "Practitioner/example" - assert inst.sender.reference == "Device/f001" - assert inst.sent == fhirtypes.DateTime.validate("2014-12-12T18:01:10-08:00") - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Patient has very' - " high serum potassium
" - ) - assert inst.text.status == "generated" - - -def test_communication_3(base_settings): - """No. 3 tests collection for Communication. - Test File: communication-example.json - """ - filename = base_settings["unittest_data_dir"] / "communication-example.json" - inst = communication.Communication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Communication" == inst.resource_type - - impl_communication_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Communication" == data["resourceType"] - - inst2 = communication.Communication(**data) - impl_communication_3(inst2) diff --git a/fhir/resources/tests/test_communicationrequest.py b/fhir/resources/tests/test_communicationrequest.py deleted file mode 100644 index 1d646a8a..00000000 --- a/fhir/resources/tests/test_communicationrequest.py +++ /dev/null @@ -1,116 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CommunicationRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import communicationrequest - - -def impl_communicationrequest_1(inst): - assert inst.encounter.reference == "Encounter/example" - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "active" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
To be filled out' - " at a later time
" - ) - assert inst.text.status == "generated" - - -def test_communicationrequest_1(base_settings): - """No. 1 tests collection for CommunicationRequest. - Test File: communicationrequest-example.json - """ - filename = base_settings["unittest_data_dir"] / "communicationrequest-example.json" - inst = communicationrequest.CommunicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CommunicationRequest" == inst.resource_type - - impl_communicationrequest_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CommunicationRequest" == data["resourceType"] - - inst2 = communicationrequest.CommunicationRequest(**data) - impl_communicationrequest_1(inst2) - - -def impl_communicationrequest_2(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2016-06-10T11:01:10-08:00") - assert inst.basedOn[0].display == "EligibilityRequest" - assert inst.category[0].coding[0].code == "SolicitedAttachmentRequest" - assert inst.category[0].coding[0].system == "http://acme.org/messagetypes" - assert inst.contained[0].id == "provider" - assert inst.contained[1].id == "payor" - assert inst.contained[2].id == "requester" - assert inst.encounter.reference == "Encounter/example" - assert inst.groupIdentifier.value == "12345" - assert inst.id == "fm-solicit" - assert inst.identifier[0].system == "http://www.jurisdiction.com/insurer/123456" - assert inst.identifier[0].value == "ABC123" - assert inst.medium[0].coding[0].code == "WRITTEN" - assert inst.medium[0].coding[0].display == "written" - assert ( - inst.medium[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationMode" - ) - assert inst.medium[0].text == "written" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2016-06-10T11:01:10-08:00" - ) - assert inst.payload[0].contentString == ( - "Please provide the accident report and any associated " - "pictures to support your Claim# DEF5647." - ) - assert inst.priority == "routine" - assert inst.recipient[0].reference == "#provider" - assert inst.replaces[0].display == "prior CommunicationRequest" - assert inst.requester.reference == "#requester" - assert inst.sender.reference == "#payor" - assert inst.status == "active" - assert inst.text.div == ( - '
Request for ' "Accident Report
" - ) - assert inst.text.status == "generated" - - -def test_communicationrequest_2(base_settings): - """No. 2 tests collection for CommunicationRequest. - Test File: communicationrequest-example-fm-solicit-attachment.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "communicationrequest-example-fm-solicit-attachment.json" - ) - inst = communicationrequest.CommunicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CommunicationRequest" == inst.resource_type - - impl_communicationrequest_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CommunicationRequest" == data["resourceType"] - - inst2 = communicationrequest.CommunicationRequest(**data) - impl_communicationrequest_2(inst2) diff --git a/fhir/resources/tests/test_compartmentdefinition.py b/fhir/resources/tests/test_compartmentdefinition.py deleted file mode 100644 index 5e461cd1..00000000 --- a/fhir/resources/tests/test_compartmentdefinition.py +++ /dev/null @@ -1,350 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CompartmentDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import compartmentdefinition - - -def impl_compartmentdefinition_1(inst): - assert inst.code == "Device" - assert inst.contact[0].name == "[string]" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2017-02-24T12:09:24+00:06") - assert inst.description == ( - "The set of resources associated with a particular Device " - "(example with Communication and CommunicationRequest " - "resourses only)." - ) - assert inst.experimental is True - assert inst.id == "example" - assert inst.name == "EXAMPLE" - assert inst.publisher == "Health Level Seven International (FHIR Infrastructure)" - assert inst.purpose == ( - "Provides an example of a FHIR compartment definition based " - "on the Device resource type." - ) - assert inst.resource[0].code == "Communication" - assert ( - inst.resource[0].documentation - == "The device used as the message sender and recipient" - ) - assert inst.resource[0].param[0] == "sender" - assert inst.resource[0].param[1] == "recipient" - assert inst.resource[1].code == "CommunicationRequest" - assert ( - inst.resource[1].documentation - == "The device used as the message sender and recipient" - ) - assert inst.resource[1].param[0] == "sender" - assert inst.resource[1].param[1] == "recipient" - assert inst.search is True - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/CompartmentDefinition/example" - assert inst.useContext[0].code.code == "focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "Device" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/resource-types" - ) - - -def test_compartmentdefinition_1(base_settings): - """No. 1 tests collection for CompartmentDefinition. - Test File: compartmentdefinition-example.json - """ - filename = base_settings["unittest_data_dir"] / "compartmentdefinition-example.json" - inst = compartmentdefinition.CompartmentDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CompartmentDefinition" == inst.resource_type - - impl_compartmentdefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CompartmentDefinition" == data["resourceType"] - - inst2 = compartmentdefinition.CompartmentDefinition(**data) - impl_compartmentdefinition_1(inst2) - - -def impl_compartmentdefinition_2(inst): - assert inst.code == "RelatedPerson" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.experimental is True - assert inst.id == "relatedPerson" - assert inst.name == "Base FHIR compartment definition for RelatedPerson" - assert inst.publisher == "FHIR Project Team" - assert inst.resource[0].code == "Account" - assert inst.resource[1].code == "ActivityDefinition" - assert inst.resource[2].code == "AdverseEvent" - assert inst.resource[2].param[0] == "recorder" - assert inst.resource[3].code == "AllergyIntolerance" - assert inst.resource[3].param[0] == "asserter" - assert inst.resource[4].code == "Appointment" - assert inst.resource[4].param[0] == "actor" - assert inst.resource[5].code == "AppointmentResponse" - assert inst.resource[5].param[0] == "actor" - assert inst.resource[6].code == "AuditEvent" - assert inst.resource[7].code == "Basic" - assert inst.resource[7].param[0] == "author" - assert inst.resource[8].code == "Binary" - assert inst.resource[9].code == "BiologicallyDerivedProduct" - assert inst.search is True - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/CompartmentDefinition/relatedPerson" - assert inst.version == "4.0.1" - - -def test_compartmentdefinition_2(base_settings): - """No. 2 tests collection for CompartmentDefinition. - Test File: compartmentdefinition-relatedperson.json - """ - filename = ( - base_settings["unittest_data_dir"] / "compartmentdefinition-relatedperson.json" - ) - inst = compartmentdefinition.CompartmentDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CompartmentDefinition" == inst.resource_type - - impl_compartmentdefinition_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CompartmentDefinition" == data["resourceType"] - - inst2 = compartmentdefinition.CompartmentDefinition(**data) - impl_compartmentdefinition_2(inst2) - - -def impl_compartmentdefinition_3(inst): - assert inst.code == "Patient" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.experimental is True - assert inst.id == "patient" - assert inst.name == "Base FHIR compartment definition for Patient" - assert inst.publisher == "FHIR Project Team" - assert inst.resource[0].code == "Account" - assert inst.resource[0].param[0] == "subject" - assert inst.resource[1].code == "ActivityDefinition" - assert inst.resource[2].code == "AdverseEvent" - assert inst.resource[2].param[0] == "subject" - assert inst.resource[3].code == "AllergyIntolerance" - assert inst.resource[3].param[0] == "patient" - assert inst.resource[3].param[1] == "recorder" - assert inst.resource[3].param[2] == "asserter" - assert inst.resource[4].code == "Appointment" - assert inst.resource[4].param[0] == "actor" - assert inst.resource[5].code == "AppointmentResponse" - assert inst.resource[5].param[0] == "actor" - assert inst.resource[6].code == "AuditEvent" - assert inst.resource[6].param[0] == "patient" - assert inst.resource[7].code == "Basic" - assert inst.resource[7].param[0] == "patient" - assert inst.resource[7].param[1] == "author" - assert inst.resource[8].code == "Binary" - assert inst.resource[9].code == "BiologicallyDerivedProduct" - assert inst.search is True - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/CompartmentDefinition/patient" - assert inst.version == "4.0.1" - - -def test_compartmentdefinition_3(base_settings): - """No. 3 tests collection for CompartmentDefinition. - Test File: compartmentdefinition-patient.json - """ - filename = base_settings["unittest_data_dir"] / "compartmentdefinition-patient.json" - inst = compartmentdefinition.CompartmentDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CompartmentDefinition" == inst.resource_type - - impl_compartmentdefinition_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CompartmentDefinition" == data["resourceType"] - - inst2 = compartmentdefinition.CompartmentDefinition(**data) - impl_compartmentdefinition_3(inst2) - - -def impl_compartmentdefinition_4(inst): - assert inst.code == "Practitioner" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.experimental is True - assert inst.id == "practitioner" - assert inst.name == "Base FHIR compartment definition for Practitioner" - assert inst.publisher == "FHIR Project Team" - assert inst.resource[0].code == "Account" - assert inst.resource[0].param[0] == "subject" - assert inst.resource[1].code == "ActivityDefinition" - assert inst.resource[2].code == "AdverseEvent" - assert inst.resource[2].param[0] == "recorder" - assert inst.resource[3].code == "AllergyIntolerance" - assert inst.resource[3].param[0] == "recorder" - assert inst.resource[3].param[1] == "asserter" - assert inst.resource[4].code == "Appointment" - assert inst.resource[4].param[0] == "actor" - assert inst.resource[5].code == "AppointmentResponse" - assert inst.resource[5].param[0] == "actor" - assert inst.resource[6].code == "AuditEvent" - assert inst.resource[6].param[0] == "agent" - assert inst.resource[7].code == "Basic" - assert inst.resource[7].param[0] == "author" - assert inst.resource[8].code == "Binary" - assert inst.resource[9].code == "BiologicallyDerivedProduct" - assert inst.search is True - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/CompartmentDefinition/practitioner" - assert inst.version == "4.0.1" - - -def test_compartmentdefinition_4(base_settings): - """No. 4 tests collection for CompartmentDefinition. - Test File: compartmentdefinition-practitioner.json - """ - filename = ( - base_settings["unittest_data_dir"] / "compartmentdefinition-practitioner.json" - ) - inst = compartmentdefinition.CompartmentDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CompartmentDefinition" == inst.resource_type - - impl_compartmentdefinition_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CompartmentDefinition" == data["resourceType"] - - inst2 = compartmentdefinition.CompartmentDefinition(**data) - impl_compartmentdefinition_4(inst2) - - -def impl_compartmentdefinition_5(inst): - assert inst.code == "Encounter" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.experimental is True - assert inst.id == "encounter" - assert inst.name == "Base FHIR compartment definition for Encounter" - assert inst.publisher == "FHIR Project Team" - assert inst.resource[0].code == "Account" - assert inst.resource[1].code == "ActivityDefinition" - assert inst.resource[2].code == "AdverseEvent" - assert inst.resource[3].code == "AllergyIntolerance" - assert inst.resource[4].code == "Appointment" - assert inst.resource[5].code == "AppointmentResponse" - assert inst.resource[6].code == "AuditEvent" - assert inst.resource[7].code == "Basic" - assert inst.resource[8].code == "Binary" - assert inst.resource[9].code == "BiologicallyDerivedProduct" - assert inst.search is True - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/CompartmentDefinition/encounter" - assert inst.version == "4.0.1" - - -def test_compartmentdefinition_5(base_settings): - """No. 5 tests collection for CompartmentDefinition. - Test File: compartmentdefinition-encounter.json - """ - filename = ( - base_settings["unittest_data_dir"] / "compartmentdefinition-encounter.json" - ) - inst = compartmentdefinition.CompartmentDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CompartmentDefinition" == inst.resource_type - - impl_compartmentdefinition_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CompartmentDefinition" == data["resourceType"] - - inst2 = compartmentdefinition.CompartmentDefinition(**data) - impl_compartmentdefinition_5(inst2) - - -def impl_compartmentdefinition_6(inst): - assert inst.code == "Device" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - "There is an instance of the device compartment for each " - "Device resource, and the identity of the compartment is the " - "same as the Device. The set of resources associated with a " - "particular device" - ) - assert inst.experimental is True - assert inst.id == "device" - assert inst.name == "Base FHIR compartment definition for Device" - assert inst.publisher == "FHIR Project Team" - assert inst.resource[0].code == "Account" - assert inst.resource[0].param[0] == "subject" - assert inst.resource[1].code == "ActivityDefinition" - assert inst.resource[2].code == "AdverseEvent" - assert inst.resource[3].code == "AllergyIntolerance" - assert inst.resource[4].code == "Appointment" - assert inst.resource[4].param[0] == "actor" - assert inst.resource[5].code == "AppointmentResponse" - assert inst.resource[5].param[0] == "actor" - assert inst.resource[6].code == "AuditEvent" - assert inst.resource[6].param[0] == "agent" - assert inst.resource[7].code == "Basic" - assert inst.resource[8].code == "Binary" - assert inst.resource[9].code == "BiologicallyDerivedProduct" - assert inst.search is True - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/CompartmentDefinition/device" - assert inst.version == "4.0.1" - - -def test_compartmentdefinition_6(base_settings): - """No. 6 tests collection for CompartmentDefinition. - Test File: compartmentdefinition-device.json - """ - filename = base_settings["unittest_data_dir"] / "compartmentdefinition-device.json" - inst = compartmentdefinition.CompartmentDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CompartmentDefinition" == inst.resource_type - - impl_compartmentdefinition_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CompartmentDefinition" == data["resourceType"] - - inst2 = compartmentdefinition.CompartmentDefinition(**data) - impl_compartmentdefinition_6(inst2) diff --git a/fhir/resources/tests/test_composition.py b/fhir/resources/tests/test_composition.py deleted file mode 100644 index 2bd4ec9a..00000000 --- a/fhir/resources/tests/test_composition.py +++ /dev/null @@ -1,178 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Composition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import composition - - -def impl_composition_1(inst): - assert inst.attester[0].mode == "legal" - assert inst.attester[0].party.display == "Harold Hippocrates, MD" - assert inst.attester[0].party.reference == "Practitioner/xcda-author" - assert inst.attester[0].time == fhirtypes.DateTime.validate("2012-01-04T09:10:14Z") - assert inst.author[0].display == "Harold Hippocrates, MD" - assert inst.author[0].reference == "Practitioner/xcda-author" - assert inst.category[0].coding[0].code == "LP173421-1" - assert inst.category[0].coding[0].display == "Report" - assert inst.category[0].coding[0].system == "http://loinc.org" - assert inst.confidentiality == "N" - assert inst.custodian.display == "Good Health Clinic" - assert inst.custodian.reference == "Organization/2.16.840.1.113883.19.5" - assert inst.date == fhirtypes.DateTime.validate("2018-10-30T16:56:04+11:00") - assert inst.id == "example-mixed" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.section[0].code.coding[0].code == "newborn" - assert inst.section[0].code.coding[0].display == "New Born Details" - assert inst.section[0].code.coding[0].system == "http://acme.org/codes/SectionType" - assert inst.section[0].text.status == "generated" - assert inst.section[0].title == "Child's Details" - assert inst.section[1].code.coding[0].code == "mother" - assert inst.section[1].code.coding[0].display == "Mother's Details" - assert inst.section[1].code.coding[0].system == "http://acme.org/codes/SectionType" - assert inst.section[1].text.status == "generated" - assert inst.section[1].title == "Mpther's Details" - assert inst.status == "final" - assert inst.subject.display == "Tahlia Smith" - assert inst.subject.reference == "Patient/newborn" - assert inst.text.status == "generated" - assert inst.title == "Discharge Summary (Neonatal Service)" - assert inst.type.coding[0].code == "78418-1" - assert ( - inst.type.coding[0].display == "Neonatal perinatal medicine Discharge summary" - ) - assert inst.type.coding[0].system == "http://loinc.org" - - -def test_composition_1(base_settings): - """No. 1 tests collection for Composition. - Test File: composition-example-mixed.json - """ - filename = base_settings["unittest_data_dir"] / "composition-example-mixed.json" - inst = composition.Composition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Composition" == inst.resource_type - - impl_composition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Composition" == data["resourceType"] - - inst2 = composition.Composition(**data) - impl_composition_1(inst2) - - -def impl_composition_2(inst): - assert inst.attester[0].mode == "legal" - assert inst.attester[0].party.display == "Harold Hippocrates, MD" - assert inst.attester[0].party.reference == "Practitioner/xcda-author" - assert inst.attester[0].time == fhirtypes.DateTime.validate("2012-01-04T09:10:14Z") - assert inst.author[0].display == "Harold Hippocrates, MD" - assert inst.author[0].reference == "Practitioner/xcda-author" - assert inst.category[0].coding[0].code == "LP173421-1" - assert inst.category[0].coding[0].display == "Report" - assert inst.category[0].coding[0].system == "http://loinc.org" - assert inst.confidentiality == "N" - assert inst.custodian.display == "Good Health Clinic" - assert inst.custodian.reference == "Organization/2.16.840.1.113883.19.5" - assert inst.date == fhirtypes.DateTime.validate("2012-01-04T09:10:14Z") - assert inst.encounter.reference == "Encounter/xcda" - assert inst.event[0].code[0].coding[0].code == "HEALTHREC" - assert inst.event[0].code[0].coding[0].display == "health record" - assert ( - inst.event[0].code[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.event[0].detail[0].reference == "Observation/example" - assert inst.event[0].period.end == fhirtypes.DateTime.validate( - "2012-11-12T12:09:24+00:06" - ) - assert inst.event[0].period.start == fhirtypes.DateTime.validate( - "2010-07-18T12:09:24+00:06" - ) - assert inst.id == "example" - assert inst.identifier.system == "http://healthintersections.com.au/test" - assert inst.identifier.value == "1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.relatesTo[0].code == "replaces" - assert inst.relatesTo[0].targetReference.reference == "Composition/old-example" - assert inst.relatesTo[1].code == "appends" - assert ( - inst.relatesTo[1].targetIdentifier.system - == "http://example.org/fhir/NamingSystem/document-ids" - ) - assert inst.relatesTo[1].targetIdentifier.value == "ABC123" - assert inst.section[0].code.coding[0].code == "11348-0" - assert inst.section[0].code.coding[0].display == "History of past illness Narrative" - assert inst.section[0].code.coding[0].system == "http://loinc.org" - assert inst.section[0].entry[0].reference == "Condition/stroke" - assert inst.section[0].entry[1].reference == "Condition/example" - assert inst.section[0].entry[2].reference == "Condition/example2" - assert inst.section[0].mode == "snapshot" - assert inst.section[0].orderedBy.coding[0].code == "event-date" - assert inst.section[0].orderedBy.coding[0].display == "Sorted by Event Date" - assert ( - inst.section[0].orderedBy.coding[0].system - == "http://terminology.hl7.org/CodeSystem/list-order" - ) - assert inst.section[0].text.status == "generated" - assert inst.section[0].title == "History of present illness" - assert inst.section[1].code.coding[0].code == "10157-6" - assert ( - inst.section[1].code.coding[0].display - == "History of family member diseases Narrative" - ) - assert inst.section[1].code.coding[0].system == "http://loinc.org" - assert inst.section[1].emptyReason.coding[0].code == "withheld" - assert inst.section[1].emptyReason.coding[0].display == "Information Withheld" - assert ( - inst.section[1].emptyReason.coding[0].system - == "http://terminology.hl7.org/CodeSystem/list-empty-reason" - ) - assert inst.section[1].mode == "snapshot" - assert inst.section[1].text.status == "generated" - assert inst.section[1].title == "History of family member diseases" - assert inst.status == "final" - assert inst.subject.display == "Henry Levin the 7th" - assert inst.subject.reference == "Patient/xcda" - assert inst.text.status == "generated" - assert inst.title == "Consultation Note" - assert inst.type.coding[0].code == "11488-4" - assert inst.type.coding[0].display == "Consult note" - assert inst.type.coding[0].system == "http://loinc.org" - - -def test_composition_2(base_settings): - """No. 2 tests collection for Composition. - Test File: composition-example.json - """ - filename = base_settings["unittest_data_dir"] / "composition-example.json" - inst = composition.Composition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Composition" == inst.resource_type - - impl_composition_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Composition" == data["resourceType"] - - inst2 = composition.Composition(**data) - impl_composition_2(inst2) diff --git a/fhir/resources/tests/test_conceptmap.py b/fhir/resources/tests/test_conceptmap.py deleted file mode 100644 index c03d08f4..00000000 --- a/fhir/resources/tests/test_conceptmap.py +++ /dev/null @@ -1,558 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ConceptMap -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import conceptmap - - -def impl_conceptmap_1(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - 'Canonical Mapping for "The lifecycle status of an ' 'artifact."' - ) - assert inst.group[0].element[0].code == "entered-in-error" - assert inst.group[0].element[0].target[0].code == "error" - assert inst.group[0].element[0].target[0].equivalence == "equivalent" - assert inst.group[0].element[1].code == "draft" - assert inst.group[0].element[1].target[0].code == "draft" - assert inst.group[0].element[1].target[0].equivalence == "equivalent" - assert inst.group[0].element[2].code == "active" - assert inst.group[0].element[2].target[0].code == "active" - assert inst.group[0].element[2].target[0].equivalence == "equivalent" - assert inst.group[0].element[3].code == "retired" - assert inst.group[0].element[3].target[0].code == "inactive" - assert inst.group[0].element[3].target[0].equivalence == "equivalent" - assert inst.group[0].element[4].code == "unknown" - assert inst.group[0].element[4].target[0].code == "unknown" - assert inst.group[0].element[4].target[0].equivalence == "equivalent" - assert inst.group[0].source == "http://hl7.org/fhir/publication-status" - assert inst.group[0].target == "http://hl7.org/fhir/resource-status" - assert inst.id == "sc-publication-status" - assert inst.name == "PublicationStatusCanonicalMap" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.sourceCanonical == "http://hl7.org/fhir/ValueSet/publication-status" - assert inst.status == "draft" - assert inst.targetCanonical == "http://hl7.org/fhir/ValueSet/resource-status" - assert inst.text.status == "generated" - assert inst.title == 'Canonical Mapping for "PublicationStatus"' - assert inst.url == "http://hl7.org/fhir/ConceptMap/sc-publication-status" - assert inst.version == "4.0.1" - - -def test_conceptmap_1(base_settings): - """No. 1 tests collection for ConceptMap. - Test File: sc-valueset-publication-status.json - """ - filename = ( - base_settings["unittest_data_dir"] / "sc-valueset-publication-status.json" - ) - inst = conceptmap.ConceptMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ConceptMap" == inst.resource_type - - impl_conceptmap_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ConceptMap" == data["resourceType"] - - inst2 = conceptmap.ConceptMap(**data) - impl_conceptmap_1(inst2) - - -def impl_conceptmap_2(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.group[0].element[0].code == "home" - assert inst.group[0].element[0].target[0].code == "H" - assert inst.group[0].element[0].target[0].equivalence == "equal" - assert inst.group[0].element[1].code == "work" - assert inst.group[0].element[1].target[0].code == "WP" - assert inst.group[0].element[1].target[0].equivalence == "equal" - assert inst.group[0].element[2].code == "temp" - assert inst.group[0].element[2].target[0].code == "TMP" - assert inst.group[0].element[2].target[0].equivalence == "equal" - assert inst.group[0].element[3].code == "old" - assert inst.group[0].element[3].target[0].code == "OLD" - assert inst.group[0].element[3].target[0].comment == "Bad or Old" - assert inst.group[0].element[3].target[0].equivalence == "narrower" - assert inst.group[0].element[3].target[1].code == "BAD" - assert inst.group[0].element[3].target[1].comment == "Bad or Old" - assert inst.group[0].element[3].target[1].equivalence == "narrower" - assert inst.group[0].source == "http://hl7.org/fhir/address-use" - assert inst.group[0].target == "http://terminology.hl7.org/CodeSystem/v3-AddressUse" - assert inst.id == "cm-address-use-v3" - assert inst.name == "v3.AddressUse" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.sourceCanonical == "http://hl7.org/fhir/ValueSet/address-use" - assert inst.status == "draft" - assert inst.targetCanonical == "http://terminology.hl7.org/ValueSet/v3-AddressUse" - assert inst.text.status == "generated" - assert inst.title == "v3 map for AddressUse" - assert inst.url == "http://hl7.org/fhir/ConceptMap/cm-address-use-v3" - assert inst.version == "4.0.1" - - -def test_conceptmap_2(base_settings): - """No. 2 tests collection for ConceptMap. - Test File: cm-address-use-v3.json - """ - filename = base_settings["unittest_data_dir"] / "cm-address-use-v3.json" - inst = conceptmap.ConceptMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ConceptMap" == inst.resource_type - - impl_conceptmap_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ConceptMap" == data["resourceType"] - - inst2 = conceptmap.ConceptMap(**data) - impl_conceptmap_2(inst2) - - -def impl_conceptmap_3(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - 'Canonical Mapping for "This value set includes Status ' 'codes."' - ) - assert inst.group[0].element[0].code == "entered-in-error" - assert inst.group[0].element[0].target[0].code == "error" - assert inst.group[0].element[0].target[0].equivalence == "equivalent" - assert inst.group[0].element[1].code == "draft" - assert inst.group[0].element[1].target[0].code == "draft" - assert inst.group[0].element[1].target[0].equivalence == "equivalent" - assert inst.group[0].element[2].code == "active" - assert inst.group[0].element[2].target[0].code == "active" - assert inst.group[0].element[2].target[0].equivalence == "equivalent" - assert inst.group[0].element[3].code == "cancelled" - assert inst.group[0].element[3].target[0].code == "abandoned" - assert inst.group[0].element[3].target[0].equivalence == "equivalent" - assert inst.group[0].source == "http://hl7.org/fhir/fm-status" - assert inst.group[0].target == "http://hl7.org/fhir/resource-status" - assert inst.id == "sc-fm-status" - assert inst.name == "FinancialResourceStatusCodesCanonicalMap" - assert inst.publisher == "Financial Management" - assert inst.sourceCanonical == "http://hl7.org/fhir/ValueSet/fm-status" - assert inst.status == "draft" - assert inst.targetCanonical == "http://hl7.org/fhir/ValueSet/resource-status" - assert inst.text.status == "generated" - assert inst.title == 'Canonical Mapping for "Financial Resource Status Codes"' - assert inst.url == "http://hl7.org/fhir/ConceptMap/sc-fm-status" - assert inst.version == "4.0.1" - - -def test_conceptmap_3(base_settings): - """No. 3 tests collection for ConceptMap. - Test File: sc-valueset-fm-status.json - """ - filename = base_settings["unittest_data_dir"] / "sc-valueset-fm-status.json" - inst = conceptmap.ConceptMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ConceptMap" == inst.resource_type - - impl_conceptmap_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ConceptMap" == data["resourceType"] - - inst2 = conceptmap.ConceptMap(**data) - impl_conceptmap_3(inst2) - - -def impl_conceptmap_4(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.group[0].element[0].code == "preliminary" - assert inst.group[0].element[0].target[0].code == "active" - assert inst.group[0].element[0].target[0].equivalence == "equivalent" - assert inst.group[0].element[1].code == "final" - assert inst.group[0].element[1].target[0].code == "completed" - assert inst.group[0].element[1].target[0].equivalence == "wider" - assert inst.group[0].element[2].code == "amended" - assert inst.group[0].element[2].target[0].code == "completed" - assert inst.group[0].element[2].target[0].equivalence == "wider" - assert inst.group[0].element[3].code == "entered-in-error" - assert inst.group[0].element[3].target[0].code == "nullified" - assert inst.group[0].element[3].target[0].equivalence == "equivalent" - assert inst.group[0].source == "http://hl7.org/fhir/composition-status" - assert inst.group[0].target == "http://terminology.hl7.org/CodeSystem/v3-ActStatus" - assert inst.id == "cm-composition-status-v3" - assert inst.name == "v3.CompositionStatus" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.sourceCanonical == "http://hl7.org/fhir/ValueSet/composition-status" - assert inst.status == "draft" - assert inst.targetCanonical == "http://terminology.hl7.org/ValueSet/v3-ActStatus" - assert inst.text.status == "generated" - assert inst.title == "v3 map for CompositionStatus" - assert inst.url == "http://hl7.org/fhir/ConceptMap/cm-composition-status-v3" - assert inst.version == "4.0.1" - - -def test_conceptmap_4(base_settings): - """No. 4 tests collection for ConceptMap. - Test File: cm-composition-status-v3.json - """ - filename = base_settings["unittest_data_dir"] / "cm-composition-status-v3.json" - inst = conceptmap.ConceptMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ConceptMap" == inst.resource_type - - impl_conceptmap_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ConceptMap" == data["resourceType"] - - inst2 = conceptmap.ConceptMap(**data) - impl_conceptmap_4(inst2) - - -def impl_conceptmap_5(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - 'Canonical Mapping for "Indicates whether this flag is ' - "active and needs to be displayed to a user, or whether it is" - ' no longer needed or was entered in error."' - ) - assert inst.group[0].element[0].code == "entered-in-error" - assert inst.group[0].element[0].target[0].code == "error" - assert inst.group[0].element[0].target[0].equivalence == "equivalent" - assert inst.group[0].element[1].code == "active" - assert inst.group[0].element[1].target[0].code == "active" - assert inst.group[0].element[1].target[0].equivalence == "equivalent" - assert inst.group[0].element[2].code == "inactive" - assert inst.group[0].element[2].target[0].code == "inactive" - assert inst.group[0].element[2].target[0].equivalence == "equivalent" - assert inst.group[0].source == "http://hl7.org/fhir/flag-status" - assert inst.group[0].target == "http://hl7.org/fhir/resource-status" - assert inst.id == "sc-flag-status" - assert inst.name == "FlagStatusCanonicalMap" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.sourceCanonical == "http://hl7.org/fhir/ValueSet/flag-status" - assert inst.status == "draft" - assert inst.targetCanonical == "http://hl7.org/fhir/ValueSet/resource-status" - assert inst.text.status == "generated" - assert inst.title == 'Canonical Mapping for "FlagStatus"' - assert inst.url == "http://hl7.org/fhir/ConceptMap/sc-flag-status" - assert inst.version == "4.0.1" - - -def test_conceptmap_5(base_settings): - """No. 5 tests collection for ConceptMap. - Test File: sc-valueset-flag-status.json - """ - filename = base_settings["unittest_data_dir"] / "sc-valueset-flag-status.json" - inst = conceptmap.ConceptMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ConceptMap" == inst.resource_type - - impl_conceptmap_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ConceptMap" == data["resourceType"] - - inst2 = conceptmap.ConceptMap(**data) - impl_conceptmap_5(inst2) - - -def impl_conceptmap_6(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - 'Canonical Mapping for "The availability status of the ' 'device."' - ) - assert inst.group[0].element[0].code == "entered-in-error" - assert inst.group[0].element[0].target[0].code == "error" - assert inst.group[0].element[0].target[0].equivalence == "equivalent" - assert inst.group[0].element[1].code == "active" - assert inst.group[0].element[1].target[0].code == "active" - assert inst.group[0].element[1].target[0].equivalence == "equivalent" - assert inst.group[0].element[2].code == "inactive" - assert inst.group[0].element[2].target[0].code == "inactive" - assert inst.group[0].element[2].target[0].equivalence == "equivalent" - assert inst.group[0].element[3].code == "unknown" - assert inst.group[0].element[3].target[0].code == "unknown" - assert inst.group[0].element[3].target[0].equivalence == "equivalent" - assert inst.group[0].source == "http://hl7.org/fhir/device-status" - assert inst.group[0].target == "http://hl7.org/fhir/resource-status" - assert inst.id == "sc-device-status" - assert inst.name == "FHIRDeviceStatusCanonicalMap" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.sourceCanonical == "http://hl7.org/fhir/ValueSet/device-status" - assert inst.status == "draft" - assert inst.targetCanonical == "http://hl7.org/fhir/ValueSet/resource-status" - assert inst.text.status == "generated" - assert inst.title == 'Canonical Mapping for "FHIRDeviceStatus"' - assert inst.url == "http://hl7.org/fhir/ConceptMap/sc-device-status" - assert inst.version == "4.0.1" - - -def test_conceptmap_6(base_settings): - """No. 6 tests collection for ConceptMap. - Test File: sc-valueset-device-status.json - """ - filename = base_settings["unittest_data_dir"] / "sc-valueset-device-status.json" - inst = conceptmap.ConceptMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ConceptMap" == inst.resource_type - - impl_conceptmap_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ConceptMap" == data["resourceType"] - - inst2 = conceptmap.ConceptMap(**data) - impl_conceptmap_6(inst2) - - -def impl_conceptmap_7(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.group[0].element[0].code == "home" - assert inst.group[0].element[0].target[0].code == "PRN" - assert inst.group[0].element[0].target[0].equivalence == "wider" - assert inst.group[0].element[0].target[1].code == "ORN" - assert inst.group[0].element[0].target[1].equivalence == "wider" - assert inst.group[0].element[0].target[2].code == "VHN" - assert inst.group[0].element[0].target[2].equivalence == "wider" - assert inst.group[0].element[1].code == "work" - assert inst.group[0].element[1].target[0].code == "WPN" - assert inst.group[0].element[1].target[0].equivalence == "equivalent" - assert inst.group[0].element[2].code == "mobile" - assert inst.group[0].element[2].target[0].code == "PRS" - assert inst.group[0].element[2].target[0].equivalence == "equivalent" - assert inst.group[0].source == "http://hl7.org/fhir/contact-point-use" - assert inst.group[0].target == "http://terminology.hl7.org/CodeSystem/v2-0201" - assert inst.id == "cm-contact-point-use-v2" - assert inst.name == "v2.ContactPointUse" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.sourceCanonical == "http://hl7.org/fhir/ValueSet/contact-point-use" - assert inst.status == "draft" - assert inst.targetCanonical == "http://terminology.hl7.org/ValueSet/v2-0201" - assert inst.text.status == "generated" - assert inst.title == "v2 map for ContactPointUse" - assert inst.url == "http://hl7.org/fhir/ConceptMap/cm-contact-point-use-v2" - assert inst.version == "4.0.1" - - -def test_conceptmap_7(base_settings): - """No. 7 tests collection for ConceptMap. - Test File: cm-contact-point-use-v2.json - """ - filename = base_settings["unittest_data_dir"] / "cm-contact-point-use-v2.json" - inst = conceptmap.ConceptMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ConceptMap" == inst.resource_type - - impl_conceptmap_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ConceptMap" == data["resourceType"] - - inst2 = conceptmap.ConceptMap(**data) - impl_conceptmap_7(inst2) - - -def impl_conceptmap_8(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - 'Canonical Mapping for "Preferred value set for ' - 'AllergyIntolerance Clinical Status."' - ) - assert inst.group[0].element[0].code == "active" - assert inst.group[0].element[0].target[0].code == "active" - assert inst.group[0].element[0].target[0].equivalence == "equivalent" - assert inst.group[0].element[1].code == "inactive" - assert inst.group[0].element[1].target[0].code == "inactive" - assert inst.group[0].element[1].target[0].equivalence == "equivalent" - assert inst.group[0].element[2].code == "resolved" - assert inst.group[0].element[2].target[0].code == "resolved" - assert inst.group[0].element[2].target[0].equivalence == "equivalent" - assert inst.group[0].source == ( - "http://terminology.hl7.org/CodeSystem/allergyintolerance-" "clinical" - ) - assert inst.group[0].target == "http://hl7.org/fhir/resource-status" - assert inst.id == "sc-allergyintolerance-clinical" - assert inst.name == "AllergyIntoleranceClinicalStatusCodesCanonicalMap" - assert inst.publisher == "FHIR Project team" - assert ( - inst.sourceCanonical - == "http://hl7.org/fhir/ValueSet/allergyintolerance-clinical" - ) - assert inst.status == "draft" - assert inst.targetCanonical == "http://hl7.org/fhir/ValueSet/resource-status" - assert inst.text.status == "generated" - assert inst.title == ( - 'Canonical Mapping for "AllergyIntolerance Clinical Status ' 'Codes"' - ) - assert inst.url == ( - "http://hl7.org/fhir/ConceptMap/sc-allergyintolerance-" "clinical" - ) - assert inst.version == "4.0.1" - - -def test_conceptmap_8(base_settings): - """No. 8 tests collection for ConceptMap. - Test File: sc-valueset-allergyintolerance-clinical.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "sc-valueset-allergyintolerance-clinical.json" - ) - inst = conceptmap.ConceptMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ConceptMap" == inst.resource_type - - impl_conceptmap_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ConceptMap" == data["resourceType"] - - inst2 = conceptmap.ConceptMap(**data) - impl_conceptmap_8(inst2) - - -def impl_conceptmap_9(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == 'Canonical Mapping for "Medication Status Codes"' - assert inst.group[0].element[0].code == "entered-in-error" - assert inst.group[0].element[0].target[0].code == "error" - assert inst.group[0].element[0].target[0].equivalence == "equivalent" - assert inst.group[0].element[1].code == "active" - assert inst.group[0].element[1].target[0].code == "active" - assert inst.group[0].element[1].target[0].equivalence == "equivalent" - assert inst.group[0].element[2].code == "inactive" - assert inst.group[0].element[2].target[0].code == "inactive" - assert inst.group[0].element[2].target[0].equivalence == "equivalent" - assert inst.group[0].source == "http://hl7.org/fhir/CodeSystem/medication-status" - assert inst.group[0].target == "http://hl7.org/fhir/resource-status" - assert inst.id == "sc-medication-status" - assert inst.name == "Medication Status CodesCanonicalMap" - assert inst.publisher == "FHIR Project team" - assert inst.sourceCanonical == "http://hl7.org/fhir/ValueSet/medication-status" - assert inst.status == "draft" - assert inst.targetCanonical == "http://hl7.org/fhir/ValueSet/resource-status" - assert inst.text.status == "generated" - assert inst.title == 'Canonical Mapping for "Medication status codes"' - assert inst.url == "http://hl7.org/fhir/ConceptMap/sc-medication-status" - assert inst.version == "4.0.1" - - -def test_conceptmap_9(base_settings): - """No. 9 tests collection for ConceptMap. - Test File: sc-valueset-medication-status.json - """ - filename = base_settings["unittest_data_dir"] / "sc-valueset-medication-status.json" - inst = conceptmap.ConceptMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ConceptMap" == inst.resource_type - - impl_conceptmap_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ConceptMap" == data["resourceType"] - - inst2 = conceptmap.ConceptMap(**data) - impl_conceptmap_9(inst2) - - -def impl_conceptmap_10(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - 'Canonical Mapping for "Indicates whether the location is ' 'still in use."' - ) - assert inst.group[0].element[0].code == "active" - assert inst.group[0].element[0].target[0].code == "active" - assert inst.group[0].element[0].target[0].equivalence == "equivalent" - assert inst.group[0].element[1].code == "suspended" - assert inst.group[0].element[1].target[0].code == "suspended" - assert inst.group[0].element[1].target[0].equivalence == "equivalent" - assert inst.group[0].element[2].code == "inactive" - assert inst.group[0].element[2].target[0].code == "inactive" - assert inst.group[0].element[2].target[0].equivalence == "equivalent" - assert inst.group[0].source == "http://hl7.org/fhir/location-status" - assert inst.group[0].target == "http://hl7.org/fhir/resource-status" - assert inst.id == "sc-location-status" - assert inst.name == "LocationStatusCanonicalMap" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.sourceCanonical == "http://hl7.org/fhir/ValueSet/location-status" - assert inst.status == "draft" - assert inst.targetCanonical == "http://hl7.org/fhir/ValueSet/resource-status" - assert inst.text.status == "generated" - assert inst.title == 'Canonical Mapping for "LocationStatus"' - assert inst.url == "http://hl7.org/fhir/ConceptMap/sc-location-status" - assert inst.version == "4.0.1" - - -def test_conceptmap_10(base_settings): - """No. 10 tests collection for ConceptMap. - Test File: sc-valueset-location-status.json - """ - filename = base_settings["unittest_data_dir"] / "sc-valueset-location-status.json" - inst = conceptmap.ConceptMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ConceptMap" == inst.resource_type - - impl_conceptmap_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ConceptMap" == data["resourceType"] - - inst2 = conceptmap.ConceptMap(**data) - impl_conceptmap_10(inst2) diff --git a/fhir/resources/tests/test_condition.py b/fhir/resources/tests/test_condition.py deleted file mode 100644 index 4b5a1d85..00000000 --- a/fhir/resources/tests/test_condition.py +++ /dev/null @@ -1,658 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Condition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import condition - - -def impl_condition_1(inst): - assert inst.asserter.display == "P. van de Heuvel" - assert inst.asserter.reference == "Patient/f001" - assert inst.bodySite[0].coding[0].code == "280193007" - assert inst.bodySite[0].coding[0].display == "Entire retropharyngeal area" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].coding[0].code == "439401001" - assert inst.category[0].coding[0].display == "diagnosis" - assert inst.category[0].coding[0].system == "http://snomed.info/sct" - assert inst.clinicalStatus.coding[0].code == "active" - assert ( - inst.clinicalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-clinical" - ) - assert inst.code.coding[0].code == "18099001" - assert inst.code.coding[0].display == "Retropharyngeal abscess" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.encounter.reference == "Encounter/f003" - assert inst.evidence[0].code[0].coding[0].code == "169068008" - assert inst.evidence[0].code[0].coding[0].display == "CT of neck" - assert inst.evidence[0].code[0].coding[0].system == "http://snomed.info/sct" - assert inst.id == "f003" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.onsetDateTime == fhirtypes.DateTime.validate( - "2012-02-27T12:09:24+00:06" - ) - assert inst.recordedDate == fhirtypes.DateTime.validate("2012-02-20T12:09:24+00:06") - assert inst.severity.coding[0].code == "371923003" - assert inst.severity.coding[0].display == "Mild to moderate" - assert inst.severity.coding[0].system == "http://snomed.info/sct" - assert inst.subject.display == "P. van de Heuvel" - assert inst.subject.reference == "Patient/f001" - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert ( - inst.verificationStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-ver-status" - ) - - -def test_condition_1(base_settings): - """No. 1 tests collection for Condition. - Test File: condition-example-f003-abscess.json - """ - filename = ( - base_settings["unittest_data_dir"] / "condition-example-f003-abscess.json" - ) - inst = condition.Condition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Condition" == inst.resource_type - - impl_condition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Condition" == data["resourceType"] - - inst2 = condition.Condition(**data) - impl_condition_1(inst2) - - -def impl_condition_2(inst): - assert inst.asserter.reference == "Practitioner/f201" - assert inst.bodySite[0].coding[0].code == "281158006" - assert inst.bodySite[0].coding[0].display == "Pulmonary vascular structure" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].coding[0].code == "55607006" - assert inst.category[0].coding[0].display == "Problem" - assert inst.category[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].coding[1].code == "problem-list-item" - assert ( - inst.category[0].coding[1].system - == "http://terminology.hl7.org/CodeSystem/condition-category" - ) - assert inst.clinicalStatus.coding[0].code == "active" - assert ( - inst.clinicalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-clinical" - ) - assert inst.code.coding[0].code == "10001005" - assert inst.code.coding[0].display == "Bacterial sepsis" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.encounter.display == "Roel's encounter on March elevanth" - assert inst.encounter.reference == "Encounter/f203" - assert inst.evidence[0].detail[0].display == "Diagnostic report for Roel's sepsis" - assert inst.evidence[0].detail[0].reference == "DiagnosticReport/f202" - assert inst.id == "f203" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.onsetDateTime == fhirtypes.DateTime.validate( - "2013-03-08T12:09:24+00:06" - ) - assert inst.recordedDate == fhirtypes.DateTime.validate("2013-03-11T12:09:24+00:06") - assert inst.severity.coding[0].code == "371924009" - assert inst.severity.coding[0].display == "Moderate to severe" - assert inst.severity.coding[0].system == "http://snomed.info/sct" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert ( - inst.verificationStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-ver-status" - ) - - -def test_condition_2(base_settings): - """No. 2 tests collection for Condition. - Test File: condition-example-f203-sepsis.json - """ - filename = base_settings["unittest_data_dir"] / "condition-example-f203-sepsis.json" - inst = condition.Condition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Condition" == inst.resource_type - - impl_condition_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Condition" == data["resourceType"] - - inst2 = condition.Condition(**data) - impl_condition_2(inst2) - - -def impl_condition_3(inst): - assert inst.category[0].coding[0].code == "encounter-diagnosis" - assert inst.category[0].coding[0].display == "Encounter Diagnosis" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-category" - ) - assert inst.clinicalStatus.coding[0].code == "active" - assert ( - inst.clinicalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-clinical" - ) - assert inst.code.coding[0].code == "422504002" - assert inst.code.coding[0].display == "Ischemic stroke (disorder)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Stroke" - assert inst.id == "stroke" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.onsetDateTime == fhirtypes.DateTime.validate( - "2010-07-18T12:09:24+00:06" - ) - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Ischemic stroke,' - " July 18, 2010
" - ) - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert ( - inst.verificationStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-ver-status" - ) - - -def test_condition_3(base_settings): - """No. 3 tests collection for Condition. - Test File: condition-example-stroke.json - """ - filename = base_settings["unittest_data_dir"] / "condition-example-stroke.json" - inst = condition.Condition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Condition" == inst.resource_type - - impl_condition_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Condition" == data["resourceType"] - - inst2 = condition.Condition(**data) - impl_condition_3(inst2) - - -def impl_condition_4(inst): - assert inst.category[0].coding[0].code == "problem-list-item" - assert inst.category[0].coding[0].display == "Problem List Item" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-category" - ) - assert inst.clinicalStatus.coding[0].code == "active" - assert ( - inst.clinicalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-clinical" - ) - assert inst.code.coding[0].code == "312824007" - assert inst.code.coding[0].display == "Family history of cancer of colon" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.id == "family-history" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Family history ' - "of cancer of colon
" - ) - assert inst.text.status == "generated" - - -def test_condition_4(base_settings): - """No. 4 tests collection for Condition. - Test File: condition-example-family-history.json - """ - filename = ( - base_settings["unittest_data_dir"] / "condition-example-family-history.json" - ) - inst = condition.Condition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Condition" == inst.resource_type - - impl_condition_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Condition" == data["resourceType"] - - inst2 = condition.Condition(**data) - impl_condition_4(inst2) - - -def impl_condition_5(inst): - assert inst.asserter.display == "P. van de Heuvel" - assert inst.asserter.reference == "Patient/f001" - assert inst.bodySite[0].coding[0].code == "51185008" - assert inst.bodySite[0].coding[0].display == "Thorax" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].coding[0].code == "439401001" - assert inst.category[0].coding[0].display == "diagnosis" - assert inst.category[0].coding[0].system == "http://snomed.info/sct" - assert inst.clinicalStatus.coding[0].code == "active" - assert ( - inst.clinicalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-clinical" - ) - assert inst.code.coding[0].code == "254637007" - assert inst.code.coding[0].display == "NSCLC - Non-small cell lung cancer" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.encounter.reference == "Encounter/f002" - assert inst.evidence[0].code[0].coding[0].code == "169069000" - assert inst.evidence[0].code[0].coding[0].display == "CT of thorax" - assert inst.evidence[0].code[0].coding[0].system == "http://snomed.info/sct" - assert inst.id == "f002" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.onsetDateTime == fhirtypes.DateTime.validate( - "2011-05-05T12:09:24+00:06" - ) - assert inst.recordedDate == fhirtypes.DateTime.validate("2012-06-03T12:09:24+00:06") - assert inst.severity.coding[0].code == "24484000" - assert inst.severity.coding[0].display == "Severe" - assert inst.severity.coding[0].system == "http://snomed.info/sct" - assert inst.stage[0].summary.coding[0].code == "258219007" - assert inst.stage[0].summary.coding[0].display == "stage II" - assert inst.stage[0].summary.coding[0].system == "http://snomed.info/sct" - assert inst.stage[0].type.coding[0].code == "260998006" - assert inst.stage[0].type.coding[0].display == "Clinical staging (qualifier value)" - assert inst.stage[0].type.coding[0].system == "http://snomed.info/sct" - assert inst.subject.display == "P. van de Heuvel" - assert inst.subject.reference == "Patient/f001" - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert ( - inst.verificationStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-ver-status" - ) - - -def test_condition_5(base_settings): - """No. 5 tests collection for Condition. - Test File: condition-example-f002-lung.json - """ - filename = base_settings["unittest_data_dir"] / "condition-example-f002-lung.json" - inst = condition.Condition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Condition" == inst.resource_type - - impl_condition_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Condition" == data["resourceType"] - - inst2 = condition.Condition(**data) - impl_condition_5(inst2) - - -def impl_condition_6(inst): - assert inst.asserter.reference == "Practitioner/f201" - assert inst.clinicalStatus.coding[0].code == "active" - assert ( - inst.clinicalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-clinical" - ) - assert inst.code.coding[0].code == "87628006" - assert inst.code.coding[0].display == "Bacterial infectious disease" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.id == "f205" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.recordedDate == fhirtypes.DateTime.validate("2013-04-04T12:09:24+00:06") - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "differential" - assert ( - inst.verificationStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-ver-status" - ) - - -def test_condition_6(base_settings): - """No. 6 tests collection for Condition. - Test File: condition-example-f205-infection.json - """ - filename = ( - base_settings["unittest_data_dir"] / "condition-example-f205-infection.json" - ) - inst = condition.Condition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Condition" == inst.resource_type - - impl_condition_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Condition" == data["resourceType"] - - inst2 = condition.Condition(**data) - impl_condition_6(inst2) - - -def impl_condition_7(inst): - assert inst.abatementDateTime == fhirtypes.DateTime.validate( - "2013-03-20T12:09:24+00:06" - ) - assert inst.asserter.reference == "Practitioner/f201" - assert inst.bodySite[0].coding[0].code == "181414000" - assert inst.bodySite[0].coding[0].display == "Kidney" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].coding[0].code == "55607006" - assert inst.category[0].coding[0].display == "Problem" - assert inst.category[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].coding[1].code == "problem-list-item" - assert ( - inst.category[0].coding[1].system - == "http://terminology.hl7.org/CodeSystem/condition-category" - ) - assert inst.clinicalStatus.coding[0].code == "inactive" - assert ( - inst.clinicalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-clinical" - ) - assert inst.code.coding[0].code == "36225005" - assert ( - inst.code.coding[0].display - == "Acute renal insufficiency specified as due to procedure" - ) - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.encounter.display == "Roel's encounter on March elevanth" - assert inst.encounter.reference == "Encounter/f203" - assert inst.id == "f204" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "The patient is anuric." - assert inst.onsetDateTime == fhirtypes.DateTime.validate( - "2013-03-11T12:09:24+00:06" - ) - assert inst.recordedDate == fhirtypes.DateTime.validate("2013-03-11T12:09:24+00:06") - assert inst.severity.coding[0].code == "24484000" - assert inst.severity.coding[0].display == "Severe" - assert inst.severity.coding[0].system == "http://snomed.info/sct" - assert inst.stage[0].assessment[0].display == "Genetic analysis master panel" - assert inst.stage[0].summary.coding[0].code == "14803004" - assert inst.stage[0].summary.coding[0].display == "Temporary" - assert inst.stage[0].summary.coding[0].system == "http://snomed.info/sct" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "differential" - assert ( - inst.verificationStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-ver-status" - ) - - -def test_condition_7(base_settings): - """No. 7 tests collection for Condition. - Test File: condition-example-f204-renal.json - """ - filename = base_settings["unittest_data_dir"] / "condition-example-f204-renal.json" - inst = condition.Condition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Condition" == inst.resource_type - - impl_condition_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Condition" == data["resourceType"] - - inst2 = condition.Condition(**data) - impl_condition_7(inst2) - - -def impl_condition_8(inst): - assert inst.category[0].coding[0].code == "problem-list-item" - assert inst.category[0].coding[0].display == "Problem List Item" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-category" - ) - assert inst.clinicalStatus.coding[0].code == "active" - assert ( - inst.clinicalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-clinical" - ) - assert inst.code.text == "Asthma" - assert inst.id == "example2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.onsetString == "approximately November 2012" - assert inst.severity.coding[0].code == "255604002" - assert inst.severity.coding[0].display == "Mild" - assert inst.severity.coding[0].system == "http://snomed.info/sct" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Mild Asthma ' - "(Date: 12-Nov 2012)
" - ) - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert ( - inst.verificationStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-ver-status" - ) - - -def test_condition_8(base_settings): - """No. 8 tests collection for Condition. - Test File: condition-example2.json - """ - filename = base_settings["unittest_data_dir"] / "condition-example2.json" - inst = condition.Condition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Condition" == inst.resource_type - - impl_condition_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Condition" == data["resourceType"] - - inst2 = condition.Condition(**data) - impl_condition_8(inst2) - - -def impl_condition_9(inst): - assert inst.abatementAge.code == "a" - assert inst.abatementAge.system == "http://unitsofmeasure.org" - assert inst.abatementAge.unit == "years" - assert float(inst.abatementAge.value) == float(54) - assert inst.bodySite[0].coding[0].code == "361355005" - assert inst.bodySite[0].coding[0].display == "Entire head and neck" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].coding[0].code == "encounter-diagnosis" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-category" - ) - assert inst.clinicalStatus.coding[0].code == "resolved" - assert ( - inst.clinicalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-clinical" - ) - assert inst.code.coding[0].code == "363346000" - assert inst.code.coding[0].display == "Malignant neoplastic disease" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert ( - inst.evidence[0].detail[0].display - == "Erasmus' diagnostic report of Roel's tumor" - ) - assert inst.evidence[0].detail[0].reference == "DiagnosticReport/f201" - assert inst.id == "f202" - assert inst.meta.security[0].code == "TBOO" - assert inst.meta.security[0].display == "taboo" - assert ( - inst.meta.security[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.onsetAge.code == "a" - assert inst.onsetAge.system == "http://unitsofmeasure.org" - assert inst.onsetAge.unit == "years" - assert float(inst.onsetAge.value) == float(52) - assert inst.recordedDate == fhirtypes.DateTime.validate("2012-12-01T12:09:24+00:06") - assert inst.severity.coding[0].code == "24484000" - assert inst.severity.coding[0].display == "Severe" - assert inst.severity.coding[0].system == "http://snomed.info/sct" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert ( - inst.verificationStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-ver-status" - ) - - -def test_condition_9(base_settings): - """No. 9 tests collection for Condition. - Test File: condition-example-f202-malignancy.json - """ - filename = ( - base_settings["unittest_data_dir"] / "condition-example-f202-malignancy.json" - ) - inst = condition.Condition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Condition" == inst.resource_type - - impl_condition_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Condition" == data["resourceType"] - - inst2 = condition.Condition(**data) - impl_condition_9(inst2) - - -def impl_condition_10(inst): - assert inst.abatementString == "around April 9, 2013" - assert inst.asserter.reference == "Practitioner/f201" - assert inst.bodySite[0].coding[0].code == "38266002" - assert inst.bodySite[0].coding[0].display == "Entire body as a whole" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].coding[0].code == "55607006" - assert inst.category[0].coding[0].display == "Problem" - assert inst.category[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].coding[1].code == "problem-list-item" - assert ( - inst.category[0].coding[1].system - == "http://terminology.hl7.org/CodeSystem/condition-category" - ) - assert inst.clinicalStatus.coding[0].code == "resolved" - assert ( - inst.clinicalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-clinical" - ) - assert inst.code.coding[0].code == "386661006" - assert inst.code.coding[0].display == "Fever" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.encounter.reference == "Encounter/f201" - assert inst.evidence[0].code[0].coding[0].code == "258710007" - assert inst.evidence[0].code[0].coding[0].display == "degrees C" - assert inst.evidence[0].code[0].coding[0].system == "http://snomed.info/sct" - assert inst.evidence[0].detail[0].display == "Temperature" - assert inst.evidence[0].detail[0].reference == "Observation/f202" - assert inst.id == "f201" - assert inst.identifier[0].value == "12345" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.onsetDateTime == fhirtypes.DateTime.validate( - "2013-04-02T12:09:24+00:06" - ) - assert inst.recordedDate == fhirtypes.DateTime.validate("2013-04-04T12:09:24+00:06") - assert inst.recorder.reference == "Practitioner/f201" - assert inst.severity.coding[0].code == "255604002" - assert inst.severity.coding[0].display == "Mild" - assert inst.severity.coding[0].system == "http://snomed.info/sct" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - assert inst.verificationStatus.coding[0].code == "confirmed" - assert ( - inst.verificationStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/condition-ver-status" - ) - - -def test_condition_10(base_settings): - """No. 10 tests collection for Condition. - Test File: condition-example-f201-fever.json - """ - filename = base_settings["unittest_data_dir"] / "condition-example-f201-fever.json" - inst = condition.Condition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Condition" == inst.resource_type - - impl_condition_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Condition" == data["resourceType"] - - inst2 = condition.Condition(**data) - impl_condition_10(inst2) diff --git a/fhir/resources/tests/test_consent.py b/fhir/resources/tests/test_consent.py deleted file mode 100644 index 2fe8afdc..00000000 --- a/fhir/resources/tests/test_consent.py +++ /dev/null @@ -1,810 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Consent -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import consent - - -def impl_consent_1(inst): - assert inst.category[0].coding[0].code == "59284-0" - assert inst.category[0].coding[0].system == "http://loinc.org" - assert inst.dateTime == fhirtypes.DateTime.validate("2015-11-18T11:15:33+10:00") - assert inst.id == "consent-example-notThis" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization[0].reference == "Organization/f001" - assert inst.patient.display == "P. van de Heuvel" - assert inst.patient.reference == "Patient/f001" - assert inst.policyRule.coding[0].code == "OPTIN" - assert ( - inst.policyRule.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.data[0].meaning == "related" - assert inst.provision.data[0].reference.reference == "Task/example3" - assert inst.scope.coding[0].code == "patient-privacy" - assert ( - inst.scope.coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentscope" - ) - assert inst.sourceAttachment.title == "The terms of the consent in lawyer speak." - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_consent_1(base_settings): - """No. 1 tests collection for Consent. - Test File: consent-example-notThis.json - """ - filename = base_settings["unittest_data_dir"] / "consent-example-notThis.json" - inst = consent.Consent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Consent" == inst.resource_type - - impl_consent_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Consent" == data["resourceType"] - - inst2 = consent.Consent(**data) - impl_consent_1(inst2) - - -def impl_consent_2(inst): - assert inst.category[0].coding[0].code == "59284-0" - assert inst.category[0].coding[0].system == "http://loinc.org" - assert inst.dateTime == fhirtypes.DateTime.validate("2016-06-23T17:02:33+10:00") - assert inst.id == "consent-example-smartonfhir" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization[0].reference == "Organization/f001" - assert inst.patient.reference == "Patient/xcda" - assert inst.performer[0].reference == "RelatedPerson/peter" - assert inst.policyRule.coding[0].code == "OPTIN" - assert ( - inst.policyRule.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.period.end == fhirtypes.DateTime.validate( - "2016-06-23T17:32:33+10:00" - ) - assert inst.provision.period.start == fhirtypes.DateTime.validate( - "2016-06-23T17:02:33+10:00" - ) - assert inst.provision.provision[0].action[0].coding[0].code == "access" - assert ( - inst.provision.provision[0].action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert inst.provision.provision[0].class_fhir[0].code == "MedicationRequest" - assert ( - inst.provision.provision[0].class_fhir[0].system - == "http://hl7.org/fhir/resource-types" - ) - assert inst.provision.provision[0].type == "permit" - assert inst.scope.coding[0].code == "patient-privacy" - assert ( - inst.scope.coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentscope" - ) - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_consent_2(base_settings): - """No. 2 tests collection for Consent. - Test File: consent-example-smartonfhir.json - """ - filename = base_settings["unittest_data_dir"] / "consent-example-smartonfhir.json" - inst = consent.Consent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Consent" == inst.resource_type - - impl_consent_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Consent" == data["resourceType"] - - inst2 = consent.Consent(**data) - impl_consent_2(inst2) - - -def impl_consent_3(inst): - assert inst.category[0].coding[0].code == "59284-0" - assert inst.category[0].coding[0].system == "http://loinc.org" - assert inst.dateTime == fhirtypes.DateTime.validate("2015-11-18T11:15:33+10:00") - assert inst.id == "consent-example-notAuthor" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization[0].reference == "Organization/f001" - assert inst.patient.display == "P. van de Heuvel" - assert inst.patient.reference == "Patient/f001" - assert inst.policyRule.coding[0].code == "OPTIN" - assert ( - inst.policyRule.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.actor[0].reference.reference == "Organization/f001" - assert inst.provision.actor[0].role.coding[0].code == "CST" - assert ( - inst.provision.actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.scope.coding[0].code == "patient-privacy" - assert ( - inst.scope.coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentscope" - ) - assert inst.sourceAttachment.title == "The terms of the consent in lawyer speak." - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_consent_3(base_settings): - """No. 3 tests collection for Consent. - Test File: consent-example-notAuthor.json - """ - filename = base_settings["unittest_data_dir"] / "consent-example-notAuthor.json" - inst = consent.Consent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Consent" == inst.resource_type - - impl_consent_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Consent" == data["resourceType"] - - inst2 = consent.Consent(**data) - impl_consent_3(inst2) - - -def impl_consent_4(inst): - assert inst.category[0].coding[0].code == "59284-0" - assert inst.category[0].coding[0].system == "http://loinc.org" - assert inst.dateTime == fhirtypes.DateTime.validate("2015-11-18T11:15:33+10:00") - assert inst.id == "consent-example-notTime" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization[0].reference == "Organization/f001" - assert inst.patient.display == "P. van de Heuvel" - assert inst.patient.reference == "Patient/f001" - assert inst.policyRule.coding[0].code == "OPTIN" - assert ( - inst.policyRule.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.period.end == fhirtypes.DateTime.validate( - "2015-02-01T11:15:33+10:00" - ) - assert inst.provision.period.start == fhirtypes.DateTime.validate( - "2015-01-01T11:15:33+10:00" - ) - assert inst.scope.coding[0].code == "patient-privacy" - assert ( - inst.scope.coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentscope" - ) - assert inst.sourceAttachment.title == "The terms of the consent in lawyer speak." - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_consent_4(base_settings): - """No. 4 tests collection for Consent. - Test File: consent-example-notTime.json - """ - filename = base_settings["unittest_data_dir"] / "consent-example-notTime.json" - inst = consent.Consent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Consent" == inst.resource_type - - impl_consent_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Consent" == data["resourceType"] - - inst2 = consent.Consent(**data) - impl_consent_4(inst2) - - -def impl_consent_5(inst): - assert inst.category[0].coding[0].code == "npp" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentcategorycodes" - ) - assert inst.dateTime == fhirtypes.DateTime.validate("2016-05-26T00:41:10-04:00") - assert inst.id == "consent-example-signature" - assert inst.identifier[0].system == "urn:oid:2.16.840.1.113883.3.72.5.9.1" - assert inst.identifier[0].value == "494e0c7a-a69e-4fb4-9d02-6aae747790d7" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization[0].reference == "Organization/f001" - assert inst.patient.reference == "Patient/72" - assert inst.performer[0].reference == "Patient/72" - assert inst.policyRule.coding[0].code == "OPTIN" - assert ( - inst.policyRule.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.actor[0].reference.reference == "Practitioner/13" - assert inst.provision.actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.period.end == fhirtypes.DateTime.validate( - "2016-10-10T11:15:33+10:00" - ) - assert inst.provision.period.start == fhirtypes.DateTime.validate( - "2015-10-10T11:15:33+10:00" - ) - assert ( - inst.provision.provision[0].actor[0].reference.reference - == "Practitioner/xcda-author" - ) - assert inst.provision.provision[0].actor[0].role.coding[0].code == "AUT" - assert ( - inst.provision.provision[0].actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[0].class_fhir[0].code == "application/hl7-cda+xml" - assert inst.provision.provision[0].class_fhir[0].system == "urn:ietf:bcp:13" - assert inst.provision.provision[0].code[0].coding[0].code == "34133-9" - assert inst.provision.provision[0].code[0].coding[0].system == "http://loinc.org" - assert inst.provision.provision[0].code[1].coding[0].code == "18842-5" - assert inst.provision.provision[0].code[1].coding[0].system == "http://loinc.org" - assert inst.provision.provision[0].type == "permit" - assert inst.scope.coding[0].code == "patient-privacy" - assert ( - inst.scope.coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentscope" - ) - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_consent_5(base_settings): - """No. 5 tests collection for Consent. - Test File: consent-example-signature.json - """ - filename = base_settings["unittest_data_dir"] / "consent-example-signature.json" - inst = consent.Consent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Consent" == inst.resource_type - - impl_consent_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Consent" == data["resourceType"] - - inst2 = consent.Consent(**data) - impl_consent_5(inst2) - - -def impl_consent_6(inst): - assert inst.category[0].coding[0].code == "59284-0" - assert inst.category[0].coding[0].system == "http://loinc.org" - assert inst.dateTime == fhirtypes.DateTime.validate("2015-11-18T11:15:33+10:00") - assert inst.id == "consent-example-notThem" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization[0].reference == "Organization/f001" - assert inst.patient.display == "P. van de Heuvel" - assert inst.patient.reference == "Patient/f001" - assert inst.policyRule.coding[0].code == "OPTIN" - assert ( - inst.policyRule.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.action[0].coding[0].code == "access" - assert ( - inst.provision.action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert inst.provision.action[1].coding[0].code == "correct" - assert ( - inst.provision.action[1].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert inst.provision.actor[0].reference.display == "Fictive Nurse" - assert inst.provision.actor[0].reference.reference == "Practitioner/f204" - assert inst.provision.actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.scope.coding[0].code == "patient-privacy" - assert ( - inst.scope.coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentscope" - ) - assert inst.sourceAttachment.title == "The terms of the consent in lawyer speak." - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_consent_6(base_settings): - """No. 6 tests collection for Consent. - Test File: consent-example-notThem.json - """ - filename = base_settings["unittest_data_dir"] / "consent-example-notThem.json" - inst = consent.Consent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Consent" == inst.resource_type - - impl_consent_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Consent" == data["resourceType"] - - inst2 = consent.Consent(**data) - impl_consent_6(inst2) - - -def impl_consent_7(inst): - assert inst.category[0].coding[0].code == "INFAO" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.dateTime == fhirtypes.DateTime.validate("2015-11-18T11:15:33+10:00") - assert inst.id == "consent-example-grantor" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization[0].reference == "Organization/f001" - assert inst.patient.display == "P. van de Heuvel" - assert inst.patient.reference == "Patient/f001" - assert inst.policyRule.coding[0].code == "OPTOUT" - assert ( - inst.policyRule.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.action[0].coding[0].code == "access" - assert ( - inst.provision.action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert inst.provision.actor[0].reference.reference == "Organization/f001" - assert inst.provision.actor[0].role.coding[0].code == "CST" - assert ( - inst.provision.actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.actor[1].reference.display == "Good Health Clinic" - assert inst.provision.actor[1].reference.reference == "Patient/example" - assert inst.provision.actor[1].role.coding[0].code == "PRCP" - assert ( - inst.provision.actor[1].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.scope.coding[0].code == "patient-privacy" - assert ( - inst.scope.coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentscope" - ) - assert inst.sourceAttachment.title == "The terms of the consent in lawyer speak." - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_consent_7(base_settings): - """No. 7 tests collection for Consent. - Test File: consent-example-grantor.json - """ - filename = base_settings["unittest_data_dir"] / "consent-example-grantor.json" - inst = consent.Consent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Consent" == inst.resource_type - - impl_consent_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Consent" == data["resourceType"] - - inst2 = consent.Consent(**data) - impl_consent_7(inst2) - - -def impl_consent_8(inst): - assert inst.category[0].coding[0].code == "59284-0" - assert inst.category[0].coding[0].system == "http://loinc.org" - assert inst.dateTime == fhirtypes.DateTime.validate("2015-11-18T11:15:33+10:00") - assert inst.id == "consent-example-notOrg" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization[0].reference == "Organization/f001" - assert inst.patient.display == "P. van de Heuvel" - assert inst.patient.reference == "Patient/f001" - assert inst.policyRule.coding[0].code == "OPTIN" - assert ( - inst.policyRule.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.action[0].coding[0].code == "access" - assert ( - inst.provision.action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert inst.provision.action[1].coding[0].code == "correct" - assert ( - inst.provision.action[1].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert inst.provision.actor[0].reference.reference == "Organization/f001" - assert inst.provision.actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.type == "deny" - assert inst.scope.coding[0].code == "patient-privacy" - assert ( - inst.scope.coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentscope" - ) - assert inst.sourceAttachment.title == "The terms of the consent in lawyer speak." - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_consent_8(base_settings): - """No. 8 tests collection for Consent. - Test File: consent-example-notOrg.json - """ - filename = base_settings["unittest_data_dir"] / "consent-example-notOrg.json" - inst = consent.Consent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Consent" == inst.resource_type - - impl_consent_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Consent" == data["resourceType"] - - inst2 = consent.Consent(**data) - impl_consent_8(inst2) - - -def impl_consent_9(inst): - assert inst.category[0].coding[0].code == "59284-0" - assert inst.category[0].coding[0].system == "http://loinc.org" - assert inst.dateTime == fhirtypes.DateTime.validate("2016-06-16T11:15:33+10:00") - assert inst.id == "consent-example-pkb" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization[0].reference == "Organization/f001" - assert inst.patient.display == "...example patient..." - assert inst.patient.reference == "Patient/example" - assert inst.policyRule.coding[0].code == "OPTOUT" - assert ( - inst.policyRule.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.action[0].coding[0].code == "access" - assert ( - inst.provision.action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert inst.provision.actor[0].reference.reference == "Organization/f001" - assert inst.provision.actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[0].action[0].coding[0].code == "access" - assert ( - inst.provision.provision[0].action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert ( - inst.provision.provision[0].actor[0].reference.reference == "Organization/f001" - ) - assert inst.provision.provision[0].actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.provision[0].actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[0].securityLabel[0].code == "PSY" - assert ( - inst.provision.provision[0].securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.provision[1].action[0].coding[0].code == "access" - assert ( - inst.provision.provision[1].action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert ( - inst.provision.provision[1].actor[0].reference.reference == "Organization/f001" - ) - assert inst.provision.provision[1].actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.provision[1].actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[1].securityLabel[0].code == "SPI" - assert ( - inst.provision.provision[1].securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.provision[2].action[0].coding[0].code == "access" - assert ( - inst.provision.provision[2].action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert ( - inst.provision.provision[2].actor[0].reference.reference == "Organization/f001" - ) - assert inst.provision.provision[2].actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.provision[2].actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[2].securityLabel[0].code == "N" - assert ( - inst.provision.provision[2].securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-Confidentiality" - ) - assert inst.provision.provision[3].action[0].coding[0].code == "access" - assert ( - inst.provision.provision[3].action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert ( - inst.provision.provision[3].actor[0].reference.reference == "Organization/f001" - ) - assert inst.provision.provision[3].actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.provision[3].actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[3].securityLabel[0].code == "PSY" - assert ( - inst.provision.provision[3].securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.provision[4].action[0].coding[0].code == "access" - assert ( - inst.provision.provision[4].action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert ( - inst.provision.provision[4].actor[0].reference.reference == "Organization/f001" - ) - assert inst.provision.provision[4].actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.provision[4].actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[4].securityLabel[0].code == "SPI" - assert ( - inst.provision.provision[4].securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.provision[5].action[0].coding[0].code == "access" - assert ( - inst.provision.provision[5].action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert ( - inst.provision.provision[5].actor[0].reference.reference == "Organization/f001" - ) - assert inst.provision.provision[5].actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.provision[5].actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[5].securityLabel[0].code == "SEX" - assert ( - inst.provision.provision[5].securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.provision[6].action[0].coding[0].code == "access" - assert ( - inst.provision.provision[6].action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert ( - inst.provision.provision[6].actor[0].reference.reference == "Organization/f001" - ) - assert inst.provision.provision[6].actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.provision[6].actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[6].securityLabel[0].code == "N" - assert ( - inst.provision.provision[6].securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-Confidentiality" - ) - assert inst.provision.provision[7].action[0].coding[0].code == "access" - assert ( - inst.provision.provision[7].action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert ( - inst.provision.provision[7].actor[0].reference.reference == "Organization/f001" - ) - assert inst.provision.provision[7].actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.provision[7].actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[7].securityLabel[0].code == "PSY" - assert ( - inst.provision.provision[7].securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.provision[8].action[0].coding[0].code == "access" - assert ( - inst.provision.provision[8].action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert ( - inst.provision.provision[8].actor[0].reference.reference == "Organization/f001" - ) - assert inst.provision.provision[8].actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.provision[8].actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[8].securityLabel[0].code == "SPI" - assert ( - inst.provision.provision[8].securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.provision[9].action[0].coding[0].code == "access" - assert ( - inst.provision.provision[9].action[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentaction" - ) - assert ( - inst.provision.provision[9].actor[0].reference.reference == "Organization/f001" - ) - assert inst.provision.provision[9].actor[0].role.coding[0].code == "PRCP" - assert ( - inst.provision.provision[9].actor[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.provision.provision[9].securityLabel[0].code == "SEX" - assert ( - inst.provision.provision[9].securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.securityLabel[0].code == "N" - assert ( - inst.provision.securityLabel[0].system - == "http://terminology.hl7.org/CodeSystem/v3-Confidentiality" - ) - assert inst.scope.coding[0].code == "patient-privacy" - assert ( - inst.scope.coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentscope" - ) - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_consent_9(base_settings): - """No. 9 tests collection for Consent. - Test File: consent-example-pkb.json - """ - filename = base_settings["unittest_data_dir"] / "consent-example-pkb.json" - inst = consent.Consent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Consent" == inst.resource_type - - impl_consent_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Consent" == data["resourceType"] - - inst2 = consent.Consent(**data) - impl_consent_9(inst2) - - -def impl_consent_10(inst): - assert inst.category[0].coding[0].code == "59284-0" - assert inst.category[0].coding[0].system == "http://loinc.org" - assert inst.dateTime == fhirtypes.DateTime.validate("2016-05-11T11:15:33+10:00") - assert inst.id == "consent-example-basic" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization[0].reference == "Organization/f001" - assert inst.patient.display == "P. van de Heuvel" - assert inst.patient.reference == "Patient/f001" - assert inst.policyRule.coding[0].code == "OPTIN" - assert ( - inst.policyRule.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.provision.period.end == fhirtypes.DateTime.validate( - "2016-01-01T11:15:33+10:00" - ) - assert inst.provision.period.start == fhirtypes.DateTime.validate( - "1964-01-01T11:15:33+10:00" - ) - assert inst.scope.coding[0].code == "patient-privacy" - assert ( - inst.scope.coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentscope" - ) - assert inst.sourceAttachment.title == "The terms of the consent in lawyer speak." - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_consent_10(base_settings): - """No. 10 tests collection for Consent. - Test File: consent-example.json - """ - filename = base_settings["unittest_data_dir"] / "consent-example.json" - inst = consent.Consent.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Consent" == inst.resource_type - - impl_consent_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Consent" == data["resourceType"] - - inst2 = consent.Consent(**data) - impl_consent_10(inst2) diff --git a/fhir/resources/tests/test_contract.py b/fhir/resources/tests/test_contract.py deleted file mode 100644 index 36332b4f..00000000 --- a/fhir/resources/tests/test_contract.py +++ /dev/null @@ -1,662 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Contract -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import contract - - -def impl_contract_1(inst): - assert inst.authority[0].display == "Michigan Health" - assert inst.authority[0].reference == "Organization/3" - assert inst.domain[0].display == "UK Pharmacies" - assert inst.domain[0].reference == "Location/ukp" - assert ( - inst.friendly[0].contentAttachment.title - == "The terms of the consent in friendly consumer speak." - ) - assert inst.id == "pcd-example-notOrg" - assert inst.issued == fhirtypes.DateTime.validate("2015-11-18T11:15:33+10:00") - assert ( - inst.legal[0].contentAttachment.title - == "The terms of the consent in lawyer speak." - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.subType[0].coding[0].code == "Opt-In" - assert inst.subType[0].coding[0].display == "Default Authorization with exceptions." - assert ( - inst.subType[0].coding[0].system - == "http://www.infoway-inforoute.ca.org/Consent-subtype-codes" - ) - assert inst.subject[0].display == "P. van de Heuvel" - assert inst.subject[0].reference == "Patient/f001" - assert inst.term[0].offer.text == ( - "Withhold this order and any results or related objects from " "any provider." - ) - assert inst.term[0].offer.topic.display == "Good Health Clinic" - assert inst.term[0].offer.topic.reference == "Organization/2.16.840.1.113883.19.5" - assert inst.term[0].type.coding[0].code == "withhold-from" - assert ( - inst.term[0].type.coding[0].display - == "Withhold all data from specified actor entity." - ) - assert ( - inst.term[0].type.coding[0].system - == "http://example.org/fhir/consent-term-type-codes" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "57016-8" - assert inst.type.coding[0].system == "http://loinc.org" - - -def test_contract_1(base_settings): - """No. 1 tests collection for Contract. - Test File: pcd-example-notOrg.json - """ - filename = base_settings["unittest_data_dir"] / "pcd-example-notOrg.json" - inst = contract.Contract.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Contract" == inst.resource_type - - impl_contract_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Contract" == data["resourceType"] - - inst2 = contract.Contract(**data) - impl_contract_1(inst2) - - -def impl_contract_2(inst): - assert inst.applies.start == fhirtypes.DateTime.validate( - "2017-01-01T11:15:33+10:00" - ) - assert inst.id == "INS-101" - assert inst.identifier[0].system == "http://xyz-insurance.com/forms" - assert inst.identifier[0].value == "YCSCWLN(01-2017)" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.subject[0].reference == "Patient/1" - assert inst.term[0].asset[0].period[0].start == fhirtypes.DateTime.validate( - "2017-06-01T11:15:33+10:00" - ) - assert inst.term[0].asset[0].subtype[0].text == "sample" - assert inst.term[0].asset[0].type[0].coding[0].code == "RicardianContract" - assert inst.term[0].asset[0].type[0].coding[0].system == "urn:ietf:rfc:3986" - assert inst.term[0].asset[0].valuedItem[ - 0 - ].effectiveTime == fhirtypes.DateTime.validate("1995-09-09T11:15:33+10:00") - assert ( - inst.term[0].asset[0].valuedItem[0].entityCodeableConcept.text == "Ford Bobcat" - ) - assert float(inst.term[0].asset[0].valuedItem[0].factor) == float(1.0) - assert ( - inst.term[0].asset[0].valuedItem[0].identifier.system - == "http://somewhere.motor-vehicle.com/vin" - ) - assert inst.term[0].asset[0].valuedItem[0].identifier.value == "XXSVT34-7665t952236" - assert inst.term[0].asset[0].valuedItem[0].net.currency == "CAD" - assert float(inst.term[0].asset[0].valuedItem[0].net.value) == float(200.0) - assert float(inst.term[0].asset[0].valuedItem[0].points) == float(1.0) - assert float(inst.term[0].asset[0].valuedItem[0].quantity.value) == float(1) - assert inst.term[0].asset[0].valuedItem[0].unitPrice.currency == "CAD" - assert float(inst.term[0].asset[0].valuedItem[0].unitPrice.value) == float(200.0) - assert inst.term[0].group[0].offer.text == "Eligible Providers" - assert inst.term[0].group[1].offer.text == "Responsibility for Payment" - assert inst.term[0].group[2].group[0].group[0].offer.text == "Emergency Room Copay" - assert ( - inst.term[0].group[2].group[0].group[1].offer.text == "Professional Visit Copay" - ) - assert inst.term[0].group[2].group[0].offer.text == "Copays" - assert inst.term[0].group[2].group[1].offer.text == "Calendar Year Deductible" - assert inst.term[0].group[2].group[2].offer.text == "Out-Of-Pocket Maximum" - assert inst.term[0].group[2].group[3].group[0].offer.text == "Ambulance Services" - assert inst.term[0].group[2].group[3].group[1].offer.text == "Dental Services" - assert inst.term[0].group[2].group[3].group[2].offer.text == "Diagnostic Services" - assert ( - inst.term[0].group[2].group[3].group[3].offer.text == "Emergency Room Services" - ) - assert ( - inst.term[0].group[2].group[3].group[4].offer.text == "Hospital Inpatient Care" - ) - assert inst.term[0].group[2].group[3].offer.text == "Medical Services" - assert inst.term[0].group[2].offer.text == "List of Benefits" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "healthinsurance" - assert inst.type.coding[0].display == "Health Insurance" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/contract-type" - ) - - -def test_contract_2(base_settings): - """No. 2 tests collection for Contract. - Test File: contract-example-ins-policy.json - """ - filename = base_settings["unittest_data_dir"] / "contract-example-ins-policy.json" - inst = contract.Contract.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Contract" == inst.resource_type - - impl_contract_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Contract" == data["resourceType"] - - inst2 = contract.Contract(**data) - impl_contract_2(inst2) - - -def impl_contract_3(inst): - assert inst.applies.start == fhirtypes.DateTime.validate( - "2013-11-01T21:18:27-04:00" - ) - assert inst.contentDerivative.coding[0].code == "registration" - assert inst.contentDerivative.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/contract-content-" "derivative" - ) - assert inst.id == "C-2121" - assert inst.issued == fhirtypes.DateTime.validate("2013-11-01T21:18:27-04:00") - assert inst.legal[0].contentAttachment.contentType == "application/pdf" - assert inst.legal[0].contentAttachment.language == "en-US" - assert ( - inst.legal[0].contentAttachment.title - == "MDHHS-5515 Consent To Share Your Health Information" - ) - assert ( - inst.legal[0].contentAttachment.url - == "http://org.mihin.ecms/ConsentDirective-2121" - ) - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2016-07-19T18:18:42.108-04:00" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.meta.versionId == "1" - assert inst.signer[0].party.display == "Alice Recruit" - assert inst.signer[0].party.reference == "Patient/f201" - assert inst.signer[0].signature[0].type[0].code == "1.2.840.10065.1.12.1.1" - assert inst.signer[0].signature[0].type[0].system == "urn:iso-astm:E1762-95:2013" - assert inst.signer[0].signature[0].when == fhirtypes.Instant.validate( - "2017-02-08T10:57:34+01:00" - ) - assert inst.signer[0].signature[0].who.reference == "Patient/f201" - assert inst.signer[0].type.code == "SELF" - assert inst.signer[0].type.system == "http://mdhhs.org/fhir/consent-signer-type" - assert inst.status == "executed" - assert inst.subType[0].coding[0].code == "hcd" - assert ( - inst.subType[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/consentcategorycodes" - ) - assert inst.subject[0].reference == "Patient/f201" - assert inst.term[0].action[0].intent.coding[0].code == "HPRGRP" - assert ( - inst.term[0].action[0].intent.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.term[0].action[0].status.text == "Sample" - assert ( - inst.term[0].action[0].subject[0].reference[0].display - == "VA Ann Arbor Healthcare System" - ) - assert ( - inst.term[0].action[0].subject[0].reference[0].reference == "Organization/f001" - ) - assert inst.term[0].action[0].subject[0].role.coding[0].code == "IR" - assert inst.term[0].action[0].subject[0].role.coding[0].display == "Recipient" - assert ( - inst.term[0].action[0].subject[0].role.coding[0].system - == "http://mdhhs.org/fhir/consent-actor-type" - ) - assert ( - inst.term[0].action[0].subject[0].role.text - == "Recipient of restricted health information" - ) - assert ( - inst.term[0].action[0].subject[1].reference[0].display - == "Community Mental Health Clinic" - ) - assert inst.term[0].action[0].subject[1].reference[0].reference == "Organization/2" - assert inst.term[0].action[0].subject[1].role.coding[0].code == "IS" - assert inst.term[0].action[0].subject[1].role.coding[0].display == "Sender" - assert ( - inst.term[0].action[0].subject[1].role.coding[0].system - == "http://mdhhs.org/fhir/consent-actor-type" - ) - assert ( - inst.term[0].action[0].subject[1].role.text - == "Sender of restricted health information" - ) - assert inst.term[0].action[0].type.coding[0].code == "action-a" - assert ( - inst.term[0].action[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/contractaction" - ) - assert inst.term[0].asset[0].period[0].end == fhirtypes.DateTime.validate( - "2019-11-01T21:18:27-04:00" - ) - assert inst.term[0].asset[0].period[0].start == fhirtypes.DateTime.validate( - "2013-11-01T21:18:27-04:00" - ) - assert inst.term[0].offer.decision.coding[0].code == "OPTIN" - assert ( - inst.term[0].offer.decision.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.term[0].offer.text == "Can't refuse" - assert inst.term[0].offer.type.coding[0].code == "statutory" - assert ( - inst.term[0].offer.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/contracttermtypecodes" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "OPTIN" - assert inst.type.coding[0].system == "http://mdhhs.org/fhir/consentdirective-type" - assert inst.type.text == "Opt-in consent directive" - - -def test_contract_3(base_settings): - """No. 3 tests collection for Contract. - Test File: contract-example-42cfr-part2.json - """ - filename = base_settings["unittest_data_dir"] / "contract-example-42cfr-part2.json" - inst = contract.Contract.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Contract" == inst.resource_type - - impl_contract_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Contract" == data["resourceType"] - - inst2 = contract.Contract(**data) - impl_contract_3(inst2) - - -def impl_contract_4(inst): - assert inst.authority[0].display == "Michigan Health" - assert inst.authority[0].reference == "Organization/3" - assert inst.domain[0].display == "UK Pharmacies" - assert inst.domain[0].reference == "Location/ukp" - assert ( - inst.friendly[0].contentAttachment.title - == "The terms of the consent in friendly consumer speak." - ) - assert inst.id == "pcd-example-notLabs" - assert inst.issued == fhirtypes.DateTime.validate("2014-08-17T11:15:33+10:00") - assert ( - inst.legal[0].contentAttachment.title - == "The terms of the consent in lawyer speak." - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.subType[0].coding[0].code == "Opt-In" - assert inst.subType[0].coding[0].display == "Default Authorization with exceptions." - assert ( - inst.subType[0].coding[0].system - == "http://www.infoway-inforoute.ca.org/Consent-subtype-codes" - ) - assert inst.subject[0].display == "P. van de Heuvel" - assert inst.subject[0].reference == "Patient/f001" - assert inst.term[0].group[0].offer.text == "Withhold orders from any provider." - assert inst.term[0].group[0].subType.coding[0].code == "ServiceRequest" - assert ( - inst.term[0].group[0].subType.coding[0].system - == "http://hl7.org/fhir/resource-types" - ) - assert inst.term[0].group[0].type.coding[0].code == "withhold-object-type" - assert ( - inst.term[0].group[0].type.coding[0].system - == "http://example.org/fhir/consent-term-type-codes" - ) - assert ( - inst.term[0].group[1].offer.text == "Withhold order results from any provider." - ) - assert inst.term[0].group[1].subType.coding[0].code == "DiagnosticReport" - assert ( - inst.term[0].group[1].subType.coding[0].system - == "http://hl7.org/fhir/resource-types" - ) - assert inst.term[0].group[1].type.coding[0].code == "withhold-object-type" - assert ( - inst.term[0].group[1].type.coding[0].system - == "http://example.org/fhir/consent-term-type-codes" - ) - assert inst.term[0].offer.text == "sample" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "57016-8" - assert inst.type.coding[0].system == "http://loinc.org" - - -def test_contract_4(base_settings): - """No. 4 tests collection for Contract. - Test File: pcd-example-notLabs.json - """ - filename = base_settings["unittest_data_dir"] / "pcd-example-notLabs.json" - inst = contract.Contract.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Contract" == inst.resource_type - - impl_contract_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Contract" == data["resourceType"] - - inst2 = contract.Contract(**data) - impl_contract_4(inst2) - - -def impl_contract_5(inst): - assert inst.authority[0].display == "Michigan Health" - assert inst.authority[0].reference == "Organization/3" - assert inst.domain[0].display == "UK Pharmacies" - assert inst.domain[0].reference == "Location/ukp" - assert ( - inst.friendly[0].contentAttachment.title - == "The terms of the consent in friendly consumer speak." - ) - assert inst.id == "pcd-example-notThem" - assert inst.issued == fhirtypes.DateTime.validate("2015-11-18T11:15:33+10:00") - assert ( - inst.legal[0].contentAttachment.title - == "The terms of the consent in lawyer speak." - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.signer[0].party.reference == "Patient/f001" - assert inst.signer[0].signature[0].type[0].code == "1.2.840.10065.1.12.1.1" - assert inst.signer[0].signature[0].type[0].system == "urn:iso-astm:E1762-95:2013" - assert inst.signer[0].signature[0].when == fhirtypes.Instant.validate( - "2013-06-08T10:57:34-07:00" - ) - assert inst.signer[0].signature[0].who.reference == "Patient/f001" - assert inst.signer[0].type.code == "COVPTY" - assert inst.signer[0].type.system == ( - "http://terminology.hl7.org/CodeSystem/contractsignertypecode" "s" - ) - assert inst.subType[0].coding[0].code == "Opt-In" - assert inst.subType[0].coding[0].display == "Default Authorization with exceptions." - assert ( - inst.subType[0].coding[0].system - == "http://www.infoway-inforoute.ca.org/Consent-subtype-codes" - ) - assert inst.subject[0].display == "P. van de Heuvel" - assert inst.subject[0].reference == "Patient/f001" - assert inst.term[0].offer.text == ( - "Withhold this order and any results or related objects from " - "specified nurse provider." - ) - assert inst.term[0].offer.topic.display == "Fictive Nurse" - assert inst.term[0].offer.topic.reference == "Practitioner/f204" - assert inst.term[0].type.coding[0].code == "withhold-from" - assert ( - inst.term[0].type.coding[0].display - == "Withhold all data from specified actor entity." - ) - assert ( - inst.term[0].type.coding[0].system - == "http://example.org/fhir/consent-term-type-codes" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "57016-8" - assert inst.type.coding[0].system == "http://loinc.org" - - -def test_contract_5(base_settings): - """No. 5 tests collection for Contract. - Test File: pcd-example-notThem.json - """ - filename = base_settings["unittest_data_dir"] / "pcd-example-notThem.json" - inst = contract.Contract.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Contract" == inst.resource_type - - impl_contract_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Contract" == data["resourceType"] - - inst2 = contract.Contract(**data) - impl_contract_5(inst2) - - -def impl_contract_6(inst): - assert inst.authority[0].display == "Michigan Health" - assert inst.authority[0].reference == "Organization/3" - assert inst.domain[0].display == "UK Pharmacies" - assert inst.domain[0].reference == "Location/ukp" - assert ( - inst.friendly[0].contentAttachment.title - == "The terms of the consent in friendly consumer speak." - ) - assert inst.id == "pcd-example-notAuthor" - assert inst.issued == fhirtypes.DateTime.validate("2015-11-18T11:15:33+10:00") - assert ( - inst.legal[0].contentAttachment.title - == "The terms of the consent in lawyer speak." - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.subType[0].coding[0].code == "Opt-In" - assert inst.subType[0].coding[0].display == "Default Authorization with exceptions." - assert ( - inst.subType[0].coding[0].system - == "http://www.infoway-inforoute.ca.org/Consent-subtype-codes" - ) - assert inst.subject[0].display == "P. van de Heuvel" - assert inst.subject[0].reference == "Patient/f001" - assert ( - inst.term[0].offer.text == "Withhold all data authored by Good Health provider." - ) - assert inst.term[0].offer.topic.display == "Good Health Clinic" - assert inst.term[0].offer.topic.reference == "Organization/2.16.840.1.113883.19.5" - assert inst.term[0].type.coding[0].code == "withhold-authored-by" - assert ( - inst.term[0].type.coding[0].display - == "Withhold all data authored by specified actor entity." - ) - assert ( - inst.term[0].type.coding[0].system - == "http://example.org/fhir/consent-term-type-codes" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "57016-8" - assert inst.type.coding[0].system == "http://loinc.org" - - -def test_contract_6(base_settings): - """No. 6 tests collection for Contract. - Test File: pcd-example-notAuthor.json - """ - filename = base_settings["unittest_data_dir"] / "pcd-example-notAuthor.json" - inst = contract.Contract.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Contract" == inst.resource_type - - impl_contract_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Contract" == data["resourceType"] - - inst2 = contract.Contract(**data) - impl_contract_6(inst2) - - -def impl_contract_7(inst): - assert inst.id == "C-123" - assert inst.identifier[0].system == "http://happyvalley.com/contract" - assert inst.identifier[0].value == "12347" - assert inst.legallyBindingAttachment.contentType == "application/pdf" - assert inst.legallyBindingAttachment.url == "http://www.aws3.com/storage/doc.pdf" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.rule[0].contentAttachment.contentType == "application/txt" - assert ( - inst.rule[0].contentAttachment.url == "http://www.rfc-editor.org/bcp/bcp13.txt" - ) - assert inst.term[0].asset[0].period[0].start == fhirtypes.DateTime.validate( - "2017-06-01T11:15:33+10:00" - ) - assert inst.term[0].asset[0].subtype[0].text == "sample" - assert inst.term[0].asset[0].type[0].coding[0].code == "RicardianContract" - assert inst.term[0].asset[0].type[0].coding[0].system == "urn:ietf:rfc:3986" - assert inst.term[0].asset[0].valuedItem[ - 0 - ].effectiveTime == fhirtypes.DateTime.validate("1995-09-09T11:15:33+10:00") - assert ( - inst.term[0].asset[0].valuedItem[0].entityCodeableConcept.text == "Ford Bobcat" - ) - assert float(inst.term[0].asset[0].valuedItem[0].factor) == float(1.0) - assert ( - inst.term[0].asset[0].valuedItem[0].identifier.system - == "http://somewhere.motor-vehicle.com/vin" - ) - assert inst.term[0].asset[0].valuedItem[0].identifier.value == "XXSVT34-7665t952236" - assert inst.term[0].asset[0].valuedItem[0].net.currency == "CAD" - assert float(inst.term[0].asset[0].valuedItem[0].net.value) == float(200.0) - assert float(inst.term[0].asset[0].valuedItem[0].points) == float(1.0) - assert float(inst.term[0].asset[0].valuedItem[0].quantity.value) == float(1) - assert inst.term[0].asset[0].valuedItem[0].unitPrice.currency == "CAD" - assert float(inst.term[0].asset[0].valuedItem[0].unitPrice.value) == float(200.0) - assert inst.term[0].offer.text == "Can't refuse" - assert inst.text.div == ( - '
A human-readable' - " rendering of the contract
" - ) - assert inst.text.status == "generated" - - -def test_contract_7(base_settings): - """No. 7 tests collection for Contract. - Test File: contract-example.json - """ - filename = base_settings["unittest_data_dir"] / "contract-example.json" - inst = contract.Contract.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Contract" == inst.resource_type - - impl_contract_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Contract" == data["resourceType"] - - inst2 = contract.Contract(**data) - impl_contract_7(inst2) - - -def impl_contract_8(inst): - assert inst.authority[0].display == "Michigan Health" - assert inst.authority[0].reference == "Organization/3" - assert inst.domain[0].display == "UK Pharmacies" - assert inst.domain[0].reference == "Location/ukp" - assert ( - inst.friendly[0].contentAttachment.title - == "The terms of the consent in friendly consumer speak." - ) - assert inst.id == "pcd-example-notThis" - assert inst.issued == fhirtypes.DateTime.validate("2015-11-18T11:15:33+10:00") - assert ( - inst.legal[0].contentAttachment.title - == "The terms of the consent in lawyer speak." - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.subType[0].coding[0].code == "Opt-In" - assert inst.subType[0].coding[0].display == "Default Authorization with exceptions." - assert ( - inst.subType[0].coding[0].system - == "http://www.infoway-inforoute.ca.org/Consent-subtype-codes" - ) - assert inst.subject[0].display == "P. van de Heuvel" - assert inst.subject[0].reference == "Patient/f001" - assert inst.term[0].applies.start == fhirtypes.DateTime.validate( - "2015-11-18T11:15:33+10:00" - ) - assert inst.term[0].identifier.system == "http://example.org/fhir/term-items" - assert inst.term[0].identifier.value == "3347689" - assert inst.term[0].issued == fhirtypes.DateTime.validate( - "2015-11-01T11:15:33+10:00" - ) - assert inst.term[0].offer.text == ( - "Withhold this order and any results or related objects from " "any provider." - ) - assert inst.term[0].offer.topic.reference == "ServiceRequest/lipid" - assert inst.term[0].type.coding[0].code == "withhold-identified-object-and-related" - assert inst.term[0].type.coding[0].display == ( - "Withhold the identified object and any other resources that " - "are related to this object." - ) - assert ( - inst.term[0].type.coding[0].system - == "http://example.org/fhir/consent-term-type-codes" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "57016-8" - assert inst.type.coding[0].system == "http://loinc.org" - - -def test_contract_8(base_settings): - """No. 8 tests collection for Contract. - Test File: pcd-example-notThis.json - """ - filename = base_settings["unittest_data_dir"] / "pcd-example-notThis.json" - inst = contract.Contract.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Contract" == inst.resource_type - - impl_contract_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Contract" == data["resourceType"] - - inst2 = contract.Contract(**data) - impl_contract_8(inst2) diff --git a/fhir/resources/tests/test_coverage.py b/fhir/resources/tests/test_coverage.py deleted file mode 100644 index 454d88e6..00000000 --- a/fhir/resources/tests/test_coverage.py +++ /dev/null @@ -1,323 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Coverage -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import coverage - - -def impl_coverage_1(inst): - assert inst.beneficiary.reference == "Patient/5" - assert inst.class_fhir[0].name == "Western Airlines" - assert inst.class_fhir[0].type.coding[0].code == "group" - assert ( - inst.class_fhir[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[0].value == "WESTAIR" - assert ( - inst.class_fhir[1].name - == "Full Coverage: Medical, Dental, Pharmacy, Vision, EHC" - ) - assert inst.class_fhir[1].type.coding[0].code == "plan" - assert ( - inst.class_fhir[1].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[1].value == "BG4352" - assert inst.class_fhir[2].name == "Platinum" - assert inst.class_fhir[2].type.coding[0].code == "subplan" - assert ( - inst.class_fhir[2].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[2].value == "D15C9" - assert inst.contract[0].reference == "Contract/INS-101" - assert inst.costToBeneficiary[0].exception[ - 0 - ].period.end == fhirtypes.DateTime.validate("2018-12-31T11:15:33+10:00") - assert inst.costToBeneficiary[0].exception[ - 0 - ].period.start == fhirtypes.DateTime.validate("2018-01-01T11:15:33+10:00") - assert inst.costToBeneficiary[0].exception[0].type.coding[0].code == "retired" - assert inst.costToBeneficiary[0].exception[0].type.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/ex-coverage-financial-" "exception" - ) - assert inst.costToBeneficiary[0].type.coding[0].code == "gpvisit" - assert ( - inst.costToBeneficiary[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-copay-type" - ) - assert inst.costToBeneficiary[0].valueMoney.currency == "USD" - assert float(inst.costToBeneficiary[0].valueMoney.value) == float(20.0) - assert inst.dependent == "1" - assert inst.id == "7546D" - assert inst.identifier[0].system == "http://xyz.com/codes/identifier" - assert inst.identifier[0].value == "AB98761" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.network == "5" - assert inst.order == 2 - assert inst.payor[0].reference == "Organization/2" - assert inst.period.end == fhirtypes.DateTime.validate("2012-03-17T11:15:33+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2011-03-17T11:15:33+10:00") - assert inst.relationship.coding[0].code == "self" - assert inst.status == "active" - assert inst.subscriber.reference == "Patient/5" - assert inst.subscriberId == "AB9876" - assert inst.text.div == ( - '
A human-readable' - " rendering of the coverage
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "EHCPOL" - assert inst.type.coding[0].display == "extended healthcare" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - - -def test_coverage_1(base_settings): - """No. 1 tests collection for Coverage. - Test File: coverage-example-2.json - """ - filename = base_settings["unittest_data_dir"] / "coverage-example-2.json" - inst = coverage.Coverage.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Coverage" == inst.resource_type - - impl_coverage_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Coverage" == data["resourceType"] - - inst2 = coverage.Coverage(**data) - impl_coverage_1(inst2) - - -def impl_coverage_2(inst): - assert inst.beneficiary.reference == "Patient/5" - assert inst.id == "SP1234" - assert inst.identifier[0].system == "http://hospitalx.com/selfpayagreement" - assert inst.identifier[0].value == "SP12345678" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.payor[0].reference == "Patient/5" - assert inst.period.end == fhirtypes.DateTime.validate("2012-03-17T11:15:33+10:00") - assert inst.relationship.coding[0].code == "self" - assert inst.status == "active" - assert inst.subscriber.reference == "Patient/5" - assert inst.text.div == ( - '
A human-readable' - " rendering of a Self Pay Agreement.
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "pay" - assert inst.type.coding[0].display == "PAY" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-selfpay" - ) - - -def test_coverage_2(base_settings): - """No. 2 tests collection for Coverage. - Test File: coverage-example-selfpay.json - """ - filename = base_settings["unittest_data_dir"] / "coverage-example-selfpay.json" - inst = coverage.Coverage.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Coverage" == inst.resource_type - - impl_coverage_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Coverage" == data["resourceType"] - - inst2 = coverage.Coverage(**data) - impl_coverage_2(inst2) - - -def impl_coverage_3(inst): - assert inst.beneficiary.reference == "Patient/5" - assert inst.id == "7547E" - assert inst.identifier[0].system == "http://ehic.com/insurer/123456789/member" - assert inst.identifier[0].value == "A123456780" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.payor[0].identifier.system == "http://ehic.com/insurer" - assert inst.payor[0].identifier.value == "123456789" - assert inst.period.end == fhirtypes.DateTime.validate("2012-03-17T11:15:33+10:00") - assert inst.relationship.coding[0].code == "self" - assert inst.status == "active" - assert inst.subscriber.reference == "Patient/5" - assert inst.text.div == ( - '
A human-readable' - " rendering of the European Health Insurance Card
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "EHCPOL" - assert inst.type.coding[0].display == "extended healthcare" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - - -def test_coverage_3(base_settings): - """No. 3 tests collection for Coverage. - Test File: coverage-example-ehic.json - """ - filename = base_settings["unittest_data_dir"] / "coverage-example-ehic.json" - inst = coverage.Coverage.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Coverage" == inst.resource_type - - impl_coverage_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Coverage" == data["resourceType"] - - inst2 = coverage.Coverage(**data) - impl_coverage_3(inst2) - - -def impl_coverage_4(inst): - assert inst.beneficiary.reference == "Patient/4" - assert inst.class_fhir[0].name == "Corporate Baker's Inc. Local #35" - assert inst.class_fhir[0].type.coding[0].code == "group" - assert ( - inst.class_fhir[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[0].value == "CB135" - assert inst.class_fhir[1].name == "Trainee Part-time Benefits" - assert inst.class_fhir[1].type.coding[0].code == "subgroup" - assert ( - inst.class_fhir[1].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[1].value == "123" - assert ( - inst.class_fhir[2].name - == "Full Coverage: Medical, Dental, Pharmacy, Vision, EHC" - ) - assert inst.class_fhir[2].type.coding[0].code == "plan" - assert ( - inst.class_fhir[2].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[2].value == "B37FC" - assert inst.class_fhir[3].name == "Includes afterlife benefits" - assert inst.class_fhir[3].type.coding[0].code == "subplan" - assert ( - inst.class_fhir[3].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[3].value == "P7" - assert inst.class_fhir[4].name == "Silver: Family Plan spouse only" - assert inst.class_fhir[4].type.coding[0].code == "class" - assert ( - inst.class_fhir[4].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[4].value == "SILVER" - assert inst.class_fhir[5].name == "Low deductable, max $20 copay" - assert inst.class_fhir[5].type.coding[0].code == "subclass" - assert ( - inst.class_fhir[5].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[5].value == "Tier2" - assert inst.class_fhir[6].type.coding[0].code == "sequence" - assert ( - inst.class_fhir[6].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[6].value == "9" - assert inst.class_fhir[7].type.coding[0].code == "rxid" - assert ( - inst.class_fhir[7].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[7].value == "MDF12345" - assert inst.class_fhir[8].type.coding[0].code == "rxbin" - assert ( - inst.class_fhir[8].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[8].value == "987654" - assert inst.class_fhir[9].type.coding[0].code == "rxgroup" - assert ( - inst.class_fhir[9].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/coverage-class" - ) - assert inst.class_fhir[9].value == "M35PT" - assert inst.dependent == "0" - assert inst.id == "9876B1" - assert inst.identifier[0].system == "http://benefitsinc.com/certificate" - assert inst.identifier[0].value == "12345" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.payor[0].reference == "Organization/2" - assert inst.period.end == fhirtypes.DateTime.validate("2012-05-23T11:15:33+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2011-05-23T11:15:33+10:00") - assert ( - inst.policyHolder.reference == "http://benefitsinc.com/FHIR/Organization/CBI35" - ) - assert inst.relationship.coding[0].code == "self" - assert inst.status == "active" - assert inst.subscriber.reference == "Patient/4" - assert inst.text.div == ( - '
A human-readable' - " rendering of the coverage
" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "EHCPOL" - assert inst.type.coding[0].display == "extended healthcare" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - - -def test_coverage_4(base_settings): - """No. 4 tests collection for Coverage. - Test File: coverage-example.json - """ - filename = base_settings["unittest_data_dir"] / "coverage-example.json" - inst = coverage.Coverage.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Coverage" == inst.resource_type - - impl_coverage_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Coverage" == data["resourceType"] - - inst2 = coverage.Coverage(**data) - impl_coverage_4(inst2) diff --git a/fhir/resources/tests/test_coverageeligibilityrequest.py b/fhir/resources/tests/test_coverageeligibilityrequest.py deleted file mode 100644 index 9e00fb76..00000000 --- a/fhir/resources/tests/test_coverageeligibilityrequest.py +++ /dev/null @@ -1,122 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CoverageEligibilityRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import coverageeligibilityrequest - - -def impl_coverageeligibilityrequest_1(inst): - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T11:15:33+10:00") - assert inst.id == "52345" - assert ( - inst.identifier[0].system == "http://happyvalley.com/coverageelegibilityrequest" - ) - assert inst.identifier[0].value == "52345" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is True - assert inst.insurer.reference == "Organization/2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/pat1" - assert inst.priority.coding[0].code == "normal" - assert inst.provider.reference == "Organization/1" - assert inst.purpose[0] == "validation" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the CoverageEligibilityRequest
" - ) - assert inst.text.status == "generated" - - -def test_coverageeligibilityrequest_1(base_settings): - """No. 1 tests collection for CoverageEligibilityRequest. - Test File: coverageeligibilityrequest-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "coverageeligibilityrequest-example.json" - ) - inst = coverageeligibilityrequest.CoverageEligibilityRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CoverageEligibilityRequest" == inst.resource_type - - impl_coverageeligibilityrequest_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CoverageEligibilityRequest" == data["resourceType"] - - inst2 = coverageeligibilityrequest.CoverageEligibilityRequest(**data) - impl_coverageeligibilityrequest_1(inst2) - - -def impl_coverageeligibilityrequest_2(inst): - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T11:15:33+10:00") - assert inst.enterer.identifier.system == "http://happyvalleyclinic.com/staff" - assert inst.enterer.identifier.value == "14" - assert inst.facility.identifier.system == "http://statecliniclicensor.com/clinicid" - assert inst.facility.identifier.value == "G35B9" - assert inst.id == "52346" - assert ( - inst.identifier[0].system == "http://happyvalley.com/coverageelegibilityrequest" - ) - assert inst.identifier[0].value == "52346" - assert inst.insurance[0].businessArrangement == "NB8742" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurer.reference == "Organization/2" - assert inst.item[0].category.coding[0].code == "69" - assert inst.item[0].category.coding[0].display == "Maternity" - assert ( - inst.item[0].category.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-benefitcategory" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/pat1" - assert inst.priority.coding[0].code == "normal" - assert inst.provider.reference == "Organization/1" - assert inst.purpose[0] == "validation" - assert inst.purpose[1] == "benefits" - assert inst.servicedDate == fhirtypes.Date.validate("2014-09-17") - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the CoverageEligibilityRequest
" - ) - assert inst.text.status == "generated" - - -def test_coverageeligibilityrequest_2(base_settings): - """No. 2 tests collection for CoverageEligibilityRequest. - Test File: coverageeligibilityrequest-example-2.json - """ - filename = ( - base_settings["unittest_data_dir"] / "coverageeligibilityrequest-example-2.json" - ) - inst = coverageeligibilityrequest.CoverageEligibilityRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CoverageEligibilityRequest" == inst.resource_type - - impl_coverageeligibilityrequest_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CoverageEligibilityRequest" == data["resourceType"] - - inst2 = coverageeligibilityrequest.CoverageEligibilityRequest(**data) - impl_coverageeligibilityrequest_2(inst2) diff --git a/fhir/resources/tests/test_coverageeligibilityresponse.py b/fhir/resources/tests/test_coverageeligibilityresponse.py deleted file mode 100644 index c92f91d7..00000000 --- a/fhir/resources/tests/test_coverageeligibilityresponse.py +++ /dev/null @@ -1,479 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/CoverageEligibilityResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import coverageeligibilityresponse - - -def impl_coverageeligibilityresponse_1(inst): - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T11:15:33+10:00") - assert inst.disposition == "Policy is currently in-force." - assert inst.id == "E2500" - assert ( - inst.identifier[0].system - == "http://www.BenefitsInc.com/fhir/coverageeligibilityresponse" - ) - assert inst.identifier[0].value == "881234" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].inforce is True - assert inst.insurer.reference == "Organization/2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "complete" - assert inst.patient.reference == "Patient/pat1" - assert inst.purpose[0] == "validation" - assert inst.request.reference == ( - "http://www.BenefitsInc.com/fhir/coverageeligibilityrequest/2" "25476332402" - ) - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the CoverageEligibilityResponse.
" - ) - assert inst.text.status == "generated" - - -def test_coverageeligibilityresponse_1(base_settings): - """No. 1 tests collection for CoverageEligibilityResponse. - Test File: coverageeligibilityresponse-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "coverageeligibilityresponse-example.json" - ) - inst = coverageeligibilityresponse.CoverageEligibilityResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CoverageEligibilityResponse" == inst.resource_type - - impl_coverageeligibilityresponse_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CoverageEligibilityResponse" == data["resourceType"] - - inst2 = coverageeligibilityresponse.CoverageEligibilityResponse(**data) - impl_coverageeligibilityresponse_1(inst2) - - -def impl_coverageeligibilityresponse_2(inst): - assert inst.created == fhirtypes.DateTime.validate("2014-09-16T11:15:33+10:00") - assert inst.disposition == ( - "Eligibiliy request could not be processed, please address " - "errors before submitting." - ) - assert inst.error[0].code.coding[0].code == "a001" - assert ( - inst.error[0].code.coding[0].system - == "http://terminology.hl7.org/CodeSystem/adjudication-error" - ) - assert inst.form.coding[0].code == "ELRSP/2017/01" - assert inst.form.coding[0].system == "http://national.org/form" - assert inst.id == "E2503" - assert ( - inst.identifier[0].system - == "http://www.BenefitsInc.com/fhir/coverageeligibilityresponse" - ) - assert inst.identifier[0].value == "8812343" - assert inst.insurer.reference == "Organization/2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "error" - assert inst.patient.reference == "Patient/f201" - assert inst.purpose[0] == "validation" - assert inst.request.reference == ( - "http://www.BenefitsInc.com/fhir/coverageeligibilityresponse/" "225476332406" - ) - assert inst.requestor.identifier.system == "http://national.org/clinic" - assert inst.requestor.identifier.value == "OR1234" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the CoverageEligibilityResponse.
" - ) - assert inst.text.status == "generated" - - -def test_coverageeligibilityresponse_2(base_settings): - """No. 2 tests collection for CoverageEligibilityResponse. - Test File: coverageeligibilityresponse-example-error.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "coverageeligibilityresponse-example-error.json" - ) - inst = coverageeligibilityresponse.CoverageEligibilityResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CoverageEligibilityResponse" == inst.resource_type - - impl_coverageeligibilityresponse_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CoverageEligibilityResponse" == data["resourceType"] - - inst2 = coverageeligibilityresponse.CoverageEligibilityResponse(**data) - impl_coverageeligibilityresponse_2(inst2) - - -def impl_coverageeligibilityresponse_3(inst): - assert inst.contained[0].id == "coverage-1" - assert inst.created == fhirtypes.DateTime.validate("2014-09-16T11:15:33+10:00") - assert inst.disposition == "Policy is currently in-force." - assert inst.form.coding[0].code == "ELRSP/2017/01" - assert inst.form.coding[0].system == "http://national.org/form" - assert inst.id == "E2502" - assert ( - inst.identifier[0].system - == "http://www.BenefitsInc.com/fhir/coverageeligibilityresponse" - ) - assert inst.identifier[0].value == "8812342" - assert inst.insurance[0].coverage.reference == "#coverage-1" - assert inst.insurance[0].inforce is True - assert inst.insurance[0].item[0].benefit[0].allowedMoney.currency == "USD" - assert float(inst.insurance[0].item[0].benefit[0].allowedMoney.value) == float( - 500000 - ) - assert inst.insurance[0].item[0].benefit[0].type.coding[0].code == "benefit" - assert inst.insurance[0].item[0].benefit[0].usedMoney.currency == "USD" - assert float(inst.insurance[0].item[0].benefit[0].usedMoney.value) == float(3748.0) - assert inst.insurance[0].item[0].benefit[1].allowedMoney.currency == "USD" - assert float(inst.insurance[0].item[0].benefit[1].allowedMoney.value) == float(100) - assert inst.insurance[0].item[0].benefit[1].type.coding[0].code == "copay-maximum" - assert inst.insurance[0].item[0].benefit[2].allowedUnsignedInt == 20 - assert inst.insurance[0].item[0].benefit[2].type.coding[0].code == "copay-percent" - assert inst.insurance[0].item[0].category.coding[0].code == "30" - assert ( - inst.insurance[0].item[0].category.coding[0].display - == "Health Benefit Plan Coverage" - ) - assert ( - inst.insurance[0].item[0].category.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-benefitcategory" - ) - assert inst.insurance[0].item[0].network.coding[0].code == "in" - assert ( - inst.insurance[0].item[0].network.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-network" - ) - assert inst.insurance[0].item[0].term.coding[0].code == "annual" - assert ( - inst.insurance[0].item[0].term.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-term" - ) - assert inst.insurance[0].item[0].unit.coding[0].code == "individual" - assert ( - inst.insurance[0].item[0].unit.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-unit" - ) - assert inst.insurance[0].item[1].benefit[0].allowedMoney.currency == "USD" - assert float(inst.insurance[0].item[1].benefit[0].allowedMoney.value) == float( - 15000 - ) - assert inst.insurance[0].item[1].benefit[0].type.coding[0].code == "benefit" - assert inst.insurance[0].item[1].category.coding[0].code == "69" - assert inst.insurance[0].item[1].category.coding[0].display == "Maternity" - assert ( - inst.insurance[0].item[1].category.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-benefitcategory" - ) - assert inst.insurance[0].item[1].network.coding[0].code == "in" - assert ( - inst.insurance[0].item[1].network.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-network" - ) - assert inst.insurance[0].item[1].term.coding[0].code == "annual" - assert ( - inst.insurance[0].item[1].term.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-term" - ) - assert inst.insurance[0].item[1].unit.coding[0].code == "individual" - assert ( - inst.insurance[0].item[1].unit.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-unit" - ) - assert inst.insurance[0].item[2].benefit[0].allowedMoney.currency == "USD" - assert float(inst.insurance[0].item[2].benefit[0].allowedMoney.value) == float(2000) - assert inst.insurance[0].item[2].benefit[0].type.coding[0].code == "benefit" - assert inst.insurance[0].item[2].category.coding[0].code == "F3" - assert inst.insurance[0].item[2].category.coding[0].display == "Dental Coverage" - assert ( - inst.insurance[0].item[2].category.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-benefitcategory" - ) - assert inst.insurance[0].item[2].network.coding[0].code == "in" - assert ( - inst.insurance[0].item[2].network.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-network" - ) - assert inst.insurance[0].item[2].term.coding[0].code == "annual" - assert ( - inst.insurance[0].item[2].term.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-term" - ) - assert inst.insurance[0].item[2].unit.coding[0].code == "individual" - assert ( - inst.insurance[0].item[2].unit.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-unit" - ) - assert inst.insurance[0].item[3].category.coding[0].code == "F6" - assert inst.insurance[0].item[3].category.coding[0].display == "Vision Coverage" - assert ( - inst.insurance[0].item[3].category.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-benefitcategory" - ) - assert inst.insurance[0].item[3].description == ( - "Vision products and services such as exams, glasses and " "contact lenses." - ) - assert inst.insurance[0].item[3].excluded is True - assert inst.insurance[0].item[3].name == "Vision" - assert inst.insurer.reference == "Organization/2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "complete" - assert inst.patient.reference == "Patient/f201" - assert inst.purpose[0] == "validation" - assert inst.purpose[1] == "benefits" - assert inst.request.reference == ( - "http://www.BenefitsInc.com/fhir/coverageeligibilityrequest/2" "25476332405" - ) - assert inst.requestor.identifier.system == "http://national.org/clinic" - assert inst.requestor.identifier.value == "OR1234" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the CoverageEligibilityResponse.
" - ) - assert inst.text.status == "generated" - - -def test_coverageeligibilityresponse_3(base_settings): - """No. 3 tests collection for CoverageEligibilityResponse. - Test File: coverageeligibilityresponse-example-benefits-2.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "coverageeligibilityresponse-example-benefits-2.json" - ) - inst = coverageeligibilityresponse.CoverageEligibilityResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CoverageEligibilityResponse" == inst.resource_type - - impl_coverageeligibilityresponse_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CoverageEligibilityResponse" == data["resourceType"] - - inst2 = coverageeligibilityresponse.CoverageEligibilityResponse(**data) - impl_coverageeligibilityresponse_3(inst2) - - -def impl_coverageeligibilityresponse_4(inst): - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T11:15:33+10:00") - assert inst.disposition == "Policy is currently in-force." - assert inst.id == "E2501" - assert ( - inst.identifier[0].system - == "http://www.BenefitsInc.com/fhir/coverageeligibilityresponse" - ) - assert inst.identifier[0].value == "881234" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].inforce is True - assert inst.insurance[0].item[0].benefit[0].allowedMoney.currency == "SAR" - assert float(inst.insurance[0].item[0].benefit[0].allowedMoney.value) == float( - 500000 - ) - assert inst.insurance[0].item[0].benefit[0].type.coding[0].code == "benefit" - assert inst.insurance[0].item[0].benefit[1].allowedMoney.currency == "SAR" - assert float(inst.insurance[0].item[0].benefit[1].allowedMoney.value) == float(100) - assert inst.insurance[0].item[0].benefit[1].type.coding[0].code == "copay-maximum" - assert inst.insurance[0].item[0].benefit[2].allowedUnsignedInt == 20 - assert inst.insurance[0].item[0].benefit[2].type.coding[0].code == "copay-percent" - assert inst.insurance[0].item[0].category.coding[0].code == "30" - assert ( - inst.insurance[0].item[0].category.coding[0].display - == "Health Benefit Plan Coverage" - ) - assert ( - inst.insurance[0].item[0].category.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-benefitcategory" - ) - assert inst.insurance[0].item[0].network.coding[0].code == "in" - assert ( - inst.insurance[0].item[0].network.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-network" - ) - assert inst.insurance[0].item[0].term.coding[0].code == "annual" - assert ( - inst.insurance[0].item[0].term.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-term" - ) - assert inst.insurance[0].item[0].unit.coding[0].code == "individual" - assert ( - inst.insurance[0].item[0].unit.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-unit" - ) - assert inst.insurance[0].item[1].benefit[0].allowedMoney.currency == "SAR" - assert float(inst.insurance[0].item[1].benefit[0].allowedMoney.value) == float( - 15000 - ) - assert inst.insurance[0].item[1].benefit[0].type.coding[0].code == "benefit" - assert inst.insurance[0].item[1].category.coding[0].code == "69" - assert inst.insurance[0].item[1].category.coding[0].display == "Maternity" - assert ( - inst.insurance[0].item[1].category.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-benefitcategory" - ) - assert inst.insurance[0].item[1].network.coding[0].code == "in" - assert ( - inst.insurance[0].item[1].network.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-network" - ) - assert inst.insurance[0].item[1].term.coding[0].code == "annual" - assert ( - inst.insurance[0].item[1].term.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-term" - ) - assert inst.insurance[0].item[1].unit.coding[0].code == "individual" - assert ( - inst.insurance[0].item[1].unit.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-unit" - ) - assert inst.insurance[0].item[2].benefit[0].allowedMoney.currency == "SAR" - assert float(inst.insurance[0].item[2].benefit[0].allowedMoney.value) == float(2000) - assert inst.insurance[0].item[2].benefit[0].type.coding[0].code == "benefit" - assert inst.insurance[0].item[2].category.coding[0].code == "F3" - assert inst.insurance[0].item[2].category.coding[0].display == "Dental Coverage" - assert ( - inst.insurance[0].item[2].category.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-benefitcategory" - ) - assert inst.insurance[0].item[2].network.coding[0].code == "in" - assert ( - inst.insurance[0].item[2].network.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-network" - ) - assert inst.insurance[0].item[2].term.coding[0].code == "annual" - assert ( - inst.insurance[0].item[2].term.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-term" - ) - assert inst.insurance[0].item[2].unit.coding[0].code == "individual" - assert ( - inst.insurance[0].item[2].unit.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-unit" - ) - assert inst.insurance[0].item[3].benefit[0].allowedMoney.currency == "SAR" - assert float(inst.insurance[0].item[3].benefit[0].allowedMoney.value) == float(400) - assert inst.insurance[0].item[3].benefit[0].type.coding[0].code == "benefit" - assert inst.insurance[0].item[3].category.coding[0].code == "F6" - assert inst.insurance[0].item[3].category.coding[0].display == "Vision Coverage" - assert ( - inst.insurance[0].item[3].category.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-benefitcategory" - ) - assert inst.insurance[0].item[3].network.coding[0].code == "in" - assert ( - inst.insurance[0].item[3].network.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-network" - ) - assert inst.insurance[0].item[3].term.coding[0].code == "annual" - assert ( - inst.insurance[0].item[3].term.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-term" - ) - assert inst.insurance[0].item[3].unit.coding[0].code == "individual" - assert ( - inst.insurance[0].item[3].unit.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-unit" - ) - assert inst.insurance[0].item[4].benefit[0].allowedString == "shared" - assert inst.insurance[0].item[4].benefit[0].type.coding[0].code == "room" - assert inst.insurance[0].item[4].benefit[1].allowedMoney.currency == "SAR" - assert float(inst.insurance[0].item[4].benefit[1].allowedMoney.value) == float(600) - assert inst.insurance[0].item[4].benefit[1].type.coding[0].code == "benefit" - assert inst.insurance[0].item[4].category.coding[0].code == "49" - assert ( - inst.insurance[0].item[4].category.coding[0].display - == "Hospital Room and Board" - ) - assert ( - inst.insurance[0].item[4].category.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-benefitcategory" - ) - assert inst.insurance[0].item[4].network.coding[0].code == "in" - assert ( - inst.insurance[0].item[4].network.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-network" - ) - assert inst.insurance[0].item[4].term.coding[0].code == "day" - assert ( - inst.insurance[0].item[4].term.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-term" - ) - assert inst.insurance[0].item[4].unit.coding[0].code == "individual" - assert ( - inst.insurance[0].item[4].unit.coding[0].system - == "http://terminology.hl7.org/CodeSystem/benefit-unit" - ) - assert inst.insurer.reference == "Organization/2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "complete" - assert inst.patient.reference == "Patient/pat1" - assert inst.purpose[0] == "validation" - assert inst.purpose[1] == "benefits" - assert inst.request.reference == ( - "http://www.BenefitsInc.com/fhir/coverageeligibilityresponse/" "225476332402" - ) - assert inst.servicedDate == fhirtypes.Date.validate("2014-09-17") - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the CoverageEligibilityResponse.
" - ) - assert inst.text.status == "generated" - - -def test_coverageeligibilityresponse_4(base_settings): - """No. 4 tests collection for CoverageEligibilityResponse. - Test File: coverageeligibilityresponse-example-benefits.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "coverageeligibilityresponse-example-benefits.json" - ) - inst = coverageeligibilityresponse.CoverageEligibilityResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "CoverageEligibilityResponse" == inst.resource_type - - impl_coverageeligibilityresponse_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "CoverageEligibilityResponse" == data["resourceType"] - - inst2 = coverageeligibilityresponse.CoverageEligibilityResponse(**data) - impl_coverageeligibilityresponse_4(inst2) diff --git a/fhir/resources/tests/test_detectedissue.py b/fhir/resources/tests/test_detectedissue.py deleted file mode 100644 index 00e91cb1..00000000 --- a/fhir/resources/tests/test_detectedissue.py +++ /dev/null @@ -1,203 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DetectedIssue -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import detectedissue - - -def impl_detectedissue_1(inst): - assert inst.id == "allergy" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "final" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_detectedissue_1(base_settings): - """No. 1 tests collection for DetectedIssue. - Test File: detectedissue-example-allergy.json - """ - filename = base_settings["unittest_data_dir"] / "detectedissue-example-allergy.json" - inst = detectedissue.DetectedIssue.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DetectedIssue" == inst.resource_type - - impl_detectedissue_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DetectedIssue" == data["resourceType"] - - inst2 = detectedissue.DetectedIssue(**data) - impl_detectedissue_1(inst2) - - -def impl_detectedissue_2(inst): - assert inst.author.reference == "Device/software" - assert inst.code.coding[0].code == "DUPTHPY" - assert inst.code.coding[0].display == "Duplicate Therapy Alert" - assert ( - inst.code.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.detail == "Similar test was performed within the past 14 days" - assert inst.id == "duplicate" - assert inst.identifiedDateTime == fhirtypes.DateTime.validate( - "2013-05-08T09:23:00+10:00" - ) - assert inst.identifier[0].system == "http://example.org" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345" - assert ( - inst.implicated[0].display - == "Chest CT - ordered May 8, 2013 by Dr. Adam Careful" - ) - assert inst.implicated[0].reference == "ServiceRequest/di" - assert inst.implicated[1].display == ( - "Image 1 from Series 3: CT Images on Patient MINT (MINT1234) " - "taken at 1-Jan 2011 01:20 AM" - ) - assert inst.implicated[1].reference == "ImagingStudy/example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/dicom" - assert inst.reference == ( - "http://www.tmhp.com/RadiologyClinicalDecisionSupport/2011/CH" - "EST%20IMAGING%20GUIDELINES%202011.pdf" - ) - assert inst.status == "final" - assert inst.text.status == "generated" - - -def test_detectedissue_2(base_settings): - """No. 2 tests collection for DetectedIssue. - Test File: detectedissue-example-dup.json - """ - filename = base_settings["unittest_data_dir"] / "detectedissue-example-dup.json" - inst = detectedissue.DetectedIssue.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DetectedIssue" == inst.resource_type - - impl_detectedissue_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DetectedIssue" == data["resourceType"] - - inst2 = detectedissue.DetectedIssue(**data) - impl_detectedissue_2(inst2) - - -def impl_detectedissue_3(inst): - assert inst.author.reference == "Device/software" - assert inst.code.coding[0].code == "DRG" - assert inst.code.coding[0].display == "Drug Interaction Alert" - assert ( - inst.code.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.id == "ddi" - assert inst.identifiedDateTime == fhirtypes.DateTime.validate( - "2014-01-05T09:23:00+10:00" - ) - assert ( - inst.implicated[0].display - == "500 mg Acetaminophen tablet 1/day, PRN since 2010" - ) - assert inst.implicated[0].reference == "MedicationStatement/example001" - assert inst.implicated[1].display == "Warfarin 1 MG TAB prescribed Jan. 15, 2015" - assert inst.implicated[1].reference == "MedicationRequest/medrx0331" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mitigation[0].action.coding[0].code == "13" - assert inst.mitigation[0].action.coding[0].display == "Stopped Concurrent Therapy" - assert ( - inst.mitigation[0].action.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.mitigation[0].action.text == ( - "Asked patient to discontinue regular use of Tylenol and to " - "consult with clinician if they need to resume to allow " - "appropriate INR monitoring" - ) - assert inst.mitigation[0].author.display == "Dr. Adam Careful" - assert inst.mitigation[0].author.reference == "Practitioner/example" - assert inst.mitigation[0].date == fhirtypes.DateTime.validate( - "2014-01-05T09:23:00+10:00" - ) - assert inst.severity == "high" - assert inst.status == "final" - assert inst.text.status == "generated" - - -def test_detectedissue_3(base_settings): - """No. 3 tests collection for DetectedIssue. - Test File: detectedissue-example.json - """ - filename = base_settings["unittest_data_dir"] / "detectedissue-example.json" - inst = detectedissue.DetectedIssue.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DetectedIssue" == inst.resource_type - - impl_detectedissue_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DetectedIssue" == data["resourceType"] - - inst2 = detectedissue.DetectedIssue(**data) - impl_detectedissue_3(inst2) - - -def impl_detectedissue_4(inst): - assert inst.id == "lab" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "final" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_detectedissue_4(base_settings): - """No. 4 tests collection for DetectedIssue. - Test File: detectedissue-example-lab.json - """ - filename = base_settings["unittest_data_dir"] / "detectedissue-example-lab.json" - inst = detectedissue.DetectedIssue.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DetectedIssue" == inst.resource_type - - impl_detectedissue_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DetectedIssue" == data["resourceType"] - - inst2 = detectedissue.DetectedIssue(**data) - impl_detectedissue_4(inst2) diff --git a/fhir/resources/tests/test_device.py b/fhir/resources/tests/test_device.py deleted file mode 100644 index e80c552c..00000000 --- a/fhir/resources/tests/test_device.py +++ /dev/null @@ -1,90 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Device -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import device - - -def impl_device_1(inst): - assert inst.id == "f001" - assert inst.identifier[0].system == "http:/goodhealthhospital/identifier/devices" - assert inst.identifier[0].value == "12345" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "active" - assert inst.text.div == ( - '

Generated ' - "Narrative with Details

id: " - "f001

identifier: 12345

status: " - "active

" - ) - assert inst.text.status == "generated" - - -def test_device_1(base_settings): - """No. 1 tests collection for Device. - Test File: device-example-f001-feedingtube.json - """ - filename = ( - base_settings["unittest_data_dir"] / "device-example-f001-feedingtube.json" - ) - inst = device.Device.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Device" == inst.resource_type - - impl_device_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Device" == data["resourceType"] - - inst2 = device.Device(**data) - impl_device_1(inst2) - - -def impl_device_2(inst): - assert inst.id == "example" - assert inst.identifier[0].system == "http://goodcare.org/devices/id" - assert inst.identifier[0].value == "345675" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.div == ( - '

Generated ' - "Narrative with Details

id: " - "example

identifier: 345675

" - ) - assert inst.text.status == "generated" - - -def test_device_2(base_settings): - """No. 2 tests collection for Device. - Test File: device-example.json - """ - filename = base_settings["unittest_data_dir"] / "device-example.json" - inst = device.Device.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Device" == inst.resource_type - - impl_device_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Device" == data["resourceType"] - - inst2 = device.Device(**data) - impl_device_2(inst2) diff --git a/fhir/resources/tests/test_devicedefinition.py b/fhir/resources/tests/test_devicedefinition.py deleted file mode 100644 index 0b013d9d..00000000 --- a/fhir/resources/tests/test_devicedefinition.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DeviceDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import devicedefinition - - -def impl_devicedefinition_1(inst): - assert inst.id == "example" - assert inst.identifier[0].value == "0" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.div == ( - '

Generated ' - "Narrative with Details

id: " - "example

identifier: 0

" - ) - assert inst.text.status == "generated" - - -def test_devicedefinition_1(base_settings): - """No. 1 tests collection for DeviceDefinition. - Test File: devicedefinition-example.json - """ - filename = base_settings["unittest_data_dir"] / "devicedefinition-example.json" - inst = devicedefinition.DeviceDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DeviceDefinition" == inst.resource_type - - impl_devicedefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DeviceDefinition" == data["resourceType"] - - inst2 = devicedefinition.DeviceDefinition(**data) - impl_devicedefinition_1(inst2) diff --git a/fhir/resources/tests/test_devicemetric.py b/fhir/resources/tests/test_devicemetric.py deleted file mode 100644 index 9fe7ab59..00000000 --- a/fhir/resources/tests/test_devicemetric.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DeviceMetric -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import devicemetric - - -def impl_devicemetric_1(inst): - assert inst.calibration[0].state == "calibrated" - assert inst.calibration[0].time == fhirtypes.Instant.validate( - "2016-12-28T09:03:04-05:00" - ) - assert inst.calibration[0].type == "two-point" - assert inst.category == "measurement" - assert inst.color == "blue" - assert inst.id == "example" - assert inst.identifier[0].system == "http://goodcare.org/devicemetric/id" - assert inst.identifier[0].value == "345675" - assert inst.measurementPeriod.repeat.frequency == 1 - assert float(inst.measurementPeriod.repeat.period) == float(1) - assert inst.measurementPeriod.repeat.periodUnit == "s" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.operationalStatus == "on" - assert inst.parent.reference == "DeviceDefinition/dc102" - assert inst.source.reference == "Device/dev1" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "150456" - assert inst.type.coding[0].display == "MDC_PULS_OXIM_SAT_O2" - assert inst.type.coding[0].system == "urn:iso:std:iso:11073:10101" - assert inst.unit.coding[0].code == "262688" - assert inst.unit.coding[0].display == "MDC_DIM_PERCENT" - assert inst.unit.coding[0].system == "urn:iso:std:iso:11073:10101" - - -def test_devicemetric_1(base_settings): - """No. 1 tests collection for DeviceMetric. - Test File: devicemetric-example.json - """ - filename = base_settings["unittest_data_dir"] / "devicemetric-example.json" - inst = devicemetric.DeviceMetric.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DeviceMetric" == inst.resource_type - - impl_devicemetric_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DeviceMetric" == data["resourceType"] - - inst2 = devicemetric.DeviceMetric(**data) - impl_devicemetric_1(inst2) diff --git a/fhir/resources/tests/test_devicerequest.py b/fhir/resources/tests/test_devicerequest.py deleted file mode 100644 index d63282f6..00000000 --- a/fhir/resources/tests/test_devicerequest.py +++ /dev/null @@ -1,260 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DeviceRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import devicerequest - - -def impl_devicerequest_1(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2013-05-08T09:33:27+07:00") - assert inst.basedOn[0].display == "Homecare - DM follow-up" - assert inst.codeCodeableConcept.coding[0].code == "43148-6" - assert inst.codeCodeableConcept.coding[0].system == "http://loinc.org" - assert inst.codeCodeableConcept.text == "Insulin delivery device panel" - assert inst.encounter.display == "Encounter 1" - assert inst.groupIdentifier.value == "ip_request1" - assert inst.id == "insulinpump" - assert inst.identifier[0].value == "ip_request1.1" - assert inst.instantiatesCanonical[0] == ( - "http://motivemi.com/artifacts/PlanDefinition/low-suicide-" "risk-order-set" - ) - assert inst.intent == "instance-order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "this is the right device brand and model" - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2013-05-08T09:33:27+07:00" - ) - assert inst.performer.display == "Nurse Rossignol" - assert inst.performerType.coding[0].display == "Qualified nurse" - assert inst.performerType.text == "Nurse" - assert inst.priorRequest[0].display == "CGM ambulatory" - assert inst.priority == "routine" - assert inst.reasonCode[0].text == "gastroparesis" - assert inst.reasonReference[0].display == "Gastroparesis" - assert inst.relevantHistory[0].display == "Request for unspecified device" - assert inst.requester.display == "Dr. Adam Careful" - assert inst.requester.reference == "Practitioner/example" - assert inst.status == "active" - assert inst.subject.reference == "Patient/dicom" - assert inst.supportingInfo[0].display == "Previous results" - assert inst.text.status == "generated" - - -def test_devicerequest_1(base_settings): - """No. 1 tests collection for DeviceRequest. - Test File: devicerequest-example-insulinpump.json - """ - filename = ( - base_settings["unittest_data_dir"] / "devicerequest-example-insulinpump.json" - ) - inst = devicerequest.DeviceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DeviceRequest" == inst.resource_type - - impl_devicerequest_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DeviceRequest" == data["resourceType"] - - inst2 = devicerequest.DeviceRequest(**data) - impl_devicerequest_1(inst2) - - -def impl_devicerequest_2(inst): - assert inst.codeCodeableConcept.coding[0].code == "lens" - assert inst.codeCodeableConcept.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/ex-" "visionprescriptionproduct" - ) - assert inst.groupIdentifier.system == "http://acme.org" - assert inst.groupIdentifier.value == "15013" - assert inst.id == "left-lens" - assert inst.identifier[0].system == "http://www.happysight.com/prescription" - assert inst.identifier[0].value == "15013L" - assert inst.intent == "original-order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2014-06-15T09:23:00+10:00" - ) - assert inst.parameter[0].code.coding[0].code == "28842-3" - assert ( - inst.parameter[0].code.coding[0].display - == "Sphere distance Glasses prescription.lens - left" - ) - assert inst.parameter[0].code.coding[0].system == "http://loinc.org" - assert inst.parameter[0].code.text == "sphere, left lens" - assert inst.parameter[0].valueQuantity.code == "[diop]" - assert inst.parameter[0].valueQuantity.system == "http://unitsofmeasure.org" - assert inst.parameter[0].valueQuantity.unit == "Diopter" - assert float(inst.parameter[0].valueQuantity.value) == float(-1.0) - assert inst.parameter[1].code.coding[0].code == "28843-1" - assert ( - inst.parameter[1].code.coding[0].display - == "Cylinder base distance Glasses prescription.lens - left" - ) - assert inst.parameter[1].code.coding[0].system == "http://loinc.org" - assert inst.parameter[1].code.text == "cylinder, left lens" - assert inst.parameter[1].valueQuantity.code == "[diop]" - assert inst.parameter[1].valueQuantity.system == "http://unitsofmeasure.org" - assert inst.parameter[1].valueQuantity.unit == "Diopter" - assert float(inst.parameter[1].valueQuantity.value) == float(-0.5) - assert inst.parameter[2].code.coding[0].code == "28844-9" - assert ( - inst.parameter[2].code.coding[0].display - == " Axis distance Glasses prescription.lens - left" - ) - assert inst.parameter[2].code.coding[0].system == "http://loinc.org" - assert inst.parameter[2].code.text == "axis, left lens" - assert inst.parameter[2].valueQuantity.code == "deg" - assert inst.parameter[2].valueQuantity.system == "http://unitsofmeasure.org" - assert inst.parameter[2].valueQuantity.unit == "Degrees" - assert float(inst.parameter[2].valueQuantity.value) == float(180) - assert inst.requester.reference == "Practitioner/example" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_devicerequest_2(base_settings): - """No. 2 tests collection for DeviceRequest. - Test File: devicerequest-left-lens.json - """ - filename = base_settings["unittest_data_dir"] / "devicerequest-left-lens.json" - inst = devicerequest.DeviceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DeviceRequest" == inst.resource_type - - impl_devicerequest_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DeviceRequest" == data["resourceType"] - - inst2 = devicerequest.DeviceRequest(**data) - impl_devicerequest_2(inst2) - - -def impl_devicerequest_3(inst): - assert inst.codeCodeableConcept.coding[0].code == "lens" - assert inst.codeCodeableConcept.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/ex-" "visionprescriptionproduct" - ) - assert inst.groupIdentifier.system == "http://acme.org" - assert inst.groupIdentifier.value == "15013" - assert inst.id == "right-lens" - assert inst.identifier[0].system == "http://www.happysight.com/prescription" - assert inst.identifier[0].value == "15013R" - assert inst.intent == "original-order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2014-06-15T09:23:00+10:00" - ) - assert inst.parameter[0].code.coding[0].code == "28826-6" - assert ( - inst.parameter[0].code.coding[0].display - == "Sphere distance Glasses prescription.lens - right" - ) - assert inst.parameter[0].code.coding[0].system == "http://loinc.org" - assert inst.parameter[0].code.text == "sphere, right lens" - assert inst.parameter[0].valueQuantity.code == "[diop]" - assert inst.parameter[0].valueQuantity.system == "http://unitsofmeasure.org" - assert inst.parameter[0].valueQuantity.unit == "Diopter" - assert float(inst.parameter[0].valueQuantity.value) == float(-2.0) - assert inst.parameter[1].code.coding[0].code == "28829-0" - assert ( - inst.parameter[1].code.coding[0].display - == "Prism base distance Glasses prescription.lens - right" - ) - assert inst.parameter[1].code.coding[0].system == "http://loinc.org" - assert inst.parameter[1].code.text == "prisms, right lens" - assert inst.parameter[1].valueQuantity.code == "[diop]" - assert inst.parameter[1].valueQuantity.system == "http://unitsofmeasure.org" - assert inst.parameter[1].valueQuantity.unit == "Diopter" - assert float(inst.parameter[1].valueQuantity.value) == float(-2.0) - assert inst.parameter[2].code.coding[0].code == "28810-0" - assert inst.parameter[2].code.coding[0].display == "Add 1 LM glasses lens - right" - assert inst.parameter[2].code.coding[0].system == "http://loinc.org" - assert inst.parameter[2].code.text == "add, right lens" - assert inst.parameter[2].valueQuantity.code == "[diop]" - assert inst.parameter[2].valueQuantity.system == "http://unitsofmeasure.org" - assert inst.parameter[2].valueQuantity.unit == "Diopter" - assert float(inst.parameter[2].valueQuantity.value) == float(2.0) - assert inst.requester.reference == "Practitioner/example" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_devicerequest_3(base_settings): - """No. 3 tests collection for DeviceRequest. - Test File: devicerequest-right-lens.json - """ - filename = base_settings["unittest_data_dir"] / "devicerequest-right-lens.json" - inst = devicerequest.DeviceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DeviceRequest" == inst.resource_type - - impl_devicerequest_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DeviceRequest" == data["resourceType"] - - inst2 = devicerequest.DeviceRequest(**data) - impl_devicerequest_3(inst2) - - -def impl_devicerequest_4(inst): - assert inst.codeReference.reference == "Device/example" - assert inst.id == "example" - assert inst.intent == "original-order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_devicerequest_4(base_settings): - """No. 4 tests collection for DeviceRequest. - Test File: devicerequest-example.json - """ - filename = base_settings["unittest_data_dir"] / "devicerequest-example.json" - inst = devicerequest.DeviceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DeviceRequest" == inst.resource_type - - impl_devicerequest_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DeviceRequest" == data["resourceType"] - - inst2 = devicerequest.DeviceRequest(**data) - impl_devicerequest_4(inst2) diff --git a/fhir/resources/tests/test_deviceusestatement.py b/fhir/resources/tests/test_deviceusestatement.py deleted file mode 100644 index 6595682b..00000000 --- a/fhir/resources/tests/test_deviceusestatement.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DeviceUseStatement -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import deviceusestatement - - -def impl_deviceusestatement_1(inst): - assert inst.device.reference == "Device/example" - assert inst.id == "example" - assert inst.identifier[0].system == "http:goodhealth.org/identifiers" - assert inst.identifier[0].value == "51ebb7a9-4e3a-4360-9a05-0cc2d869086f" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.reasonReference[0].display == "Appendectomy (surgery)" - assert inst.reasonReference[0].reference == "Procedure/example" - assert inst.status == "active" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_deviceusestatement_1(base_settings): - """No. 1 tests collection for DeviceUseStatement. - Test File: deviceusestatement-example.json - """ - filename = base_settings["unittest_data_dir"] / "deviceusestatement-example.json" - inst = deviceusestatement.DeviceUseStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DeviceUseStatement" == inst.resource_type - - impl_deviceusestatement_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DeviceUseStatement" == data["resourceType"] - - inst2 = deviceusestatement.DeviceUseStatement(**data) - impl_deviceusestatement_1(inst2) diff --git a/fhir/resources/tests/test_diagnosticreport.py b/fhir/resources/tests/test_diagnosticreport.py deleted file mode 100644 index e83af491..00000000 --- a/fhir/resources/tests/test_diagnosticreport.py +++ /dev/null @@ -1,343 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DiagnosticReport -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import diagnosticreport - - -def impl_diagnosticreport_1(inst): - assert inst.category[0].coding[0].code == "394914008" - assert inst.category[0].coding[0].display == "Radiology" - assert inst.category[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].coding[1].code == "RAD" - assert ( - inst.category[0].coding[1].system - == "http://terminology.hl7.org/CodeSystem/v2-0074" - ) - assert inst.code.coding[0].code == "45036003" - assert inst.code.coding[0].display == "Ultrasonography of abdomen" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Abdominal Ultrasound" - assert inst.conclusion == "Unremarkable study" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2012-12-01T12:00:00+01:00" - ) - assert inst.id == "ultrasound" - assert inst.issued == fhirtypes.Instant.validate("2012-12-01T12:00:00+01:00") - assert inst.media[0].comment == "A comment about the image" - assert inst.media[0].link.display == "WADO example image" - assert ( - inst.media[0].link.reference - == "Media/1.2.840.11361907579238403408700.3.1.04.19970327150033" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].reference == "Practitioner/example" - assert inst.status == "final" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_diagnosticreport_1(base_settings): - """No. 1 tests collection for DiagnosticReport. - Test File: diagnosticreport-example-ultrasound.json - """ - filename = ( - base_settings["unittest_data_dir"] / "diagnosticreport-example-ultrasound.json" - ) - inst = diagnosticreport.DiagnosticReport.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DiagnosticReport" == inst.resource_type - - impl_diagnosticreport_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DiagnosticReport" == data["resourceType"] - - inst2 = diagnosticreport.DiagnosticReport(**data) - impl_diagnosticreport_1(inst2) - - -def impl_diagnosticreport_2(inst): - assert inst.category[0].coding[0].code == "394914008" - assert inst.category[0].coding[0].display == "Radiology" - assert inst.category[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].coding[1].code == "RAD" - assert ( - inst.category[0].coding[1].system - == "http://terminology.hl7.org/CodeSystem/v2-0074" - ) - assert inst.code.coding[0].code == "429858000" - assert inst.code.coding[0].display == "Computed tomography (CT) of head and neck" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "CT of head-neck" - assert inst.conclusion == "CT brains: large tumor sphenoid/clivus." - assert inst.conclusionCode[0].coding[0].code == "188340000" - assert ( - inst.conclusionCode[0].coding[0].display - == "Malignant tumor of craniopharyngeal duct" - ) - assert inst.conclusionCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2012-12-01T12:00:00+01:00" - ) - assert inst.id == "f201" - assert inst.imagingStudy[0].display == "HEAD and NECK CT DICOM imaging study" - assert inst.issued == fhirtypes.Instant.validate("2012-12-01T12:00:00+01:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].display == "Blijdorp MC" - assert inst.performer[0].reference == "Organization/f203" - assert inst.status == "final" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - - -def test_diagnosticreport_2(base_settings): - """No. 2 tests collection for DiagnosticReport. - Test File: diagnosticreport-example-f201-brainct.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "diagnosticreport-example-f201-brainct.json" - ) - inst = diagnosticreport.DiagnosticReport.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DiagnosticReport" == inst.resource_type - - impl_diagnosticreport_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DiagnosticReport" == data["resourceType"] - - inst2 = diagnosticreport.DiagnosticReport(**data) - impl_diagnosticreport_2(inst2) - - -def impl_diagnosticreport_3(inst): - assert inst.code.coding[0].code == "47527-7" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2013-02-11T10:33:33+11:00" - ) - assert inst.id == "pap" - assert inst.issued == fhirtypes.Instant.validate("2013-02-13T11:45:33+11:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].reference == "Practitioner/example" - assert inst.status == "final" - assert inst.subject.reference == "Patient/b248b1b2-1686-4b94-9936-37d7a5f94b51" - assert inst.text.status == "additional" - - -def test_diagnosticreport_3(base_settings): - """No. 3 tests collection for DiagnosticReport. - Test File: diagnosticreport-example-papsmear.json - """ - filename = ( - base_settings["unittest_data_dir"] / "diagnosticreport-example-papsmear.json" - ) - inst = diagnosticreport.DiagnosticReport.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DiagnosticReport" == inst.resource_type - - impl_diagnosticreport_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DiagnosticReport" == data["resourceType"] - - inst2 = diagnosticreport.DiagnosticReport(**data) - impl_diagnosticreport_3(inst2) - - -def impl_diagnosticreport_4(inst): - assert inst.category[0].coding[0].code == "PAT" - assert ( - inst.category[0].coding[0].display - == "Pathology (gross & histopath, not surgical)" - ) - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0074" - ) - assert inst.category[0].text == "Pathology" - assert inst.code.coding[0].code == "4503" - assert inst.code.coding[0].display == ( - "Biopsy without Microscopic Description (1 " "Site/Lesion)-Standard" - ) - assert inst.code.coding[0].system == "https://www.acmeonline.com" - assert inst.code.text == ( - "Biopsy without Microscopic Description (1 " "Site/Lesion)-Standard" - ) - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2017-03-02T09:23:00+10:00" - ) - assert inst.id == "gingival-mass" - assert inst.identifier[0].system == "https://www.acmeonline.com" - assert inst.identifier[0].value == "P73456090" - assert inst.issued == fhirtypes.Instant.validate("2017-03-15T08:13:08Z") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].display == "Acme Animal Labs" - assert inst.presentedForm[0].contentType == "application/pdf" - assert inst.presentedForm[0].language == "en" - assert inst.presentedForm[0].title == ( - "LAB ID: P73456090 MAX JONES Biopsy without Microscopic " - "Description (1 Site/Lesion)-Standard" - ) - assert inst.status == "final" - assert inst.subject.display == "Max Jones" - assert inst.text.status == "generated" - - -def test_diagnosticreport_4(base_settings): - """No. 4 tests collection for DiagnosticReport. - Test File: diagnosticreport-example-gingival-mass.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "diagnosticreport-example-gingival-mass.json" - ) - inst = diagnosticreport.DiagnosticReport.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DiagnosticReport" == inst.resource_type - - impl_diagnosticreport_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DiagnosticReport" == data["resourceType"] - - inst2 = diagnosticreport.DiagnosticReport(**data) - impl_diagnosticreport_4(inst2) - - -def impl_diagnosticreport_5(inst): - assert inst.basedOn[0].reference == "ServiceRequest/example-pgx" - assert inst.code.coding[0].code == "PGxReport" - assert inst.code.coding[0].display == "Pharmacogenetics Report" - assert inst.code.coding[0].system == "https://system/PGxReport" - assert inst.code.text == "Pharmacogenetics Report" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2016-10-15T12:34:56+11:00" - ) - assert inst.id == "example-pgx" - assert inst.issued == fhirtypes.Instant.validate("2016-10-20T14:00:05+11:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].reference == "Organization/4829" - assert inst.presentedForm[0].contentType == "application/pdf" - assert inst.presentedForm[0].creation == fhirtypes.DateTime.validate( - "2016-10-20T20:00:00+11:00" - ) - assert inst.presentedForm[0].data == bytes_validator("cGRmSW5CYXNlNjRCaW5hcnk=") - assert inst.presentedForm[0].hash == bytes_validator( - "571ef9c5655840f324e679072ed62b1b95eef8a0" - ) - assert inst.presentedForm[0].language == "en" - assert inst.presentedForm[0].title == "Pharmacogenetics Report" - assert inst.result[0].reference == "Observation/example-phenotype" - assert inst.status == "final" - assert inst.subject.display == "Bob Smith" - assert inst.subject.reference == "Patient/899962" - assert inst.text.status == "generated" - - -def test_diagnosticreport_5(base_settings): - """No. 5 tests collection for DiagnosticReport. - Test File: diagnosticreport-example-pgx.json - """ - filename = base_settings["unittest_data_dir"] / "diagnosticreport-example-pgx.json" - inst = diagnosticreport.DiagnosticReport.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DiagnosticReport" == inst.resource_type - - impl_diagnosticreport_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DiagnosticReport" == data["resourceType"] - - inst2 = diagnosticreport.DiagnosticReport(**data) - impl_diagnosticreport_5(inst2) - - -def impl_diagnosticreport_6(inst): - assert inst.code.coding[0].code == "38269-7" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.code.text == "DXA BONE DENSITOMETRY" - assert inst.conclusionCode[0].coding[0].code == "391040000" - assert ( - inst.conclusionCode[0].coding[0].display == "At risk of osteoporotic fracture" - ) - assert inst.conclusionCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2008-06-17T09:23:00+10:00" - ) - assert inst.id == "102" - assert inst.issued == fhirtypes.Instant.validate("2008-06-18T09:23:00+10:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].display == "Dr Henry Seven" - assert ( - inst.performer[0].reference - == "Practitioner/3ad0687e-f477-468c-afd5-fcc2bf897809" - ) - assert inst.result[0].reference == "Observation/bmd" - assert inst.status == "final" - assert inst.subject.reference == "Patient/pat2" - assert inst.text.status == "generated" - - -def test_diagnosticreport_6(base_settings): - """No. 6 tests collection for DiagnosticReport. - Test File: diagnosticreport-example-dxa.json - """ - filename = base_settings["unittest_data_dir"] / "diagnosticreport-example-dxa.json" - inst = diagnosticreport.DiagnosticReport.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DiagnosticReport" == inst.resource_type - - impl_diagnosticreport_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DiagnosticReport" == data["resourceType"] - - inst2 = diagnosticreport.DiagnosticReport(**data) - impl_diagnosticreport_6(inst2) diff --git a/fhir/resources/tests/test_documentmanifest.py b/fhir/resources/tests/test_documentmanifest.py deleted file mode 100644 index 7ab6eb59..00000000 --- a/fhir/resources/tests/test_documentmanifest.py +++ /dev/null @@ -1,115 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DocumentManifest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import documentmanifest - - -def impl_documentmanifest_1(inst): - assert inst.author[0].reference == "#a1" - assert inst.contained[0].id == "a1" - assert inst.content[0].reference == "DocumentReference/example" - assert inst.created == fhirtypes.DateTime.validate("2004-12-25T23:50:50-05:00") - assert inst.description == "Physical" - assert inst.id == "example" - assert inst.identifier[0].system == "http://example.org/documents" - assert inst.identifier[0].value == "23425234234-2347" - assert inst.masterIdentifier.system == "http://example.org/documents" - assert inst.masterIdentifier.value == "23425234234-2346" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.recipient[0].reference == "Practitioner/xcda1" - assert inst.related[0].identifier.system == "http://example.org/documents" - assert inst.related[0].identifier.value == "23425234234-9999" - assert inst.related[0].ref.reference == "DocumentReference/example" - assert inst.source == "urn:oid:1.3.6.1.4.1.21367.2009.1.2.1" - assert inst.status == "current" - assert inst.subject.reference == "Patient/xcda" - assert inst.text.div == '
Text
' - assert inst.text.status == "generated" - assert inst.type.text == "History and Physical" - - -def test_documentmanifest_1(base_settings): - """No. 1 tests collection for DocumentManifest. - Test File: documentmanifest-example.json - """ - filename = base_settings["unittest_data_dir"] / "documentmanifest-example.json" - inst = documentmanifest.DocumentManifest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DocumentManifest" == inst.resource_type - - impl_documentmanifest_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DocumentManifest" == data["resourceType"] - - inst2 = documentmanifest.DocumentManifest(**data) - impl_documentmanifest_1(inst2) - - -def impl_documentmanifest_2(inst): - assert inst.contained[0].id == "org-1" - assert inst.contained[1].id == "a1" - assert inst.contained[2].id == "a2" - assert inst.content[0].reference == "#a1" - assert inst.content[1].reference == "#a2" - assert inst.content[2].reference == "DocumentReference/example" - assert inst.content[3].reference == "DiagnosticReport/f001" - assert inst.created == fhirtypes.DateTime.validate("2014-09-21T11:50:23-05:00") - assert inst.id == "654789" - assert inst.identifier[0].system == "http://happyvalley.com/supportingdocumentation" - assert inst.identifier[0].value == "52345" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.recipient[0].reference == "#org-1" - assert inst.related[0].identifier.system == "http://happyvalley.com/claim" - assert inst.related[0].identifier.value == "12345" - assert ( - inst.related[1].identifier.system - == "http://www.BenefitsInc.com/fhir/remittance" - ) - assert inst.related[1].identifier.value == "R3500" - assert inst.status == "current" - assert inst.text.div == ( - '
A Financial ' - "Management Attachment example
" - ) - assert inst.text.status == "generated" - - -def test_documentmanifest_2(base_settings): - """No. 2 tests collection for DocumentManifest. - Test File: documentmanifest-fm-attachment.json - """ - filename = ( - base_settings["unittest_data_dir"] / "documentmanifest-fm-attachment.json" - ) - inst = documentmanifest.DocumentManifest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DocumentManifest" == inst.resource_type - - impl_documentmanifest_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DocumentManifest" == data["resourceType"] - - inst2 = documentmanifest.DocumentManifest(**data) - impl_documentmanifest_2(inst2) diff --git a/fhir/resources/tests/test_documentreference.py b/fhir/resources/tests/test_documentreference.py deleted file mode 100644 index 8aa7055e..00000000 --- a/fhir/resources/tests/test_documentreference.py +++ /dev/null @@ -1,120 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/DocumentReference -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import documentreference - - -def impl_documentreference_1(inst): - assert inst.authenticator.reference == "Organization/f001" - assert inst.author[0].reference == "Practitioner/xcda1" - assert inst.author[1].reference == "#a2" - assert inst.category[0].coding[0].code == "History and Physical" - assert inst.category[0].coding[0].display == "History and Physical" - assert ( - inst.category[0].coding[0].system - == "http://ihe.net/xds/connectathon/classCodes" - ) - assert inst.contained[0].id == "a2" - assert inst.content[0].attachment.contentType == "application/hl7-v3+xml" - assert inst.content[0].attachment.creation == fhirtypes.DateTime.validate( - "2005-12-24T09:35:00+11:00" - ) - assert inst.content[0].attachment.hash == bytes_validator( - "2jmj7l5rSw0yVb/vlWAYkK/YBwk=" - ) - assert inst.content[0].attachment.language == "en-US" - assert inst.content[0].attachment.size == 3654 - assert inst.content[0].attachment.title == "Physical" - assert inst.content[0].attachment.url == ( - "http://example.org/xds/mhd/Binary/07a6483f-732b-461e-86b6-ed" "b665c45510" - ) - assert inst.content[0].format.code == "urn:ihe:pcc:handp:2008" - assert inst.content[0].format.display == "History and Physical Specification" - assert inst.content[0].format.system == "urn:oid:1.3.6.1.4.1.19376.1.2.3" - assert inst.context.encounter[0].reference == "Encounter/xcda" - assert inst.context.event[0].coding[0].code == "T-D8200" - assert inst.context.event[0].coding[0].display == "Arm" - assert ( - inst.context.event[0].coding[0].system - == "http://ihe.net/xds/connectathon/eventCodes" - ) - assert inst.context.facilityType.coding[0].code == "Outpatient" - assert inst.context.facilityType.coding[0].display == "Outpatient" - assert inst.context.facilityType.coding[0].system == ( - "http://www.ihe.net/xds/connectathon/healthcareFacilityTypeCo" "des" - ) - assert inst.context.period.end == fhirtypes.DateTime.validate( - "2004-12-23T08:01:00+11:00" - ) - assert inst.context.period.start == fhirtypes.DateTime.validate( - "2004-12-23T08:00:00+11:00" - ) - assert inst.context.practiceSetting.coding[0].code == "General Medicine" - assert inst.context.practiceSetting.coding[0].display == "General Medicine" - assert ( - inst.context.practiceSetting.coding[0].system - == "http://www.ihe.net/xds/connectathon/practiceSettingCodes" - ) - assert inst.context.related[0].identifier.system == "urn:ietf:rfc:3986" - assert ( - inst.context.related[0].identifier.value - == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.2345" - ) - assert inst.context.related[0].reference == "Patient/xcda" - assert inst.context.sourcePatientInfo.reference == "Patient/xcda" - assert inst.custodian.reference == "Organization/f001" - assert inst.date == fhirtypes.Instant.validate("2005-12-24T09:43:41+11:00") - assert inst.description == "Physical" - assert inst.docStatus == "preliminary" - assert inst.id == "example" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.1234" - assert inst.masterIdentifier.system == "urn:ietf:rfc:3986" - assert inst.masterIdentifier.value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.relatesTo[0].code == "appends" - assert inst.relatesTo[0].target.reference == "DocumentReference/example" - assert inst.securityLabel[0].coding[0].code == "V" - assert inst.securityLabel[0].coding[0].display == "very restricted" - assert ( - inst.securityLabel[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-Confidentiality" - ) - assert inst.status == "current" - assert inst.subject.reference == "Patient/xcda" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "34108-1" - assert inst.type.coding[0].display == "Outpatient Note" - assert inst.type.coding[0].system == "http://loinc.org" - - -def test_documentreference_1(base_settings): - """No. 1 tests collection for DocumentReference. - Test File: documentreference-example.json - """ - filename = base_settings["unittest_data_dir"] / "documentreference-example.json" - inst = documentreference.DocumentReference.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "DocumentReference" == inst.resource_type - - impl_documentreference_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "DocumentReference" == data["resourceType"] - - inst2 = documentreference.DocumentReference(**data) - impl_documentreference_1(inst2) diff --git a/fhir/resources/tests/test_effectevidencesynthesis.py b/fhir/resources/tests/test_effectevidencesynthesis.py deleted file mode 100644 index a2fe0a2e..00000000 --- a/fhir/resources/tests/test_effectevidencesynthesis.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EffectEvidenceSynthesis -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import effectevidencesynthesis - - -def impl_effectevidencesynthesis_1(inst): - assert inst.exposure.reference == "EvidenceVariable/example" - assert inst.exposureAlternative.reference == "EvidenceVariable/example" - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome.reference == "EvidenceVariable/example" - assert inst.population.reference == "EvidenceVariable/example" - assert inst.status == "draft" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_effectevidencesynthesis_1(base_settings): - """No. 1 tests collection for EffectEvidenceSynthesis. - Test File: effectevidencesynthesis-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "effectevidencesynthesis-example.json" - ) - inst = effectevidencesynthesis.EffectEvidenceSynthesis.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "EffectEvidenceSynthesis" == inst.resource_type - - impl_effectevidencesynthesis_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "EffectEvidenceSynthesis" == data["resourceType"] - - inst2 = effectevidencesynthesis.EffectEvidenceSynthesis(**data) - impl_effectevidencesynthesis_1(inst2) diff --git a/fhir/resources/tests/test_encounter.py b/fhir/resources/tests/test_encounter.py deleted file mode 100644 index b334d865..00000000 --- a/fhir/resources/tests/test_encounter.py +++ /dev/null @@ -1,768 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Encounter -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import encounter - - -def impl_encounter_1(inst): - assert inst.class_fhir.code == "HH" - assert inst.class_fhir.display == "home health" - assert inst.class_fhir.system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - assert inst.contained[0].id == "home" - assert inst.id == "home" - assert inst.location[0].location.display == "Client's home" - assert inst.location[0].location.reference == "#home" - assert inst.location[0].period.end == fhirtypes.DateTime.validate( - "2015-01-17T16:30:00+10:00" - ) - assert inst.location[0].period.start == fhirtypes.DateTime.validate( - "2015-01-17T16:00:00+10:00" - ) - assert inst.location[0].status == "completed" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participant[0].individual.display == "Dr Adam Careful" - assert inst.participant[0].individual.reference == "Practitioner/example" - assert inst.participant[0].period.end == fhirtypes.DateTime.validate( - "2015-01-17T16:30:00+10:00" - ) - assert inst.participant[0].period.start == fhirtypes.DateTime.validate( - "2015-01-17T16:00:00+10:00" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2015-01-17T16:30:00+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2015-01-17T16:00:00+10:00") - assert inst.status == "finished" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Encounter with ' - "patient @example who is at home
" - ) - assert inst.text.status == "generated" - - -def test_encounter_1(base_settings): - """No. 1 tests collection for Encounter. - Test File: encounter-example-home.json - """ - filename = base_settings["unittest_data_dir"] / "encounter-example-home.json" - inst = encounter.Encounter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Encounter" == inst.resource_type - - impl_encounter_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Encounter" == data["resourceType"] - - inst2 = encounter.Encounter(**data) - impl_encounter_1(inst2) - - -def impl_encounter_2(inst): - assert inst.class_fhir.code == "AMB" - assert inst.class_fhir.display == "ambulatory" - assert inst.class_fhir.system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - assert inst.id == "f201" - assert inst.identifier[0].use == "temp" - assert inst.identifier[0].value == "Encounter_Roel_20130404" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participant[0].individual.reference == "Practitioner/f201" - assert inst.priority.coding[0].code == "17621005" - assert inst.priority.coding[0].display == "Normal" - assert inst.priority.coding[0].system == "http://snomed.info/sct" - assert inst.reasonCode[0].text == ( - "The patient had fever peaks over the last couple of days. He" - " is worried about these peaks." - ) - assert inst.serviceProvider.reference == "Organization/f201" - assert inst.status == "finished" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "11429006" - assert inst.type[0].coding[0].display == "Consultation" - assert inst.type[0].coding[0].system == "http://snomed.info/sct" - - -def test_encounter_2(base_settings): - """No. 2 tests collection for Encounter. - Test File: encounter-example-f201-20130404.json - """ - filename = ( - base_settings["unittest_data_dir"] / "encounter-example-f201-20130404.json" - ) - inst = encounter.Encounter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Encounter" == inst.resource_type - - impl_encounter_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Encounter" == data["resourceType"] - - inst2 = encounter.Encounter(**data) - impl_encounter_2(inst2) - - -def impl_encounter_3(inst): - assert inst.class_fhir.code == "AMB" - assert inst.class_fhir.display == "ambulatory" - assert inst.class_fhir.system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - assert inst.hospitalization.admitSource.coding[0].code == "305956004" - assert inst.hospitalization.admitSource.coding[0].display == "Referral by physician" - assert inst.hospitalization.admitSource.coding[0].system == "http://snomed.info/sct" - assert inst.hospitalization.dischargeDisposition.coding[0].code == "306689006" - assert ( - inst.hospitalization.dischargeDisposition.coding[0].display - == "Discharge to home" - ) - assert ( - inst.hospitalization.dischargeDisposition.coding[0].system - == "http://snomed.info/sct" - ) - assert ( - inst.hospitalization.preAdmissionIdentifier.system - == "http://www.bmc.nl/zorgportal/identifiers/pre-admissions" - ) - assert inst.hospitalization.preAdmissionIdentifier.use == "official" - assert inst.hospitalization.preAdmissionIdentifier.value == "93042" - assert inst.id == "f003" - assert ( - inst.identifier[0].system - == "http://www.bmc.nl/zorgportal/identifiers/encounters" - ) - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "v6751" - assert inst.length.code == "min" - assert inst.length.system == "http://unitsofmeasure.org" - assert inst.length.unit == "min" - assert float(inst.length.value) == float(90) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participant[0].individual.display == "E.M. van den Broek" - assert inst.participant[0].individual.reference == "Practitioner/f001" - assert inst.priority.coding[0].code == "103391001" - assert ( - inst.priority.coding[0].display == "Non-urgent ear, nose and throat admission" - ) - assert inst.priority.coding[0].system == "http://snomed.info/sct" - assert inst.reasonCode[0].coding[0].code == "18099001" - assert inst.reasonCode[0].coding[0].display == "Retropharyngeal abscess" - assert inst.reasonCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.serviceProvider.reference == "Organization/f001" - assert inst.status == "finished" - assert inst.subject.display == "P. van de Heuvel" - assert inst.subject.reference == "Patient/f001" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "270427003" - assert inst.type[0].coding[0].display == "Patient-initiated encounter" - assert inst.type[0].coding[0].system == "http://snomed.info/sct" - - -def test_encounter_3(base_settings): - """No. 3 tests collection for Encounter. - Test File: encounter-example-f003-abscess.json - """ - filename = ( - base_settings["unittest_data_dir"] / "encounter-example-f003-abscess.json" - ) - inst = encounter.Encounter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Encounter" == inst.resource_type - - impl_encounter_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Encounter" == data["resourceType"] - - inst2 = encounter.Encounter(**data) - impl_encounter_3(inst2) - - -def impl_encounter_4(inst): - assert inst.class_fhir.code == "IMP" - assert inst.class_fhir.display == "inpatient encounter" - assert inst.class_fhir.system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "in-progress" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Encounter with ' - "patient @example
" - ) - assert inst.text.status == "generated" - - -def test_encounter_4(base_settings): - """No. 4 tests collection for Encounter. - Test File: encounter-example.json - """ - filename = base_settings["unittest_data_dir"] / "encounter-example.json" - inst = encounter.Encounter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Encounter" == inst.resource_type - - impl_encounter_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Encounter" == data["resourceType"] - - inst2 = encounter.Encounter(**data) - impl_encounter_4(inst2) - - -def impl_encounter_5(inst): - assert inst.class_fhir.code == "AMB" - assert inst.class_fhir.display == "ambulatory" - assert inst.class_fhir.system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - assert inst.hospitalization.admitSource.coding[0].code == "305997006" - assert ( - inst.hospitalization.admitSource.coding[0].display == "Referral by radiologist" - ) - assert inst.hospitalization.admitSource.coding[0].system == "http://snomed.info/sct" - assert inst.hospitalization.dischargeDisposition.coding[0].code == "306689006" - assert ( - inst.hospitalization.dischargeDisposition.coding[0].display - == "Discharge to home" - ) - assert ( - inst.hospitalization.dischargeDisposition.coding[0].system - == "http://snomed.info/sct" - ) - assert ( - inst.hospitalization.preAdmissionIdentifier.system - == "http://www.bmc.nl/zorgportal/identifiers/pre-admissions" - ) - assert inst.hospitalization.preAdmissionIdentifier.use == "official" - assert inst.hospitalization.preAdmissionIdentifier.value == "98682" - assert inst.id == "f002" - assert ( - inst.identifier[0].system - == "http://www.bmc.nl/zorgportal/identifiers/encounters" - ) - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "v3251" - assert inst.length.code == "min" - assert inst.length.system == "http://unitsofmeasure.org" - assert inst.length.unit == "min" - assert float(inst.length.value) == float(140) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participant[0].individual.display == "M.I.M Versteegh" - assert inst.participant[0].individual.reference == "Practitioner/f003" - assert inst.priority.coding[0].code == "103391001" - assert inst.priority.coding[0].display == "Urgent" - assert inst.priority.coding[0].system == "http://snomed.info/sct" - assert inst.reasonCode[0].coding[0].code == "34068001" - assert inst.reasonCode[0].coding[0].display == "Partial lobectomy of lung" - assert inst.reasonCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.serviceProvider.display == "BMC" - assert inst.serviceProvider.reference == "Organization/f001" - assert inst.status == "finished" - assert inst.subject.display == "P. van de Heuvel" - assert inst.subject.reference == "Patient/f001" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "270427003" - assert inst.type[0].coding[0].display == "Patient-initiated encounter" - assert inst.type[0].coding[0].system == "http://snomed.info/sct" - - -def test_encounter_5(base_settings): - """No. 5 tests collection for Encounter. - Test File: encounter-example-f002-lung.json - """ - filename = base_settings["unittest_data_dir"] / "encounter-example-f002-lung.json" - inst = encounter.Encounter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Encounter" == inst.resource_type - - impl_encounter_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Encounter" == data["resourceType"] - - inst2 = encounter.Encounter(**data) - impl_encounter_5(inst2) - - -def impl_encounter_6(inst): - assert inst.account[0].reference == "Account/example" - assert inst.appointment[0].reference == "Appointment/example" - assert inst.basedOn[0].reference == "ServiceRequest/myringotomy" - assert inst.class_fhir.code == "IMP" - assert inst.class_fhir.display == "inpatient encounter" - assert inst.class_fhir.system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - assert inst.diagnosis[0].condition.reference == "Condition/stroke" - assert inst.diagnosis[0].rank == 1 - assert inst.diagnosis[0].use.coding[0].code == "AD" - assert inst.diagnosis[0].use.coding[0].display == "Admission diagnosis" - assert ( - inst.diagnosis[0].use.coding[0].system - == "http://terminology.hl7.org/CodeSystem/diagnosis-role" - ) - assert inst.diagnosis[1].condition.reference == "Condition/f201" - assert inst.diagnosis[1].use.coding[0].code == "DD" - assert inst.diagnosis[1].use.coding[0].display == "Discharge diagnosis" - assert ( - inst.diagnosis[1].use.coding[0].system - == "http://terminology.hl7.org/CodeSystem/diagnosis-role" - ) - assert inst.episodeOfCare[0].reference == "EpisodeOfCare/example" - assert inst.hospitalization.admitSource.coding[0].code == "309902002" - assert ( - inst.hospitalization.admitSource.coding[0].display - == "Clinical Oncology Department" - ) - assert inst.hospitalization.admitSource.coding[0].system == "http://snomed.info/sct" - assert inst.hospitalization.destination.reference == "Location/2" - assert inst.hospitalization.dietPreference[0].coding[0].code == "276026009" - assert ( - inst.hospitalization.dietPreference[0].coding[0].display - == "Fluid balance regulation" - ) - assert ( - inst.hospitalization.dietPreference[0].coding[0].system - == "http://snomed.info/sct" - ) - assert inst.hospitalization.origin.reference == "Location/2" - assert inst.hospitalization.reAdmission.coding[0].display == "readmitted" - assert inst.hospitalization.specialArrangement[0].coding[0].code == "wheel" - assert inst.hospitalization.specialArrangement[0].coding[0].display == "Wheelchair" - assert inst.hospitalization.specialArrangement[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/encounter-special-" "arrangements" - ) - assert inst.hospitalization.specialCourtesy[0].coding[0].code == "NRM" - assert ( - inst.hospitalization.specialCourtesy[0].coding[0].display == "normal courtesy" - ) - assert inst.hospitalization.specialCourtesy[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/v3-EncounterSpecialCou" "rtesy" - ) - assert inst.id == "f203" - assert inst.identifier[0].use == "temp" - assert inst.identifier[0].value == "Encounter_Roel_20130311" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.partOf.reference == "Encounter/f203" - assert inst.participant[0].individual.reference == "Practitioner/f201" - assert inst.participant[0].type[0].coding[0].code == "PART" - assert ( - inst.participant[0].type[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2013-03-20T09:23:00+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2013-03-11T09:23:00+10:00") - assert inst.priority.coding[0].code == "394849002" - assert inst.priority.coding[0].display == "High priority" - assert inst.priority.coding[0].system == "http://snomed.info/sct" - assert inst.reasonCode[0].text == ( - "The patient seems to suffer from bilateral pneumonia and " - "renal insufficiency, most likely due to chemotherapy." - ) - assert inst.serviceProvider.reference == "Organization/2" - assert inst.status == "finished" - assert inst.statusHistory[0].period.start == fhirtypes.DateTime.validate( - "2013-03-08T09:23:00+10:00" - ) - assert inst.statusHistory[0].status == "arrived" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "183807002" - assert inst.type[0].coding[0].display == "Inpatient stay for nine days" - assert inst.type[0].coding[0].system == "http://snomed.info/sct" - - -def test_encounter_6(base_settings): - """No. 6 tests collection for Encounter. - Test File: encounter-example-f203-20130311.json - """ - filename = ( - base_settings["unittest_data_dir"] / "encounter-example-f203-20130311.json" - ) - inst = encounter.Encounter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Encounter" == inst.resource_type - - impl_encounter_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Encounter" == data["resourceType"] - - inst2 = encounter.Encounter(**data) - impl_encounter_6(inst2) - - -def impl_encounter_7(inst): - assert inst.class_fhir.code == "AMB" - assert inst.class_fhir.display == "ambulatory" - assert inst.class_fhir.system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - assert inst.id == "xcda" - assert ( - inst.identifier[0].system - == "http://healthcare.example.org/identifiers/enocunter" - ) - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "1234213.52345873" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participant[0].individual.reference == "Practitioner/xcda1" - assert inst.reasonCode[0].coding[0].code == "T-D8200" - assert inst.reasonCode[0].coding[0].display == "Arm" - assert ( - inst.reasonCode[0].coding[0].system - == "http://ihe.net/xds/connectathon/eventCodes" - ) - assert inst.status == "finished" - assert inst.subject.reference == "Patient/xcda" - assert inst.text.status == "generated" - - -def test_encounter_7(base_settings): - """No. 7 tests collection for Encounter. - Test File: encounter-example-xcda.json - """ - filename = base_settings["unittest_data_dir"] / "encounter-example-xcda.json" - inst = encounter.Encounter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Encounter" == inst.resource_type - - impl_encounter_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Encounter" == data["resourceType"] - - inst2 = encounter.Encounter(**data) - impl_encounter_7(inst2) - - -def impl_encounter_8(inst): - assert inst.class_fhir.code == "AMB" - assert inst.class_fhir.display == "ambulatory" - assert inst.class_fhir.system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - assert inst.diagnosis[0].condition.display == ( - "Complications from Roel's TPF chemotherapy on January 28th, " "2013" - ) - assert inst.diagnosis[0].rank == 2 - assert inst.diagnosis[0].use.coding[0].code == "AD" - assert inst.diagnosis[0].use.coding[0].display == "Admission diagnosis" - assert ( - inst.diagnosis[0].use.coding[0].system - == "http://terminology.hl7.org/CodeSystem/diagnosis-role" - ) - assert inst.diagnosis[1].condition.display == "The patient is treated for a tumor" - assert inst.diagnosis[1].rank == 1 - assert inst.diagnosis[1].use.coding[0].code == "CC" - assert inst.diagnosis[1].use.coding[0].display == "Chief complaint" - assert ( - inst.diagnosis[1].use.coding[0].system - == "http://terminology.hl7.org/CodeSystem/diagnosis-role" - ) - assert inst.id == "f202" - assert inst.identifier[0].use == "temp" - assert inst.identifier[0].value == "Encounter_Roel_20130128" - assert inst.length.code == "min" - assert inst.length.system == "http://unitsofmeasure.org" - assert inst.length.unit == "minutes" - assert float(inst.length.value) == float(56) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participant[0].individual.reference == "Practitioner/f201" - assert inst.priority.coding[0].code == "103391001" - assert inst.priority.coding[0].display == "Urgent" - assert inst.priority.coding[0].system == "http://snomed.info/sct" - assert inst.reasonCode[0].text == "The patient is treated for a tumor." - assert inst.serviceProvider.reference == "Organization/f201" - assert inst.status == "finished" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "367336001" - assert inst.type[0].coding[0].display == "Chemotherapy" - assert inst.type[0].coding[0].system == "http://snomed.info/sct" - - -def test_encounter_8(base_settings): - """No. 8 tests collection for Encounter. - Test File: encounter-example-f202-20130128.json - """ - filename = ( - base_settings["unittest_data_dir"] / "encounter-example-f202-20130128.json" - ) - inst = encounter.Encounter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Encounter" == inst.resource_type - - impl_encounter_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Encounter" == data["resourceType"] - - inst2 = encounter.Encounter(**data) - impl_encounter_8(inst2) - - -def impl_encounter_9(inst): - assert inst.classHistory[0].class_fhir.code == "EMER" - assert inst.classHistory[0].class_fhir.display == "emergency" - assert ( - inst.classHistory[0].class_fhir.system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.classHistory[0].period.end == fhirtypes.DateTime.validate( - "2017-02-01T09:27:00+10:00" - ) - assert inst.classHistory[0].period.start == fhirtypes.DateTime.validate( - "2017-02-01T07:15:00+10:00" - ) - assert inst.classHistory[1].class_fhir.code == "IMP" - assert inst.classHistory[1].class_fhir.display == "inpatient encounter" - assert ( - inst.classHistory[1].class_fhir.system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.classHistory[1].period.start == fhirtypes.DateTime.validate( - "2017-02-01T09:27:00+10:00" - ) - assert inst.class_fhir.code == "IMP" - assert inst.class_fhir.display == "inpatient encounter" - assert inst.class_fhir.system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - assert inst.hospitalization.admitSource.coding[0].code == "emd" - assert ( - inst.hospitalization.admitSource.coding[0].display - == "From accident/emergency department" - ) - assert ( - inst.hospitalization.admitSource.coding[0].system - == "http://terminology.hl7.org/CodeSystem/admit-source" - ) - assert inst.id == "emerg" - assert inst.location[0].location.display == "Emergency Waiting Room" - assert inst.location[0].period.end == fhirtypes.DateTime.validate( - "2017-02-01T08:45:00+10:00" - ) - assert inst.location[0].period.start == fhirtypes.DateTime.validate( - "2017-02-01T07:15:00+10:00" - ) - assert inst.location[0].status == "active" - assert inst.location[1].location.display == "Emergency" - assert inst.location[1].period.end == fhirtypes.DateTime.validate( - "2017-02-01T09:27:00+10:00" - ) - assert inst.location[1].period.start == fhirtypes.DateTime.validate( - "2017-02-01T08:45:00+10:00" - ) - assert inst.location[1].status == "active" - assert inst.location[2].location.display == "Ward 1, Room 42, Bed 1" - assert inst.location[2].period.end == fhirtypes.DateTime.validate( - "2017-02-01T12:15:00+10:00" - ) - assert inst.location[2].period.start == fhirtypes.DateTime.validate( - "2017-02-01T09:27:00+10:00" - ) - assert inst.location[2].status == "active" - assert inst.location[3].location.display == "Ward 1, Room 42, Bed 1" - assert inst.location[3].period.end == fhirtypes.DateTime.validate( - "2017-02-01T12:45:00+10:00" - ) - assert inst.location[3].period.start == fhirtypes.DateTime.validate( - "2017-02-01T12:15:00+10:00" - ) - assert inst.location[3].status == "reserved" - assert inst.location[4].location.display == "Ward 1, Room 42, Bed 1" - assert inst.location[4].period.start == fhirtypes.DateTime.validate( - "2017-02-01T12:45:00+10:00" - ) - assert inst.location[4].status == "active" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.start == fhirtypes.DateTime.validate("2017-02-01T07:15:00+10:00") - assert inst.status == "in-progress" - assert inst.statusHistory[0].period.end == fhirtypes.DateTime.validate( - "2017-02-01T07:35:00+10:00" - ) - assert inst.statusHistory[0].period.start == fhirtypes.DateTime.validate( - "2017-02-01T07:15:00+10:00" - ) - assert inst.statusHistory[0].status == "arrived" - assert inst.statusHistory[1].period.end == fhirtypes.DateTime.validate( - "2017-02-01T08:45:00+10:00" - ) - assert inst.statusHistory[1].period.start == fhirtypes.DateTime.validate( - "2017-02-01T07:35:00+10:00" - ) - assert inst.statusHistory[1].status == "triaged" - assert inst.statusHistory[2].period.end == fhirtypes.DateTime.validate( - "2017-02-01T12:15:00+10:00" - ) - assert inst.statusHistory[2].period.start == fhirtypes.DateTime.validate( - "2017-02-01T08:45:00+10:00" - ) - assert inst.statusHistory[2].status == "in-progress" - assert inst.statusHistory[3].period.end == fhirtypes.DateTime.validate( - "2017-02-01T12:45:00+10:00" - ) - assert inst.statusHistory[3].period.start == fhirtypes.DateTime.validate( - "2017-02-01T12:15:00+10:00" - ) - assert inst.statusHistory[3].status == "onleave" - assert inst.statusHistory[4].period.start == fhirtypes.DateTime.validate( - "2017-02-01T12:45:00+10:00" - ) - assert inst.statusHistory[4].status == "in-progress" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Emergency visit ' - "that escalated into inpatient patient @example
" - ) - assert inst.text.status == "generated" - - -def test_encounter_9(base_settings): - """No. 9 tests collection for Encounter. - Test File: encounter-example-emerg.json - """ - filename = base_settings["unittest_data_dir"] / "encounter-example-emerg.json" - inst = encounter.Encounter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Encounter" == inst.resource_type - - impl_encounter_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Encounter" == data["resourceType"] - - inst2 = encounter.Encounter(**data) - impl_encounter_9(inst2) - - -def impl_encounter_10(inst): - assert inst.class_fhir.code == "AMB" - assert inst.class_fhir.display == "ambulatory" - assert inst.class_fhir.system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - assert inst.hospitalization.admitSource.coding[0].code == "305956004" - assert inst.hospitalization.admitSource.coding[0].display == "Referral by physician" - assert inst.hospitalization.admitSource.coding[0].system == "http://snomed.info/sct" - assert inst.hospitalization.dischargeDisposition.coding[0].code == "306689006" - assert ( - inst.hospitalization.dischargeDisposition.coding[0].display - == "Discharge to home" - ) - assert ( - inst.hospitalization.dischargeDisposition.coding[0].system - == "http://snomed.info/sct" - ) - assert ( - inst.hospitalization.preAdmissionIdentifier.system - == "http://www.amc.nl/zorgportal/identifiers/pre-admissions" - ) - assert inst.hospitalization.preAdmissionIdentifier.use == "official" - assert inst.hospitalization.preAdmissionIdentifier.value == "93042" - assert inst.id == "f001" - assert ( - inst.identifier[0].system == "http://www.amc.nl/zorgportal/identifiers/visits" - ) - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "v1451" - assert inst.length.code == "min" - assert inst.length.system == "http://unitsofmeasure.org" - assert inst.length.unit == "min" - assert float(inst.length.value) == float(140) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participant[0].individual.display == "P. Voigt" - assert inst.participant[0].individual.reference == "Practitioner/f002" - assert inst.priority.coding[0].code == "310361003" - assert inst.priority.coding[0].display == "Non-urgent cardiological admission" - assert inst.priority.coding[0].system == "http://snomed.info/sct" - assert inst.reasonCode[0].coding[0].code == "34068001" - assert inst.reasonCode[0].coding[0].display == "Heart valve replacement" - assert inst.reasonCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.serviceProvider.display == "Burgers University Medical Center" - assert inst.serviceProvider.reference == "Organization/f001" - assert inst.status == "finished" - assert inst.subject.display == "P. van de Heuvel" - assert inst.subject.reference == "Patient/f001" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "270427003" - assert inst.type[0].coding[0].display == "Patient-initiated encounter" - assert inst.type[0].coding[0].system == "http://snomed.info/sct" - - -def test_encounter_10(base_settings): - """No. 10 tests collection for Encounter. - Test File: encounter-example-f001-heart.json - """ - filename = base_settings["unittest_data_dir"] / "encounter-example-f001-heart.json" - inst = encounter.Encounter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Encounter" == inst.resource_type - - impl_encounter_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Encounter" == data["resourceType"] - - inst2 = encounter.Encounter(**data) - impl_encounter_10(inst2) diff --git a/fhir/resources/tests/test_endpoint.py b/fhir/resources/tests/test_endpoint.py deleted file mode 100644 index 7a59ffce..00000000 --- a/fhir/resources/tests/test_endpoint.py +++ /dev/null @@ -1,176 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Endpoint -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import endpoint - - -def impl_endpoint_1(inst): - assert inst.address == "https://pacs.hospital.org/IHEInvokeImageDisplay" - assert inst.connectionType.code == "ihe-iid" - assert inst.connectionType.system == ( - "http://terminology.hl7.org/CodeSystem/endpoint-connection-" "type" - ) - assert inst.id == "example-iid" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "PACS Hospital Invoke Image Display endpoint" - assert inst.payloadType[0].text == "DICOM IID" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_endpoint_1(base_settings): - """No. 1 tests collection for Endpoint. - Test File: endpoint-example-iid.json - """ - filename = base_settings["unittest_data_dir"] / "endpoint-example-iid.json" - inst = endpoint.Endpoint.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Endpoint" == inst.resource_type - - impl_endpoint_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Endpoint" == data["resourceType"] - - inst2 = endpoint.Endpoint(**data) - impl_endpoint_1(inst2) - - -def impl_endpoint_2(inst): - assert inst.address == "mailto:MARTIN.SMIETANKA@directnppes.com" - assert inst.connectionType.code == "direct-project" - assert inst.id == "direct-endpoint" - assert inst.managingOrganization.reference == "Organization/299" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "MARTIN SMIETANKA" - assert ( - inst.payloadType[0].coding[0].code == "urn:hl7-org:sdwg:ccda-structuredBody:1.1" - ) - assert inst.payloadType[0].coding[0].system == "urn:oid:1.3.6.1.4.1.19376.1.2.3" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_endpoint_2(base_settings): - """No. 2 tests collection for Endpoint. - Test File: endpoint-example-direct.json - """ - filename = base_settings["unittest_data_dir"] / "endpoint-example-direct.json" - inst = endpoint.Endpoint.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Endpoint" == inst.resource_type - - impl_endpoint_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Endpoint" == data["resourceType"] - - inst2 = endpoint.Endpoint(**data) - impl_endpoint_2(inst2) - - -def impl_endpoint_3(inst): - assert inst.address == "https://pacs.hospital.org/wado-rs" - assert inst.connectionType.code == "dicom-wado-rs" - assert inst.connectionType.system == ( - "http://terminology.hl7.org/CodeSystem/endpoint-connection-" "type" - ) - assert inst.id == "example-wadors" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "PACS Hospital DICOM WADO-RS endpoint" - assert inst.payloadMimeType[0] == "application/dicom" - assert inst.payloadType[0].text == "DICOM WADO-RS" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_endpoint_3(base_settings): - """No. 3 tests collection for Endpoint. - Test File: endpoint-example-wadors.json - """ - filename = base_settings["unittest_data_dir"] / "endpoint-example-wadors.json" - inst = endpoint.Endpoint.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Endpoint" == inst.resource_type - - impl_endpoint_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Endpoint" == data["resourceType"] - - inst2 = endpoint.Endpoint(**data) - impl_endpoint_3(inst2) - - -def impl_endpoint_4(inst): - assert inst.address == "http://fhir3.healthintersections.com.au/open/CarePlan" - assert inst.connectionType.code == "hl7-fhir-rest" - assert inst.connectionType.system == ( - "http://terminology.hl7.org/CodeSystem/endpoint-connection-" "type" - ) - assert inst.contact[0].system == "email" - assert inst.contact[0].use == "work" - assert inst.contact[0].value == "endpointmanager@example.org" - assert inst.header[0] == "bearer-code BASGS534s4" - assert inst.id == "example" - assert inst.identifier[0].system == "http://example.org/enpoint-identifier" - assert inst.identifier[0].value == "epcp12" - assert inst.managingOrganization.reference == "Organization/hl7" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Health Intersections CarePlan Hub" - assert inst.payloadMimeType[0] == "application/fhir+xml" - assert inst.payloadType[0].coding[0].code == "CarePlan" - assert inst.payloadType[0].coding[0].system == "http://hl7.org/fhir/resource-types" - assert inst.period.start == fhirtypes.DateTime.validate("2014-09-01T09:23:00+10:00") - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_endpoint_4(base_settings): - """No. 4 tests collection for Endpoint. - Test File: endpoint-example.json - """ - filename = base_settings["unittest_data_dir"] / "endpoint-example.json" - inst = endpoint.Endpoint.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Endpoint" == inst.resource_type - - impl_endpoint_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Endpoint" == data["resourceType"] - - inst2 = endpoint.Endpoint(**data) - impl_endpoint_4(inst2) diff --git a/fhir/resources/tests/test_enrollmentrequest.py b/fhir/resources/tests/test_enrollmentrequest.py deleted file mode 100644 index 502312ae..00000000 --- a/fhir/resources/tests/test_enrollmentrequest.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EnrollmentRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import enrollmentrequest - - -def impl_enrollmentrequest_1(inst): - assert inst.candidate.reference == "Patient/1" - assert inst.coverage.reference == "Coverage/9876B1" - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T09:23:00+10:00") - assert inst.id == "22345" - assert inst.identifier[0].system == "http://happyvalley.com/enrollmentrequest" - assert inst.identifier[0].value == "EN22345" - assert inst.insurer.reference == "Organization/2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.provider.reference == "Organization/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the EnrollmentRequest.
" - ) - assert inst.text.status == "generated" - - -def test_enrollmentrequest_1(base_settings): - """No. 1 tests collection for EnrollmentRequest. - Test File: enrollmentrequest-example.json - """ - filename = base_settings["unittest_data_dir"] / "enrollmentrequest-example.json" - inst = enrollmentrequest.EnrollmentRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "EnrollmentRequest" == inst.resource_type - - impl_enrollmentrequest_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "EnrollmentRequest" == data["resourceType"] - - inst2 = enrollmentrequest.EnrollmentRequest(**data) - impl_enrollmentrequest_1(inst2) diff --git a/fhir/resources/tests/test_enrollmentresponse.py b/fhir/resources/tests/test_enrollmentresponse.py deleted file mode 100644 index 402604a8..00000000 --- a/fhir/resources/tests/test_enrollmentresponse.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EnrollmentResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import enrollmentresponse - - -def impl_enrollmentresponse_1(inst): - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T09:23:00+10:00") - assert inst.disposition == "Dependant added to policy." - assert inst.id == "ER2500" - assert ( - inst.identifier[0].system - == "http://www.BenefitsInc.com/fhir/enrollmentresponse" - ) - assert inst.identifier[0].value == "781234" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization.reference == "Organization/2" - assert inst.outcome == "complete" - assert ( - inst.request.reference - == "http://www.BenefitsInc.com/fhir/eligibility/225476332402" - ) - assert inst.requestProvider.reference == "Organization/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the EnrollmentResponse
" - ) - assert inst.text.status == "generated" - - -def test_enrollmentresponse_1(base_settings): - """No. 1 tests collection for EnrollmentResponse. - Test File: enrollmentresponse-example.json - """ - filename = base_settings["unittest_data_dir"] / "enrollmentresponse-example.json" - inst = enrollmentresponse.EnrollmentResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "EnrollmentResponse" == inst.resource_type - - impl_enrollmentresponse_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "EnrollmentResponse" == data["resourceType"] - - inst2 = enrollmentresponse.EnrollmentResponse(**data) - impl_enrollmentresponse_1(inst2) diff --git a/fhir/resources/tests/test_episodeofcare.py b/fhir/resources/tests/test_episodeofcare.py deleted file mode 100644 index 3d9aa5e4..00000000 --- a/fhir/resources/tests/test_episodeofcare.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EpisodeOfCare -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import episodeofcare - - -def impl_episodeofcare_1(inst): - assert inst.account[0].display == "example account" - assert inst.account[0].reference == "Account/example" - assert inst.careManager.display == "Amanda Assigned" - assert inst.careManager.reference == "Practitioner/14" - assert inst.diagnosis[0].condition.reference == "Condition/stroke" - assert inst.diagnosis[0].rank == 1 - assert inst.diagnosis[0].role.coding[0].code == "CC" - assert inst.diagnosis[0].role.coding[0].display == "Chief complaint" - assert ( - inst.diagnosis[0].role.coding[0].system - == "http://terminology.hl7.org/CodeSystem/diagnosis-role" - ) - assert inst.id == "example" - assert ( - inst.identifier[0].system == "http://example.org/sampleepisodeofcare-identifier" - ) - assert inst.identifier[0].value == "123" - assert inst.managingOrganization.reference == "Organization/hl7" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.period.start == fhirtypes.DateTime.validate("2014-09-01T09:23:00+10:00") - assert inst.referralRequest[0].display == "Referral from Example Aged Care Services" - assert inst.status == "active" - assert inst.statusHistory[0].period.end == fhirtypes.DateTime.validate( - "2014-09-14T09:23:00+10:00" - ) - assert inst.statusHistory[0].period.start == fhirtypes.DateTime.validate( - "2014-09-01T09:23:00+10:00" - ) - assert inst.statusHistory[0].status == "planned" - assert inst.statusHistory[1].period.end == fhirtypes.DateTime.validate( - "2014-09-21T09:23:00+10:00" - ) - assert inst.statusHistory[1].period.start == fhirtypes.DateTime.validate( - "2014-09-15T09:23:00+10:00" - ) - assert inst.statusHistory[1].status == "active" - assert inst.statusHistory[2].period.end == fhirtypes.DateTime.validate( - "2014-09-24T09:23:00+10:00" - ) - assert inst.statusHistory[2].period.start == fhirtypes.DateTime.validate( - "2014-09-22T09:23:00+10:00" - ) - assert inst.statusHistory[2].status == "onhold" - assert inst.statusHistory[3].period.start == fhirtypes.DateTime.validate( - "2014-09-25T09:23:00+10:00" - ) - assert inst.statusHistory[3].status == "active" - assert inst.team[0].display == "example care team" - assert inst.team[0].reference == "CareTeam/example" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "hacc" - assert inst.type[0].coding[0].display == "Home and Community Care" - assert ( - inst.type[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/episodeofcare-type" - ) - - -def test_episodeofcare_1(base_settings): - """No. 1 tests collection for EpisodeOfCare. - Test File: episodeofcare-example.json - """ - filename = base_settings["unittest_data_dir"] / "episodeofcare-example.json" - inst = episodeofcare.EpisodeOfCare.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "EpisodeOfCare" == inst.resource_type - - impl_episodeofcare_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "EpisodeOfCare" == data["resourceType"] - - inst2 = episodeofcare.EpisodeOfCare(**data) - impl_episodeofcare_1(inst2) diff --git a/fhir/resources/tests/test_eventdefinition.py b/fhir/resources/tests/test_eventdefinition.py deleted file mode 100644 index c6c23a98..00000000 --- a/fhir/resources/tests/test_eventdefinition.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EventDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import eventdefinition - - -def impl_eventdefinition_1(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.purpose == "Monitor all admissions to Emergency" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.trigger[0].condition.description == ( - "Encounter Location = emergency (active/completed encounters," - " current or previous)" - ) - assert inst.trigger[0].condition.expression == ( - "(this | %previous).location.where(location = " - "'Location/emergency' and status in {'active', " - "'completed'}).exists()" - ) - assert inst.trigger[0].condition.language == "text/fhirpath" - assert inst.trigger[0].data[0].type == "Encounter" - assert inst.trigger[0].name == "monitor-emergency-admissions" - assert inst.trigger[0].type == "named-event" - - -def test_eventdefinition_1(base_settings): - """No. 1 tests collection for EventDefinition. - Test File: eventdefinition-example.json - """ - filename = base_settings["unittest_data_dir"] / "eventdefinition-example.json" - inst = eventdefinition.EventDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "EventDefinition" == inst.resource_type - - impl_eventdefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "EventDefinition" == data["resourceType"] - - inst2 = eventdefinition.EventDefinition(**data) - impl_eventdefinition_1(inst2) diff --git a/fhir/resources/tests/test_evidence.py b/fhir/resources/tests/test_evidence.py deleted file mode 100644 index 4ee109e7..00000000 --- a/fhir/resources/tests/test_evidence.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Evidence -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import evidence - - -def impl_evidence_1(inst): - assert inst.exposureBackground.reference == "EvidenceVariable/example" - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "draft" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_evidence_1(base_settings): - """No. 1 tests collection for Evidence. - Test File: evidence-example.json - """ - filename = base_settings["unittest_data_dir"] / "evidence-example.json" - inst = evidence.Evidence.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Evidence" == inst.resource_type - - impl_evidence_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Evidence" == data["resourceType"] - - inst2 = evidence.Evidence(**data) - impl_evidence_1(inst2) diff --git a/fhir/resources/tests/test_evidencevariable.py b/fhir/resources/tests/test_evidencevariable.py deleted file mode 100644 index 72fb1213..00000000 --- a/fhir/resources/tests/test_evidencevariable.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/EvidenceVariable -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import evidencevariable - - -def impl_evidencevariable_1(inst): - assert ( - inst.characteristic[0].definitionCodeableConcept.text - == "Diabetic patients over 65" - ) - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "draft" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_evidencevariable_1(base_settings): - """No. 1 tests collection for EvidenceVariable. - Test File: evidencevariable-example.json - """ - filename = base_settings["unittest_data_dir"] / "evidencevariable-example.json" - inst = evidencevariable.EvidenceVariable.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "EvidenceVariable" == inst.resource_type - - impl_evidencevariable_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "EvidenceVariable" == data["resourceType"] - - inst2 = evidencevariable.EvidenceVariable(**data) - impl_evidencevariable_1(inst2) diff --git a/fhir/resources/tests/test_examplescenario.py b/fhir/resources/tests/test_examplescenario.py deleted file mode 100644 index 0eca161b..00000000 --- a/fhir/resources/tests/test_examplescenario.py +++ /dev/null @@ -1,284 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ExampleScenario -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import examplescenario - - -def impl_examplescenario_1(inst): - assert inst.actor[0].actorId == "Nurse" - assert inst.actor[0].description == "The Nurse" - assert inst.actor[0].name == "Nurse" - assert inst.actor[0].type == "person" - assert inst.actor[1].actorId == "MAP" - assert inst.actor[1].description == ( - "The entity that receives the Administration Requests to show" - " the nurse to perform them" - ) - assert inst.actor[1].name == "Nurse's Tablet" - assert inst.actor[1].type == "entity" - assert inst.actor[2].actorId == "OP" - assert inst.actor[2].description == "The Medication Administration Order Placer" - assert inst.actor[2].name == "MAR / Scheduler" - assert inst.actor[2].type == "entity" - assert inst.actor[3].actorId == "MAC" - assert inst.actor[3].description == ( - "The entity that receives the Medication Administration " "reports" - ) - assert inst.actor[3].name == "MAR / EHR" - assert inst.actor[3].type == "entity" - assert inst.id == "example" - assert inst.instance[0].description == ( - 'The initial prescription which describes "medication X, 3 ' - 'times per day" - the exact scheduling is not in the ' - "initial prescription (it is left for the care teams to " - "decide on the schedule)." - ) - assert inst.instance[0].name == "Initial Prescription" - assert inst.instance[0].resourceId == "iherx001" - assert ( - inst.instance[1].description == "The administration request for day 1, morning" - ) - assert inst.instance[1].name == "Request for day 1, morning" - assert inst.instance[1].resourceId == "iherx001.001" - assert inst.instance[2].description == "The administration request for day 1, lunch" - assert inst.instance[2].name == "Request for day 1, lunch" - assert inst.instance[2].resourceId == "iherx001.002" - assert ( - inst.instance[3].description == "The administration request for day 1, evening" - ) - assert inst.instance[3].name == "Request for day 1, evening" - assert inst.instance[3].resourceId == "iherx001.003" - assert ( - inst.instance[4].description == "The administration request for day 2, morning" - ) - assert inst.instance[4].name == "Request for day 2, morning" - assert inst.instance[4].resourceId == "iherx001.004" - assert inst.instance[5].description == "The administration request for day 2, lunch" - assert inst.instance[5].name == "Request for day 2, lunch" - assert inst.instance[5].resourceId == "iherx001.005" - assert ( - inst.instance[6].description == "The administration request for day 2, evening" - ) - assert inst.instance[6].name == "Request for day 2, evening" - assert inst.instance[6].resourceId == "iherx001.006" - assert ( - inst.instance[7].description - == "Administration report for day 1, morning: Taken" - ) - assert inst.instance[7].name == "Morning meds - taken" - assert inst.instance[7].resourceId == "iheadm001a" - assert ( - inst.instance[8].description - == "Administration report for day 1, morning: NOT Taken" - ) - assert inst.instance[8].name == "Morning meds - not taken" - assert inst.instance[8].resourceId == "iheadm001b" - assert inst.instance[9].containedInstance[0].resourceId == "iherx001.001" - assert inst.instance[9].containedInstance[1].resourceId == "iherx001.002" - assert inst.instance[9].containedInstance[2].resourceId == "iherx001.003" - assert inst.instance[9].containedInstance[3].resourceId == "iherx001.004" - assert inst.instance[9].containedInstance[4].resourceId == "iherx001.005" - assert inst.instance[9].containedInstance[5].resourceId == "iherx001.006" - assert inst.instance[9].description == "All the medication Requests for Day 1" - assert inst.instance[9].name == "Bundle of Medication Requests" - assert inst.instance[9].resourceId == "iherx001bundle" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.process[0].postConditions == ( - "Medication administration Reports are submitted, EHR is " "updated." - ) - assert inst.process[0].preConditions == ( - "Medication administration requests are in the EHR / MAR, " - "scheduled for each individual intake." - ) - assert inst.process[0].step[0].operation.initiator == "Nurse" - assert inst.process[0].step[0].operation.name == "1. Get today's schedule" - assert inst.process[0].step[0].operation.number == "1" - assert inst.process[0].step[0].operation.receiver == "MAP" - assert inst.process[0].step[1].process[0].description == ( - "Query for medication administration orders,\\n- For today's " - "shifts\\n- For today's patients" - ) - assert inst.process[0].step[1].process[0].step[0].operation.initiator == "MAP" - assert inst.process[0].step[1].process[0].step[0].operation.name == ( - "2.Query for medication administration orders,\\n- For " - "today's shifts\\n- For today's patients" - ) - assert inst.process[0].step[1].process[0].step[0].operation.number == "2" - assert inst.process[0].step[1].process[0].step[0].operation.receiver == "OP" - assert ( - inst.process[0].step[1].process[0].step[0].operation.request.resourceId - == "iherxqry" - ) - assert ( - inst.process[0].step[1].process[0].step[0].operation.response.resourceId - == "iherx001bundle" - ) - assert ( - inst.process[0].step[1].process[0].title == "P1. Query Administration Requests" - ) - assert inst.process[0].step[2].pause is True - assert inst.process[0].step[3].operation.initiator == "MAP" - assert inst.process[0].step[3].operation.name == "Notify (alert)" - assert inst.process[0].step[3].operation.number == "4" - assert inst.process[0].step[3].operation.receiver == "Nurse" - assert inst.process[0].step[4].operation.initiator == "Nurse" - assert inst.process[0].step[4].operation.name == "Read orders" - assert inst.process[0].step[4].operation.number == "5" - assert inst.process[0].step[4].operation.receiver == "MAP" - assert inst.process[0].step[5].pause is True - assert inst.process[0].step[6].operation.initiator == "Nurse" - assert inst.process[0].step[6].operation.name == "Ask if patient took meds" - assert inst.process[0].step[6].operation.number == "5" - assert inst.process[0].step[6].operation.receiver == "Nurse" - assert ( - inst.process[0].step[7].alternative[0].description - == "Invoke if patient took medications" - ) - assert ( - inst.process[0] - .step[7] - .alternative[0] - .step[0] - .process[0] - .step[0] - .operation.initiator - == "Nurse" - ) - assert ( - inst.process[0] - .step[7] - .alternative[0] - .step[0] - .process[0] - .step[0] - .operation.initiatorActive - is True - ) - assert ( - inst.process[0].step[7].alternative[0].step[0].process[0].step[0].operation.name - == "Register Meds taken" - ) - assert ( - inst.process[0] - .step[7] - .alternative[0] - .step[0] - .process[0] - .step[0] - .operation.number - == "1a" - ) - assert ( - inst.process[0] - .step[7] - .alternative[0] - .step[0] - .process[0] - .step[0] - .operation.receiver - == "MAP" - ) - assert ( - inst.process[0].step[7].alternative[0].step[0].process[0].title - == "Register Meds taken" - ) - assert inst.process[0].step[7].alternative[0].title == "Patient took drugs" - assert ( - inst.process[0].step[7].alternative[1].description - == "No, patient did not take drugs" - ) - assert ( - inst.process[0] - .step[7] - .alternative[1] - .step[0] - .process[0] - .step[0] - .operation.initiator - == "Nurse" - ) - assert ( - inst.process[0] - .step[7] - .alternative[1] - .step[0] - .process[0] - .step[0] - .operation.initiatorActive - is True - ) - assert ( - inst.process[0].step[7].alternative[1].step[0].process[0].step[0].operation.name - == "Register Meds NOT taken" - ) - assert ( - inst.process[0] - .step[7] - .alternative[1] - .step[0] - .process[0] - .step[0] - .operation.number - == "1b" - ) - assert ( - inst.process[0] - .step[7] - .alternative[1] - .step[0] - .process[0] - .step[0] - .operation.receiver - == "MAP" - ) - assert ( - inst.process[0].step[7].alternative[1].step[0].process[0].title - == "Register Meds NOT taken" - ) - assert inst.process[0].step[7].alternative[1].title == "No drugs" - assert ( - inst.process[0].step[7].alternative[2].description - == "Unknown whether patient took medications or not" - ) - assert inst.process[0].step[7].alternative[2].step[0].pause is True - assert inst.process[0].step[7].alternative[2].title == "Not clear" - assert inst.process[0].step[8].pause is True - assert inst.process[0].step[9].operation.initiator == "Nurse" - assert inst.process[0].step[9].operation.name == "Administer drug" - assert inst.process[0].step[9].operation.number == "6" - assert inst.process[0].step[9].operation.receiver == "Nurse" - assert inst.process[0].title == "Mobile Medication Administration" - assert inst.status == "draft" - assert inst.text.status == "generated" - - -def test_examplescenario_1(base_settings): - """No. 1 tests collection for ExampleScenario. - Test File: examplescenario-example.json - """ - filename = base_settings["unittest_data_dir"] / "examplescenario-example.json" - inst = examplescenario.ExampleScenario.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ExampleScenario" == inst.resource_type - - impl_examplescenario_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ExampleScenario" == data["resourceType"] - - inst2 = examplescenario.ExampleScenario(**data) - impl_examplescenario_1(inst2) diff --git a/fhir/resources/tests/test_explanationofbenefit.py b/fhir/resources/tests/test_explanationofbenefit.py deleted file mode 100644 index 99429b92..00000000 --- a/fhir/resources/tests/test_explanationofbenefit.py +++ /dev/null @@ -1,282 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ExplanationOfBenefit -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import explanationofbenefit - - -def impl_explanationofbenefit_1(inst): - assert inst.careTeam[0].provider.reference == "Practitioner/example" - assert inst.careTeam[0].sequence == 1 - assert inst.claim.reference == "Claim/100150" - assert inst.claimResponse.reference == "ClaimResponse/R3500" - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T09:23:00+10:00") - assert inst.disposition == "Claim settled as per contract." - assert inst.enterer.reference == "Practitioner/1" - assert inst.facility.reference == "Location/1" - assert inst.id == "EB3500" - assert ( - inst.identifier[0].system - == "http://www.BenefitsInc.com/fhir/explanationofbenefit" - ) - assert inst.identifier[0].value == "987654321" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is True - assert inst.insurer.reference == "Organization/3" - assert inst.item[0].adjudication[0].amount.currency == "USD" - assert float(inst.item[0].adjudication[0].amount.value) == float(120.0) - assert inst.item[0].adjudication[0].category.coding[0].code == "eligible" - assert inst.item[0].adjudication[1].category.coding[0].code == "eligpercent" - assert float(inst.item[0].adjudication[1].value) == float(0.8) - assert inst.item[0].adjudication[2].amount.currency == "USD" - assert float(inst.item[0].adjudication[2].amount.value) == float(96.0) - assert inst.item[0].adjudication[2].category.coding[0].code == "benefit" - assert inst.item[0].careTeamSequence[0] == 1 - assert inst.item[0].encounter[0].reference == "Encounter/example" - assert inst.item[0].net.currency == "USD" - assert float(inst.item[0].net.value) == float(135.57) - assert inst.item[0].productOrService.coding[0].code == "1205" - assert ( - inst.item[0].productOrService.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-USCLS" - ) - assert inst.item[0].sequence == 1 - assert inst.item[0].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.item[0].udi[0].reference == "Device/example" - assert inst.item[0].unitPrice.currency == "USD" - assert float(inst.item[0].unitPrice.value) == float(135.57) - assert inst.item[1].adjudication[0].amount.currency == "USD" - assert float(inst.item[1].adjudication[0].amount.value) == float(180.0) - assert inst.item[1].adjudication[0].category.coding[0].code == "benefit" - assert inst.item[1].careTeamSequence[0] == 1 - assert inst.item[1].detail[0].adjudication[0].amount.currency == "USD" - assert float(inst.item[1].detail[0].adjudication[0].amount.value) == float(180.0) - assert inst.item[1].detail[0].adjudication[0].category.coding[0].code == "benefit" - assert inst.item[1].detail[0].net.currency == "USD" - assert float(inst.item[1].detail[0].net.value) == float(200.0) - assert inst.item[1].detail[0].productOrService.coding[0].code == "group" - assert inst.item[1].detail[0].sequence == 1 - assert inst.item[1].detail[0].subDetail[0].adjudication[0].amount.currency == "USD" - assert float( - inst.item[1].detail[0].subDetail[0].adjudication[0].amount.value - ) == float(200.0) - assert ( - inst.item[1].detail[0].subDetail[0].adjudication[0].category.coding[0].code - == "eligible" - ) - assert ( - inst.item[1].detail[0].subDetail[0].adjudication[1].category.coding[0].code - == "eligpercent" - ) - assert float(inst.item[1].detail[0].subDetail[0].adjudication[1].value) == float( - 0.9 - ) - assert inst.item[1].detail[0].subDetail[0].adjudication[2].amount.currency == "USD" - assert float( - inst.item[1].detail[0].subDetail[0].adjudication[2].amount.value - ) == float(180.0) - assert ( - inst.item[1].detail[0].subDetail[0].adjudication[2].category.coding[0].code - == "benefit" - ) - assert inst.item[1].detail[0].subDetail[0].net.currency == "USD" - assert float(inst.item[1].detail[0].subDetail[0].net.value) == float(200.0) - assert inst.item[1].detail[0].subDetail[0].productOrService.coding[0].code == "1205" - assert ( - inst.item[1].detail[0].subDetail[0].productOrService.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-USCLS" - ) - assert inst.item[1].detail[0].subDetail[0].sequence == 1 - assert inst.item[1].detail[0].subDetail[0].udi[0].reference == "Device/example" - assert inst.item[1].detail[0].subDetail[0].unitPrice.currency == "USD" - assert float(inst.item[1].detail[0].subDetail[0].unitPrice.value) == float(200.0) - assert inst.item[1].detail[0].udi[0].reference == "Device/example" - assert inst.item[1].net.currency == "USD" - assert float(inst.item[1].net.value) == float(200.0) - assert inst.item[1].productOrService.coding[0].code == "group" - assert inst.item[1].sequence == 2 - assert inst.item[1].servicedDate == fhirtypes.Date.validate("2014-08-16") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "complete" - assert inst.patient.reference == "Patient/pat1" - assert inst.payee.party.reference == "Organization/2" - assert inst.payee.type.coding[0].code == "provider" - assert ( - inst.payee.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/payeetype" - ) - assert inst.provider.reference == "Practitioner/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the ExplanationOfBenefit
" - ) - assert inst.text.status == "generated" - assert inst.total[0].amount.currency == "USD" - assert float(inst.total[0].amount.value) == float(135.57) - assert inst.total[0].category.coding[0].code == "submitted" - assert inst.total[1].amount.currency == "USD" - assert float(inst.total[1].amount.value) == float(96.0) - assert inst.total[1].category.coding[0].code == "benefit" - assert inst.type.coding[0].code == "oral" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_explanationofbenefit_1(base_settings): - """No. 1 tests collection for ExplanationOfBenefit. - Test File: explanationofbenefit-example.json - """ - filename = base_settings["unittest_data_dir"] / "explanationofbenefit-example.json" - inst = explanationofbenefit.ExplanationOfBenefit.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ExplanationOfBenefit" == inst.resource_type - - impl_explanationofbenefit_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ExplanationOfBenefit" == data["resourceType"] - - inst2 = explanationofbenefit.ExplanationOfBenefit(**data) - impl_explanationofbenefit_1(inst2) - - -def impl_explanationofbenefit_2(inst): - assert inst.accident.date == fhirtypes.Date.validate("2014-02-14") - assert inst.accident.locationReference.reference == "Location/ph" - assert inst.accident.type.coding[0].code == "SPT" - assert ( - inst.accident.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.billablePeriod.end == fhirtypes.DateTime.validate( - "2014-03-01T09:23:00+10:00" - ) - assert inst.billablePeriod.start == fhirtypes.DateTime.validate( - "2014-02-01T09:23:00+10:00" - ) - assert inst.claim.reference == "Claim/100150" - assert inst.claimResponse.reference == "ClaimResponse/R3500" - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T09:23:00+10:00") - assert inst.disposition == "Could not process." - assert inst.enterer.reference == "Practitioner/1" - assert inst.facility.reference == "Location/1" - assert inst.formCode.coding[0].code == "2" - assert ( - inst.formCode.coding[0].system - == "http://terminology.hl7.org/CodeSystem/forms-codes" - ) - assert inst.id == "EB3501" - assert ( - inst.identifier[0].system - == "http://www.BenefitsInc.com/fhir/explanationofbenefit" - ) - assert inst.identifier[0].value == "error-1" - assert inst.insurance[0].coverage.reference == "Coverage/9876B1" - assert inst.insurance[0].focal is True - assert inst.insurer.reference == "Organization/2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.originalPrescription.reference == "MedicationRequest/medrx0301" - assert inst.outcome == "error" - assert inst.patient.reference == "Patient/pat1" - assert inst.precedence == 2 - assert inst.prescription.reference == "MedicationRequest/medrx002" - assert inst.procedure[0].date == fhirtypes.DateTime.validate( - "2014-02-14T09:23:00+10:00" - ) - assert inst.procedure[0].procedureCodeableConcept.coding[0].code == "123001" - assert ( - inst.procedure[0].procedureCodeableConcept.coding[0].system - == "http://hl7.org/fhir/sid/ex-icd-10-procedures" - ) - assert inst.procedure[0].sequence == 1 - assert inst.procedure[0].udi[0].reference == "Device/example" - assert inst.processNote[0].language.coding[0].code == "en-CA" - assert inst.processNote[0].language.coding[0].system == "urn:ietf:bcp:47" - assert inst.processNote[0].number == 1 - assert inst.processNote[0].text == "Invalid claim" - assert inst.processNote[0].type == "display" - assert inst.provider.reference == "Organization/2" - assert inst.related[0].reference.system == "http://www.BenefitsInc.com/case-number" - assert inst.related[0].reference.value == "23-56Tu-XX-47-20150M14" - assert inst.status == "active" - assert inst.subType.coding[0].code == "emergency" - assert ( - inst.subType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/ex-claimsubtype" - ) - assert inst.supportingInfo[0].category.coding[0].code == "employmentimpacted" - assert inst.supportingInfo[0].category.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/claiminformationcatego" "ry" - ) - assert inst.supportingInfo[0].sequence == 1 - assert inst.supportingInfo[0].timingPeriod.end == fhirtypes.DateTime.validate( - "2014-02-28T09:23:00+10:00" - ) - assert inst.supportingInfo[0].timingPeriod.start == fhirtypes.DateTime.validate( - "2014-02-14T09:23:00+10:00" - ) - assert inst.supportingInfo[1].category.coding[0].code == "hospitalized" - assert inst.supportingInfo[1].category.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/claiminformationcatego" "ry" - ) - assert inst.supportingInfo[1].sequence == 2 - assert inst.supportingInfo[1].timingPeriod.end == fhirtypes.DateTime.validate( - "2014-02-16T09:23:00+10:00" - ) - assert inst.supportingInfo[1].timingPeriod.start == fhirtypes.DateTime.validate( - "2014-02-14T09:23:00+10:00" - ) - assert inst.text.status == "generated" - assert inst.total[0].amount.currency == "USD" - assert float(inst.total[0].amount.value) == float(2478.57) - assert inst.total[0].category.coding[0].code == "submitted" - assert inst.total[1].amount.currency == "USD" - assert float(inst.total[1].amount.value) == float(0.0) - assert inst.total[1].category.coding[0].code == "benefit" - assert inst.type.coding[0].code == "oral" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/claim-type" - ) - assert inst.use == "claim" - - -def test_explanationofbenefit_2(base_settings): - """No. 2 tests collection for ExplanationOfBenefit. - Test File: explanationofbenefit-example-2.json - """ - filename = ( - base_settings["unittest_data_dir"] / "explanationofbenefit-example-2.json" - ) - inst = explanationofbenefit.ExplanationOfBenefit.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ExplanationOfBenefit" == inst.resource_type - - impl_explanationofbenefit_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ExplanationOfBenefit" == data["resourceType"] - - inst2 = explanationofbenefit.ExplanationOfBenefit(**data) - impl_explanationofbenefit_2(inst2) diff --git a/fhir/resources/tests/test_familymemberhistory.py b/fhir/resources/tests/test_familymemberhistory.py deleted file mode 100644 index 9819ab14..00000000 --- a/fhir/resources/tests/test_familymemberhistory.py +++ /dev/null @@ -1,129 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/FamilyMemberHistory -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import familymemberhistory - - -def impl_familymemberhistory_1(inst): - assert inst.condition[0].code.coding[0].code == "315619001" - assert inst.condition[0].code.coding[0].display == "Myocardial Infarction" - assert inst.condition[0].code.coding[0].system == "http://snomed.info/sct" - assert inst.condition[0].code.text == "Heart Attack" - assert inst.condition[0].contributedToDeath is True - assert inst.condition[0].note[0].text == ( - "Was fishing at the time. At least he went doing someting he " "loved." - ) - assert inst.condition[0].onsetAge.code == "a" - assert inst.condition[0].onsetAge.system == "http://unitsofmeasure.org" - assert inst.condition[0].onsetAge.unit == "yr" - assert float(inst.condition[0].onsetAge.value) == float(74) - assert inst.date == fhirtypes.DateTime.validate("2011-03-18T09:23:00+10:00") - assert inst.id == "father" - assert inst.identifier[0].value == "12345" - assert ( - inst.instantiatesUri[0] - == "http://example.org/family-member-history-questionnaire" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.display == "Peter Patient" - assert inst.patient.reference == "Patient/example" - assert inst.relationship.coding[0].code == "FTH" - assert inst.relationship.coding[0].display == "father" - assert ( - inst.relationship.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - assert inst.sex.coding[0].code == "male" - assert inst.sex.coding[0].display == "Male" - assert inst.sex.coding[0].system == "http://hl7.org/fhir/administrative-gender" - assert inst.status == "completed" - assert inst.text.div == ( - '
Father died of a' - " heart attack aged 74
" - ) - assert inst.text.status == "generated" - - -def test_familymemberhistory_1(base_settings): - """No. 1 tests collection for FamilyMemberHistory. - Test File: familymemberhistory-example.json - """ - filename = base_settings["unittest_data_dir"] / "familymemberhistory-example.json" - inst = familymemberhistory.FamilyMemberHistory.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "FamilyMemberHistory" == inst.resource_type - - impl_familymemberhistory_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "FamilyMemberHistory" == data["resourceType"] - - inst2 = familymemberhistory.FamilyMemberHistory(**data) - impl_familymemberhistory_1(inst2) - - -def impl_familymemberhistory_2(inst): - assert inst.condition[0].code.coding[0].code == "371041009" - assert inst.condition[0].code.coding[0].display == "Embolic Stroke" - assert inst.condition[0].code.coding[0].system == "http://snomed.info/sct" - assert inst.condition[0].code.text == "Stroke" - assert inst.condition[0].onsetAge.code == "a" - assert inst.condition[0].onsetAge.system == "http://unitsofmeasure.org" - assert inst.condition[0].onsetAge.unit == "yr" - assert float(inst.condition[0].onsetAge.value) == float(56) - assert inst.id == "mother" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.display == "Peter Patient" - assert inst.patient.reference == "Patient/100" - assert inst.relationship.coding[0].code == "MTH" - assert inst.relationship.coding[0].display == "mother" - assert ( - inst.relationship.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - assert inst.status == "completed" - assert inst.text.div == ( - '
Mother died of a' - " stroke aged 56
" - ) - assert inst.text.status == "generated" - - -def test_familymemberhistory_2(base_settings): - """No. 2 tests collection for FamilyMemberHistory. - Test File: familymemberhistory-example-mother.json - """ - filename = ( - base_settings["unittest_data_dir"] / "familymemberhistory-example-mother.json" - ) - inst = familymemberhistory.FamilyMemberHistory.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "FamilyMemberHistory" == inst.resource_type - - impl_familymemberhistory_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "FamilyMemberHistory" == data["resourceType"] - - inst2 = familymemberhistory.FamilyMemberHistory(**data) - impl_familymemberhistory_2(inst2) diff --git a/fhir/resources/tests/test_flag.py b/fhir/resources/tests/test_flag.py deleted file mode 100644 index 64a5d8e8..00000000 --- a/fhir/resources/tests/test_flag.py +++ /dev/null @@ -1,112 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Flag -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import flag - - -def impl_flag_1(inst): - assert inst.author.display == "Nancy Nurse" - assert inst.author.reference == "Practitioner/example" - assert inst.category[0].coding[0].code == "safety" - assert inst.category[0].coding[0].display == "Safety" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/flag-category" - ) - assert inst.category[0].text == "Safety" - assert inst.code.coding[0].code == "bigdog" - assert inst.code.coding[0].display == "Big dog" - assert inst.code.coding[0].system == "http://example.org/local" - assert inst.code.text == ( - "Patient has a big dog at his home. Always always wear a suit" - " of armor or take other active counter-measures" - ) - assert inst.id == "example" - assert inst.identifier[0].value == "12345" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2016-12-01T09:23:00+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2015-01-17T09:23:00+10:00") - assert inst.status == "inactive" - assert inst.subject.display == "Peter Patient" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Large Dog ' - "warning for Peter Patient
" - ) - assert inst.text.status == "generated" - - -def test_flag_1(base_settings): - """No. 1 tests collection for Flag. - Test File: flag-example.json - """ - filename = base_settings["unittest_data_dir"] / "flag-example.json" - inst = flag.Flag.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Flag" == inst.resource_type - - impl_flag_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Flag" == data["resourceType"] - - inst2 = flag.Flag(**data) - impl_flag_1(inst2) - - -def impl_flag_2(inst): - assert inst.category[0].coding[0].code == "infection" - assert inst.category[0].coding[0].display == "Infection Control Level" - assert inst.category[0].coding[0].system == "http://example.org/local" - assert inst.code.coding[0].code == "l3" - assert inst.code.coding[0].display == "Follow Level 3 Protocol" - assert inst.code.coding[0].system == "http://example.org/local/if1" - assert inst.encounter.reference == "Encounter/example" - assert inst.id == "example-encounter" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "active" - assert inst.subject.display == "Peter Patient" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Follow Infection' - " Control Level 3 Protocol
" - ) - assert inst.text.status == "generated" - - -def test_flag_2(base_settings): - """No. 2 tests collection for Flag. - Test File: flag-example-encounter.json - """ - filename = base_settings["unittest_data_dir"] / "flag-example-encounter.json" - inst = flag.Flag.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Flag" == inst.resource_type - - impl_flag_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Flag" == data["resourceType"] - - inst2 = flag.Flag(**data) - impl_flag_2(inst2) diff --git a/fhir/resources/tests/test_goal.py b/fhir/resources/tests/test_goal.py deleted file mode 100644 index 7d8c1b65..00000000 --- a/fhir/resources/tests/test_goal.py +++ /dev/null @@ -1,128 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Goal -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import goal - - -def impl_goal_1(inst): - assert inst.addresses[0].display == "obesity condition" - assert inst.category[0].coding[0].code == "dietary" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/goal-category" - ) - assert inst.description.text == "Target weight is 160 to 180 lbs." - assert inst.expressedBy.display == "Peter James Chalmers" - assert inst.expressedBy.reference == "Patient/example" - assert inst.id == "example" - assert inst.identifier[0].value == "123" - assert inst.lifecycleStatus == "on-hold" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcomeReference[0].display == "Body Weight Measured" - assert inst.outcomeReference[0].reference == "Observation/example" - assert inst.priority.coding[0].code == "high-priority" - assert inst.priority.coding[0].display == "High Priority" - assert ( - inst.priority.coding[0].system - == "http://terminology.hl7.org/CodeSystem/goal-priority" - ) - assert inst.priority.text == "high" - assert inst.startDate == fhirtypes.Date.validate("2015-04-05") - assert inst.statusDate == fhirtypes.Date.validate("2016-02-14") - assert ( - inst.statusReason == "Patient wants to defer weight loss until after honeymoon." - ) - assert inst.subject.display == "Peter James Chalmers" - assert inst.subject.reference == "Patient/example" - assert inst.target[0].detailRange.high.code == "[lb_av]" - assert inst.target[0].detailRange.high.system == "http://unitsofmeasure.org" - assert inst.target[0].detailRange.high.unit == "lbs" - assert float(inst.target[0].detailRange.high.value) == float(180) - assert inst.target[0].detailRange.low.code == "[lb_av]" - assert inst.target[0].detailRange.low.system == "http://unitsofmeasure.org" - assert inst.target[0].detailRange.low.unit == "lbs" - assert float(inst.target[0].detailRange.low.value) == float(160) - assert inst.target[0].dueDate == fhirtypes.Date.validate("2016-04-05") - assert inst.target[0].measure.coding[0].code == "3141-9" - assert inst.target[0].measure.coding[0].display == "Weight Measured" - assert inst.target[0].measure.coding[0].system == "http://loinc.org" - assert inst.text.status == "additional" - - -def test_goal_1(base_settings): - """No. 1 tests collection for Goal. - Test File: goal-example.json - """ - filename = base_settings["unittest_data_dir"] / "goal-example.json" - inst = goal.Goal.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Goal" == inst.resource_type - - impl_goal_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Goal" == data["resourceType"] - - inst2 = goal.Goal(**data) - impl_goal_1(inst2) - - -def impl_goal_2(inst): - assert inst.achievementStatus.coding[0].code == "achieved" - assert inst.achievementStatus.coding[0].display == "Achieved" - assert ( - inst.achievementStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/goal-achievement" - ) - assert inst.achievementStatus.text == "Achieved" - assert inst.description.text == "Stop smoking" - assert inst.id == "stop-smoking" - assert inst.identifier[0].value == "123" - assert inst.lifecycleStatus == "completed" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcomeCode[0].coding[0].code == "8517006" - assert inst.outcomeCode[0].coding[0].display == "Ex-smoker (finding)" - assert inst.outcomeCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.outcomeCode[0].text == "Former smoker" - assert inst.startDate == fhirtypes.Date.validate("2015-04-05") - assert inst.subject.display == "Peter James Chalmers" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "additional" - - -def test_goal_2(base_settings): - """No. 2 tests collection for Goal. - Test File: goal-example-stop-smoking.json - """ - filename = base_settings["unittest_data_dir"] / "goal-example-stop-smoking.json" - inst = goal.Goal.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Goal" == inst.resource_type - - impl_goal_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Goal" == data["resourceType"] - - inst2 = goal.Goal(**data) - impl_goal_2(inst2) diff --git a/fhir/resources/tests/test_graphdefinition.py b/fhir/resources/tests/test_graphdefinition.py deleted file mode 100644 index aae8c431..00000000 --- a/fhir/resources/tests/test_graphdefinition.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/GraphDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import graphdefinition - - -def impl_graphdefinition_1(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2015-08-04T09:23:00+10:00") - assert inst.description == ( - "Specify to include list references when generating a " - "document using the $document operation" - ) - assert inst.id == "example" - assert inst.link[0].description == "Link to List" - assert inst.link[0].path == "Composition.section.entry" - assert inst.link[0].target[0].compartment[0].code == "Patient" - assert inst.link[0].target[0].compartment[0].rule == "identical" - assert inst.link[0].target[0].compartment[0].use == "requirement" - assert inst.link[0].target[0].link[0].description == "Include any list entries" - assert inst.link[0].target[0].link[0].path == "List.entry.item" - assert inst.link[0].target[0].link[0].target[0].compartment[0].code == "Patient" - assert inst.link[0].target[0].link[0].target[0].compartment[0].rule == "identical" - assert inst.link[0].target[0].link[0].target[0].compartment[0].use == "requirement" - assert inst.link[0].target[0].link[0].target[0].type == "Resource" - assert inst.link[0].target[0].type == "List" - assert inst.name == "Document Generation Template" - assert inst.publisher == "FHIR Project" - assert inst.start == "Composition" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://h7.org/fhir/GraphDefinition/example" - - -def test_graphdefinition_1(base_settings): - """No. 1 tests collection for GraphDefinition. - Test File: graphdefinition-example.json - """ - filename = base_settings["unittest_data_dir"] / "graphdefinition-example.json" - inst = graphdefinition.GraphDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "GraphDefinition" == inst.resource_type - - impl_graphdefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "GraphDefinition" == data["resourceType"] - - inst2 = graphdefinition.GraphDefinition(**data) - impl_graphdefinition_1(inst2) diff --git a/fhir/resources/tests/test_group.py b/fhir/resources/tests/test_group.py deleted file mode 100644 index ea9a5cf4..00000000 --- a/fhir/resources/tests/test_group.py +++ /dev/null @@ -1,194 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Group -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import group - - -def impl_group_1(inst): - assert inst.actual is True - assert inst.characteristic[0].code.text == "gender" - assert inst.characteristic[0].exclude is False - assert inst.characteristic[0].valueCodeableConcept.text == "mixed" - assert inst.characteristic[1].code.text == "owner" - assert inst.characteristic[1].exclude is False - assert inst.characteristic[1].valueCodeableConcept.text == "John Smith" - assert inst.code.text == "Horse" - assert inst.id == "101" - assert ( - inst.identifier[0].system - == "http://someveterinarianclinic.org/fhir/NamingSystem/herds" - ) - assert inst.identifier[0].value == "12345" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "John's herd" - assert inst.quantity == 25 - assert inst.text.status == "additional" - assert inst.type == "animal" - - -def test_group_1(base_settings): - """No. 1 tests collection for Group. - Test File: group-example.json - """ - filename = base_settings["unittest_data_dir"] / "group-example.json" - inst = group.Group.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Group" == inst.resource_type - - impl_group_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Group" == data["resourceType"] - - inst2 = group.Group(**data) - impl_group_1(inst2) - - -def impl_group_2(inst): - assert inst.actual is True - assert inst.id == "102" - assert inst.member[0].entity.reference == "Patient/pat1" - assert inst.member[0].period.start == fhirtypes.DateTime.validate( - "2014-10-08T09:23:00+10:00" - ) - assert inst.member[1].entity.reference == "Patient/pat2" - assert inst.member[1].inactive is True - assert inst.member[1].period.start == fhirtypes.DateTime.validate( - "2015-04-02T09:23:00+10:00" - ) - assert inst.member[2].entity.reference == "Patient/pat3" - assert inst.member[2].period.start == fhirtypes.DateTime.validate( - "2015-08-06T09:23:00+10:00" - ) - assert inst.member[3].entity.reference == "Patient/pat4" - assert inst.member[3].period.start == fhirtypes.DateTime.validate( - "2015-08-06T09:23:00+10:00" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "additional" - assert inst.type == "person" - - -def test_group_2(base_settings): - """No. 2 tests collection for Group. - Test File: group-example-member.json - """ - filename = base_settings["unittest_data_dir"] / "group-example-member.json" - inst = group.Group.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Group" == inst.resource_type - - impl_group_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Group" == data["resourceType"] - - inst2 = group.Group(**data) - impl_group_2(inst2) - - -def impl_group_3(inst): - assert inst.actual is True - assert inst.characteristic[0].code.coding[0].code == "attributed-to" - assert inst.characteristic[0].code.coding[0].system == "http://example.org" - assert inst.characteristic[0].code.text == "Patients primarily attributed to" - assert inst.characteristic[0].exclude is False - assert inst.characteristic[0].valueReference.reference == "Practitioner/123" - assert inst.id == "example-patientlist" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "additional" - assert inst.type == "person" - - -def test_group_3(base_settings): - """No. 3 tests collection for Group. - Test File: group-example-patientlist.json - """ - filename = base_settings["unittest_data_dir"] / "group-example-patientlist.json" - inst = group.Group.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Group" == inst.resource_type - - impl_group_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Group" == data["resourceType"] - - inst2 = group.Group(**data) - impl_group_3(inst2) - - -def impl_group_4(inst): - assert inst.active is True - assert inst.actual is True - assert inst.characteristic[0].code.text == "gender" - assert inst.characteristic[0].exclude is False - assert inst.characteristic[0].valueCodeableConcept.text == "female" - assert inst.code.coding[0].code == "388393002" - assert inst.code.coding[0].display == "Genus Sus (organism)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.coding[1].code == "POR" - assert inst.code.coding[1].display == "porcine" - assert inst.code.coding[1].system == "https://www.aphis.usda.gov" - assert inst.code.text == "Porcine" - assert inst.extension[0].url == "http://example.org/fhir/StructureDefinition/owner" - assert inst.extension[0].valueReference.display == "Peter Chalmers" - assert inst.extension[0].valueReference.reference == "RelatedPerson/peter" - assert inst.id == "herd1" - assert inst.identifier[0].system == "https://vetmed.iastate.edu/vdl" - assert inst.identifier[0].value == "20171120-1234" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Breeding herd" - assert inst.quantity == 2500 - assert inst.text.status == "generated" - assert inst.type == "animal" - - -def test_group_4(base_settings): - """No. 4 tests collection for Group. - Test File: group-example-herd1.json - """ - filename = base_settings["unittest_data_dir"] / "group-example-herd1.json" - inst = group.Group.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Group" == inst.resource_type - - impl_group_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Group" == data["resourceType"] - - inst2 = group.Group(**data) - impl_group_4(inst2) diff --git a/fhir/resources/tests/test_guidanceresponse.py b/fhir/resources/tests/test_guidanceresponse.py deleted file mode 100644 index 2c37ba3e..00000000 --- a/fhir/resources/tests/test_guidanceresponse.py +++ /dev/null @@ -1,59 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/GuidanceResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import guidanceresponse - - -def impl_guidanceresponse_1(inst): - assert inst.contained[0].id == "outputParameters1" - assert inst.encounter.reference == "Encounter/example" - assert inst.id == "example" - assert inst.identifier[0].system == "http://example.org" - assert inst.identifier[0].value == "guidanceResponse1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.moduleUri == ( - "http://someguidelineprovider.org/radiology-appropriateness-" "guidelines.html" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2017-03-10T16:02:00Z" - ) - assert inst.outputParameters.reference == "#outputParameters1" - assert inst.performer.reference == "Device/software" - assert inst.reasonCode[0].text == "Guideline Appropriate Ordering Assessment" - assert inst.requestIdentifier.system == "http://example.org" - assert inst.requestIdentifier.value == "guidanceRequest1" - assert inst.status == "success" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_guidanceresponse_1(base_settings): - """No. 1 tests collection for GuidanceResponse. - Test File: guidanceresponse-example.json - """ - filename = base_settings["unittest_data_dir"] / "guidanceresponse-example.json" - inst = guidanceresponse.GuidanceResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "GuidanceResponse" == inst.resource_type - - impl_guidanceresponse_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "GuidanceResponse" == data["resourceType"] - - inst2 = guidanceresponse.GuidanceResponse(**data) - impl_guidanceresponse_1(inst2) diff --git a/fhir/resources/tests/test_healthcareservice.py b/fhir/resources/tests/test_healthcareservice.py deleted file mode 100644 index d130d9f4..00000000 --- a/fhir/resources/tests/test_healthcareservice.py +++ /dev/null @@ -1,134 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/HealthcareService -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import healthcareservice - - -def impl_healthcareservice_1(inst): - assert inst.active is True - assert inst.appointmentRequired is False - assert ( - inst.availabilityExceptions - == "Reduced capacity is available during the Christmas period" - ) - assert inst.availableTime[0].allDay is True - assert inst.availableTime[0].daysOfWeek[0] == "wed" - assert inst.availableTime[1].availableEndTime == fhirtypes.Time.validate("05:30:00") - assert inst.availableTime[1].availableStartTime == fhirtypes.Time.validate( - "08:30:00" - ) - assert inst.availableTime[1].daysOfWeek[0] == "mon" - assert inst.availableTime[1].daysOfWeek[1] == "tue" - assert inst.availableTime[1].daysOfWeek[2] == "thu" - assert inst.availableTime[1].daysOfWeek[3] == "fri" - assert inst.availableTime[2].availableEndTime == fhirtypes.Time.validate("04:30:00") - assert inst.availableTime[2].availableStartTime == fhirtypes.Time.validate( - "09:30:00" - ) - assert inst.availableTime[2].daysOfWeek[0] == "sat" - assert inst.availableTime[2].daysOfWeek[1] == "fri" - assert inst.category[0].coding[0].code == "8" - assert inst.category[0].coding[0].display == "Counselling" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/service-category" - ) - assert inst.category[0].text == "Counselling" - assert inst.characteristic[0].coding[0].display == "Wheelchair access" - assert inst.comment == ( - "Providing Specialist psychology services to the greater Den " - "Burg area, many years of experience dealing with PTSD issues" - ) - assert inst.contained[0].id == "DenBurg" - assert inst.coverageArea[0].display == "Greater Denburg area" - assert inst.coverageArea[0].reference == "#DenBurg" - assert inst.eligibility[0].code.coding[0].display == "DVA Required" - assert inst.eligibility[0].comment == ( - "Evidence of application for DVA status may be sufficient for" - " commencing assessment" - ) - assert inst.endpoint[0].reference == "Endpoint/example" - assert inst.id == "example" - assert inst.identifier[0].system == "http://example.org/shared-ids" - assert inst.identifier[0].value == "HS-12" - assert inst.location[0].reference == "Location/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Consulting psychologists and/or psychology services" - assert inst.notAvailable[0].description == "Christmas/Boxing Day" - assert inst.notAvailable[0].during.end == fhirtypes.DateTime.validate( - "2015-12-26T11:15:33+10:00" - ) - assert inst.notAvailable[0].during.start == fhirtypes.DateTime.validate( - "2015-12-25T11:15:33+10:00" - ) - assert inst.notAvailable[1].description == "New Years Day" - assert inst.notAvailable[1].during.end == fhirtypes.DateTime.validate( - "2016-01-01T11:15:33+10:00" - ) - assert inst.notAvailable[1].during.start == fhirtypes.DateTime.validate( - "2016-01-01T11:15:33+10:00" - ) - assert inst.program[0].text == "PTSD outreach" - assert inst.providedBy.display == "Burgers University Medical Center" - assert inst.providedBy.reference == "Organization/f001" - assert inst.referralMethod[0].coding[0].code == "phone" - assert inst.referralMethod[0].coding[0].display == "Phone" - assert inst.referralMethod[1].coding[0].code == "fax" - assert inst.referralMethod[1].coding[0].display == "Fax" - assert inst.referralMethod[2].coding[0].code == "elec" - assert inst.referralMethod[2].coding[0].display == "Secure Messaging" - assert inst.referralMethod[3].coding[0].code == "semail" - assert inst.referralMethod[3].coding[0].display == "Secure Email" - assert inst.serviceProvisionCode[0].coding[0].code == "cost" - assert inst.serviceProvisionCode[0].coding[0].display == "Fees apply" - assert inst.serviceProvisionCode[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/service-provision-" "conditions" - ) - assert inst.specialty[0].coding[0].code == "47505003" - assert inst.specialty[0].coding[0].display == "Posttraumatic stress disorder" - assert inst.specialty[0].coding[0].system == "http://snomed.info/sct" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "(555) silent" - assert inst.telecom[1].system == "email" - assert inst.telecom[1].use == "work" - assert inst.telecom[1].value == "directaddress@example.com" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "394913002" - assert inst.type[0].coding[0].display == "Psychotherapy" - assert inst.type[0].coding[0].system == "http://snomed.info/sct" - assert inst.type[1].coding[0].code == "394587001" - assert inst.type[1].coding[0].display == "Psychiatry" - assert inst.type[1].coding[0].system == "http://snomed.info/sct" - - -def test_healthcareservice_1(base_settings): - """No. 1 tests collection for HealthcareService. - Test File: healthcareservice-example.json - """ - filename = base_settings["unittest_data_dir"] / "healthcareservice-example.json" - inst = healthcareservice.HealthcareService.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "HealthcareService" == inst.resource_type - - impl_healthcareservice_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "HealthcareService" == data["resourceType"] - - inst2 = healthcareservice.HealthcareService(**data) - impl_healthcareservice_1(inst2) diff --git a/fhir/resources/tests/test_imagingstudy.py b/fhir/resources/tests/test_imagingstudy.py deleted file mode 100644 index d57ce4b9..00000000 --- a/fhir/resources/tests/test_imagingstudy.py +++ /dev/null @@ -1,199 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ImagingStudy -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import imagingstudy - - -def impl_imagingstudy_1(inst): - assert inst.basedOn[0].reference == "ServiceRequest/example" - assert inst.encounter.reference == "Encounter/example" - assert inst.endpoint[0].reference == "Endpoint/example-wadors" - assert inst.id == "example-xr" - assert inst.identifier[0].system == "urn:dicom:uid" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == ( - "urn:oid:2.16.124.113543.6003.1154777499.30246.19789.35034300" "46" - ) - assert inst.identifier[1].assigner.reference == "Organization/dicom-organization" - assert inst.identifier[1].type.coding[0].code == "ACSN" - assert ( - inst.identifier[1].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[1].use == "usual" - assert inst.identifier[1].value == "W12342398" - assert inst.identifier[2].assigner.reference == "Organization/dicom-organization" - assert inst.identifier[2].use == "secondary" - assert inst.identifier[2].value == "55551234" - assert inst.interpreter[0].reference == "Practitioner/example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.modality[0].code == "DX" - assert inst.modality[0].system == "http://dicom.nema.org/resources/ontology/DCM" - assert inst.note[0].text == "XR Wrist 3+ Views" - assert inst.numberOfInstances == 2 - assert inst.numberOfSeries == 1 - assert inst.procedureCode[0].coding[0].code == "RPID2589" - assert inst.procedureCode[0].coding[0].display == "XR Wrist 3+ Views" - assert inst.procedureCode[0].coding[0].system == "http://www.radlex.org" - assert inst.procedureCode[0].text == "XR Wrist 3+ Views" - assert inst.procedureReference.reference == "Procedure/example" - assert inst.reasonCode[0].coding[0].code == "357009" - assert ( - inst.reasonCode[0].coding[0].display - == "Closed fracture of trapezoidal bone of wrist" - ) - assert inst.reasonCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.referrer.reference == "Practitioner/example" - assert inst.series[0].bodySite.code == "T-15460" - assert inst.series[0].bodySite.display == "Wrist Joint" - assert inst.series[0].bodySite.system == "http://snomed.info/sct" - assert inst.series[0].description == "XR Wrist 3+ Views" - assert inst.series[0].endpoint[0].reference == "Endpoint/example-wadors" - assert inst.series[0].instance[0].number == 1 - assert ( - inst.series[0].instance[0].sopClass.code == "urn:oid:1.2.840.10008.5.1.4.1.1.2" - ) - assert inst.series[0].instance[0].sopClass.system == "urn:ietf:rfc:3986" - assert inst.series[0].instance[0].title == "PA VIEW" - assert ( - inst.series[0].instance[0].uid - == "2.16.124.113543.6003.1154777499.30246.19789.3503430045.1.1" - ) - assert inst.series[0].instance[1].number == 2 - assert ( - inst.series[0].instance[1].sopClass.code == "urn:oid:1.2.840.10008.5.1.4.1.1.2" - ) - assert inst.series[0].instance[1].sopClass.system == "urn:ietf:rfc:3986" - assert inst.series[0].instance[1].title == "LL VIEW" - assert ( - inst.series[0].instance[1].uid - == "2.16.124.113543.6003.1154777499.30246.19789.3503430045.1.2" - ) - assert inst.series[0].laterality.code == "419161000" - assert inst.series[0].laterality.display == "Unilateral left" - assert inst.series[0].laterality.system == "http://snomed.info/sct" - assert inst.series[0].modality.code == "DX" - assert ( - inst.series[0].modality.system == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.series[0].number == 3 - assert inst.series[0].numberOfInstances == 2 - assert inst.series[0].performer[0].actor.reference == "Practitioner/example" - assert inst.series[0].performer[0].function.coding[0].code == "PRF" - assert ( - inst.series[0].performer[0].function.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.series[0].started == fhirtypes.DateTime.validate( - "2011-01-01T11:01:20+03:00" - ) - assert ( - inst.series[0].uid == "2.16.124.113543.6003.1154777499.30246.19789.3503430045.1" - ) - assert inst.started == fhirtypes.DateTime.validate("2017-01-01T11:01:20+03:00") - assert inst.status == "available" - assert inst.subject.reference == "Patient/dicom" - assert inst.text.div == ( - '
XR Wrist 3+ ' - "Views. John Smith (MRN: 09236). Accession: W12342398. " - "Performed: 2017-01-01. 1 series, 2 images.
" - ) - assert inst.text.status == "generated" - - -def test_imagingstudy_1(base_settings): - """No. 1 tests collection for ImagingStudy. - Test File: imagingstudy-example-xr.json - """ - filename = base_settings["unittest_data_dir"] / "imagingstudy-example-xr.json" - inst = imagingstudy.ImagingStudy.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ImagingStudy" == inst.resource_type - - impl_imagingstudy_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ImagingStudy" == data["resourceType"] - - inst2 = imagingstudy.ImagingStudy(**data) - impl_imagingstudy_1(inst2) - - -def impl_imagingstudy_2(inst): - assert inst.id == "example" - assert inst.identifier[0].system == "urn:dicom:uid" - assert inst.identifier[0].value == ( - "urn:oid:2.16.124.113543.6003.1154777499.30246.19789.35034300" "45" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.numberOfInstances == 1 - assert inst.numberOfSeries == 1 - assert inst.series[0].bodySite.code == "67734004" - assert inst.series[0].bodySite.display == "Upper Trunk Structure" - assert inst.series[0].bodySite.system == "http://snomed.info/sct" - assert inst.series[0].description == "CT Surview 180" - assert inst.series[0].instance[0].number == 1 - assert ( - inst.series[0].instance[0].sopClass.code == "urn:oid:1.2.840.10008.5.1.4.1.1.2" - ) - assert inst.series[0].instance[0].sopClass.system == "urn:ietf:rfc:3986" - assert ( - inst.series[0].instance[0].uid - == "2.16.124.113543.6003.189642796.63084.16748.2599092903" - ) - assert inst.series[0].modality.code == "CT" - assert ( - inst.series[0].modality.system == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.series[0].number == 3 - assert inst.series[0].numberOfInstances == 1 - assert ( - inst.series[0].uid == "2.16.124.113543.6003.2588828330.45298.17418.2723805630" - ) - assert inst.started == fhirtypes.DateTime.validate("2011-01-01T11:01:20+03:00") - assert inst.status == "available" - assert inst.subject.reference == "Patient/dicom" - assert inst.text.div == ( - '
CT Chest. John ' - "Smith (MRN: 09236). Accession: W12342398. Performed: " - "2011-01-01. 3 series, 12 images.
" - ) - assert inst.text.status == "generated" - - -def test_imagingstudy_2(base_settings): - """No. 2 tests collection for ImagingStudy. - Test File: imagingstudy-example.json - """ - filename = base_settings["unittest_data_dir"] / "imagingstudy-example.json" - inst = imagingstudy.ImagingStudy.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ImagingStudy" == inst.resource_type - - impl_imagingstudy_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ImagingStudy" == data["resourceType"] - - inst2 = imagingstudy.ImagingStudy(**data) - impl_imagingstudy_2(inst2) diff --git a/fhir/resources/tests/test_immunization.py b/fhir/resources/tests/test_immunization.py deleted file mode 100644 index 72dbd819..00000000 --- a/fhir/resources/tests/test_immunization.py +++ /dev/null @@ -1,384 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Immunization -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import immunization - - -def impl_immunization_1(inst): - assert inst.doseQuantity.code == "mg" - assert inst.doseQuantity.system == "http://unitsofmeasure.org" - assert float(inst.doseQuantity.value) == float(5) - assert inst.education[0].documentType == "253088698300010311120702" - assert inst.education[0].presentationDate == fhirtypes.DateTime.validate( - "2013-01-10T11:15:33+10:00" - ) - assert inst.education[0].publicationDate == fhirtypes.DateTime.validate( - "2012-07-02T11:15:33+10:00" - ) - assert inst.encounter.reference == "Encounter/example" - assert inst.expirationDate == fhirtypes.Date.validate("2015-02-15") - assert inst.fundingSource.coding[0].code == "private" - assert inst.fundingSource.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/immunization-funding-" "source" - ) - assert inst.id == "example" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.1234" - assert inst.isSubpotent is True - assert inst.location.reference == "Location/1" - assert inst.lotNumber == "AAJN11K" - assert inst.manufacturer.reference == "Organization/hl7" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "Notes on adminstration of vaccine" - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2013-01-10T11:15:33+10:00" - ) - assert inst.patient.reference == "Patient/example" - assert inst.performer[0].actor.reference == "Practitioner/example" - assert inst.performer[0].function.coding[0].code == "OP" - assert ( - inst.performer[0].function.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0443" - ) - assert inst.performer[1].actor.reference == "Practitioner/example" - assert inst.performer[1].function.coding[0].code == "AP" - assert ( - inst.performer[1].function.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0443" - ) - assert inst.primarySource is True - assert inst.programEligibility[0].coding[0].code == "ineligible" - assert inst.programEligibility[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/immunization-program-" "eligibility" - ) - assert inst.reasonCode[0].coding[0].code == "429060002" - assert inst.reasonCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.route.coding[0].code == "IM" - assert inst.route.coding[0].display == "Injection, intramuscular" - assert inst.route.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/v3-RouteOfAdministrati" "on" - ) - assert inst.site.coding[0].code == "LA" - assert inst.site.coding[0].display == "left arm" - assert ( - inst.site.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActSite" - ) - assert inst.status == "completed" - assert inst.text.status == "generated" - assert inst.vaccineCode.coding[0].code == "FLUVAX" - assert inst.vaccineCode.coding[0].system == "urn:oid:1.2.36.1.2001.1005.17" - assert inst.vaccineCode.text == "Fluvax (Influenza)" - - -def test_immunization_1(base_settings): - """No. 1 tests collection for Immunization. - Test File: immunization-example.json - """ - filename = base_settings["unittest_data_dir"] / "immunization-example.json" - inst = immunization.Immunization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Immunization" == inst.resource_type - - impl_immunization_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Immunization" == data["resourceType"] - - inst2 = immunization.Immunization(**data) - impl_immunization_1(inst2) - - -def impl_immunization_2(inst): - assert inst.id == "historical" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.1234" - assert inst.location.reference == "Location/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "Notes on adminstration of a historical vaccine" - assert inst.occurrenceString == "January 2012" - assert inst.patient.reference == "Patient/example" - assert inst.primarySource is False - assert inst.reportOrigin.coding[0].code == "record" - assert ( - inst.reportOrigin.coding[0].system - == "http://terminology.hl7.org/CodeSystem/immunization-origin" - ) - assert inst.reportOrigin.text == "Written Record" - assert inst.status == "completed" - assert inst.text.status == "generated" - assert inst.vaccineCode.coding[0].code == "GNFLU" - assert inst.vaccineCode.coding[0].system == "urn:oid:1.2.36.1.2001.1005.17" - assert inst.vaccineCode.text == "Influenza" - - -def test_immunization_2(base_settings): - """No. 2 tests collection for Immunization. - Test File: immunization-example-historical.json - """ - filename = ( - base_settings["unittest_data_dir"] / "immunization-example-historical.json" - ) - inst = immunization.Immunization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Immunization" == inst.resource_type - - impl_immunization_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Immunization" == data["resourceType"] - - inst2 = immunization.Immunization(**data) - impl_immunization_2(inst2) - - -def impl_immunization_3(inst): - assert inst.doseQuantity.code == "mg" - assert inst.doseQuantity.system == "http://unitsofmeasure.org" - assert float(inst.doseQuantity.value) == float(5) - assert inst.encounter.reference == "Encounter/example" - assert inst.expirationDate == fhirtypes.Date.validate("2018-12-15") - assert inst.fundingSource.coding[0].code == "private" - assert inst.fundingSource.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/immunization-funding-" "source" - ) - assert inst.id == "protocol" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.1234" - assert inst.isSubpotent is False - assert inst.location.reference == "Location/1" - assert inst.lotNumber == "PT123F" - assert inst.manufacturer.reference == "Organization/hl7" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2018-06-18T11:15:33+10:00" - ) - assert inst.patient.reference == "Patient/example" - assert inst.performer[0].actor.reference == "Practitioner/example" - assert inst.performer[0].function.coding[0].code == "OP" - assert ( - inst.performer[0].function.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0443" - ) - assert inst.performer[1].actor.reference == "Practitioner/example" - assert inst.performer[1].function.coding[0].code == "AP" - assert ( - inst.performer[1].function.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0443" - ) - assert inst.primarySource is True - assert inst.programEligibility[0].coding[0].code == "ineligible" - assert inst.programEligibility[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/immunization-program-" "eligibility" - ) - assert inst.protocolApplied[0].doseNumberPositiveInt == 1 - assert inst.protocolApplied[0].series == "2-dose" - assert inst.protocolApplied[0].targetDisease[0].coding[0].code == "40468003" - assert ( - inst.protocolApplied[0].targetDisease[0].coding[0].system - == "http://snomed.info/sct" - ) - assert inst.protocolApplied[1].doseNumberPositiveInt == 2 - assert inst.protocolApplied[1].series == "3-dose" - assert inst.protocolApplied[1].targetDisease[0].coding[0].code == "66071002" - assert ( - inst.protocolApplied[1].targetDisease[0].coding[0].system - == "http://snomed.info/sct" - ) - assert inst.route.coding[0].code == "IM" - assert inst.route.coding[0].display == "Injection, intramuscular" - assert inst.route.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/v3-RouteOfAdministrati" "on" - ) - assert inst.site.coding[0].code == "LA" - assert inst.site.coding[0].display == "left arm" - assert ( - inst.site.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActSite" - ) - assert inst.status == "completed" - assert inst.text.status == "generated" - assert inst.vaccineCode.coding[0].code == "104" - assert inst.vaccineCode.coding[0].system == "http://hl7.org/fhir/sid/cvx" - assert inst.vaccineCode.text == "Twinrix (HepA/HepB)" - - -def test_immunization_3(base_settings): - """No. 3 tests collection for Immunization. - Test File: immunization-example-protocol.json - """ - filename = base_settings["unittest_data_dir"] / "immunization-example-protocol.json" - inst = immunization.Immunization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Immunization" == inst.resource_type - - impl_immunization_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Immunization" == data["resourceType"] - - inst2 = immunization.Immunization(**data) - impl_immunization_3(inst2) - - -def impl_immunization_4(inst): - assert inst.id == "notGiven" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2013-01-10T11:15:33+10:00" - ) - assert inst.patient.reference == "Patient/example" - assert inst.primarySource is True - assert inst.status == "not-done" - assert inst.statusReason.coding[0].code == "MEDPREC" - assert inst.statusReason.coding[0].display == "medical precaution" - assert ( - inst.statusReason.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - assert inst.vaccineCode.coding[0].code == "01" - assert inst.vaccineCode.coding[0].display == "DTP" - assert inst.vaccineCode.coding[0].system == "http://hl7.org/fhir/sid/cvx" - - -def test_immunization_4(base_settings): - """No. 4 tests collection for Immunization. - Test File: immunization-example-refused.json - """ - filename = base_settings["unittest_data_dir"] / "immunization-example-refused.json" - inst = immunization.Immunization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Immunization" == inst.resource_type - - impl_immunization_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Immunization" == data["resourceType"] - - inst2 = immunization.Immunization(**data) - impl_immunization_4(inst2) - - -def impl_immunization_5(inst): - assert inst.doseQuantity.code == "ml" - assert inst.doseQuantity.system == "http://unitsofmeasure.org" - assert float(inst.doseQuantity.value) == float(0.5) - assert inst.education[0].documentType == "253088698300010311120702" - assert inst.education[0].presentationDate == fhirtypes.DateTime.validate( - "2013-01-10T11:15:33+10:00" - ) - assert inst.education[0].publicationDate == fhirtypes.DateTime.validate( - "2012-07-02T11:15:33+10:00" - ) - assert inst.encounter.reference == "Encounter/example" - assert inst.expirationDate == fhirtypes.Date.validate("2015-02-28") - assert inst.fundingSource.coding[0].code == "private" - assert inst.fundingSource.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/immunization-funding-" "source" - ) - assert inst.id == "subpotent" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.1234" - assert inst.isSubpotent is False - assert inst.location.reference == "Location/1" - assert inst.lotNumber == "AAJN11K" - assert inst.manufacturer.reference == "Organization/hl7" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "Notes on adminstration of vaccine" - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2015-01-15T11:15:33+10:00" - ) - assert inst.patient.reference == "Patient/example" - assert inst.performer[0].actor.reference == "Practitioner/example" - assert inst.performer[0].function.coding[0].code == "OP" - assert ( - inst.performer[0].function.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0443" - ) - assert inst.performer[1].actor.reference == "Practitioner/example" - assert inst.performer[1].function.coding[0].code == "AP" - assert ( - inst.performer[1].function.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0443" - ) - assert inst.primarySource is True - assert inst.programEligibility[0].coding[0].code == "ineligible" - assert inst.programEligibility[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/immunization-program-" "eligibility" - ) - assert inst.route.coding[0].code == "IM" - assert inst.route.coding[0].display == "Injection, intramuscular" - assert inst.route.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/v3-RouteOfAdministrati" "on" - ) - assert inst.site.coding[0].code == "LT" - assert inst.site.coding[0].display == "left thigh" - assert ( - inst.site.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActSite" - ) - assert inst.status == "completed" - assert inst.subpotentReason[0].coding[0].code == "partial" - assert inst.subpotentReason[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/immunization-" "subpotent-reason" - ) - assert inst.text.status == "generated" - assert inst.vaccineCode.coding[0].code == "GNHEP" - assert inst.vaccineCode.coding[0].system == "urn:oid:1.2.36.1.2001.1005.17" - assert inst.vaccineCode.text == "Hepatitis B" - - -def test_immunization_5(base_settings): - """No. 5 tests collection for Immunization. - Test File: immunization-example-subpotent.json - """ - filename = ( - base_settings["unittest_data_dir"] / "immunization-example-subpotent.json" - ) - inst = immunization.Immunization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Immunization" == inst.resource_type - - impl_immunization_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Immunization" == data["resourceType"] - - inst2 = immunization.Immunization(**data) - impl_immunization_5(inst2) diff --git a/fhir/resources/tests/test_immunizationevaluation.py b/fhir/resources/tests/test_immunizationevaluation.py deleted file mode 100644 index bf984785..00000000 --- a/fhir/resources/tests/test_immunizationevaluation.py +++ /dev/null @@ -1,120 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ImmunizationEvaluation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import immunizationevaluation - - -def impl_immunizationevaluation_1(inst): - assert inst.authority.reference == "Organization/hl7" - assert inst.date == fhirtypes.DateTime.validate("2013-01-10T11:15:33+10:00") - assert inst.doseNumberPositiveInt == 1 - assert inst.doseStatus.coding[0].code == "valid" - assert inst.doseStatus.coding[0].display == "Valid" - assert inst.doseStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/immunization-" "evaluation-dose-status" - ) - assert inst.id == "example" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.1234" - assert inst.immunizationEvent.reference == "Immunization/example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.series == "Vaccination Series 1" - assert inst.seriesDosesPositiveInt == 3 - assert inst.status == "completed" - assert inst.targetDisease.coding[0].code == "1857005" - assert inst.targetDisease.coding[0].system == "http://snomed.info/sct" - assert inst.text.status == "generated" - - -def test_immunizationevaluation_1(base_settings): - """No. 1 tests collection for ImmunizationEvaluation. - Test File: immunizationevaluation-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "immunizationevaluation-example.json" - ) - inst = immunizationevaluation.ImmunizationEvaluation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ImmunizationEvaluation" == inst.resource_type - - impl_immunizationevaluation_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ImmunizationEvaluation" == data["resourceType"] - - inst2 = immunizationevaluation.ImmunizationEvaluation(**data) - impl_immunizationevaluation_1(inst2) - - -def impl_immunizationevaluation_2(inst): - assert inst.authority.reference == "Organization/hl7" - assert inst.date == fhirtypes.DateTime.validate("2013-01-10T11:15:33+10:00") - assert inst.doseNumberPositiveInt == 2 - assert inst.doseStatus.coding[0].code == "notvalid" - assert inst.doseStatus.coding[0].display == "Not Valid" - assert inst.doseStatus.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/immunization-" "evaluation-dose-status" - ) - assert inst.doseStatusReason[0].coding[0].code == "outsidesched" - assert ( - inst.doseStatusReason[0].coding[0].display - == "Administered outside recommended schedule" - ) - assert inst.doseStatusReason[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/immunization-" - "evaluation-dose-status-reason" - ) - assert inst.id == "notValid" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.1234" - assert inst.immunizationEvent.reference == "Immunization/example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.series == "Vaccination Series 1" - assert inst.seriesDosesPositiveInt == 3 - assert inst.status == "completed" - assert inst.targetDisease.coding[0].code == "1857005" - assert inst.targetDisease.coding[0].system == "http://snomed.info/sct" - assert inst.text.status == "generated" - - -def test_immunizationevaluation_2(base_settings): - """No. 2 tests collection for ImmunizationEvaluation. - Test File: immunizationevaluation-example-notvalid.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "immunizationevaluation-example-notvalid.json" - ) - inst = immunizationevaluation.ImmunizationEvaluation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ImmunizationEvaluation" == inst.resource_type - - impl_immunizationevaluation_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ImmunizationEvaluation" == data["resourceType"] - - inst2 = immunizationevaluation.ImmunizationEvaluation(**data) - impl_immunizationevaluation_2(inst2) diff --git a/fhir/resources/tests/test_immunizationrecommendation.py b/fhir/resources/tests/test_immunizationrecommendation.py deleted file mode 100644 index 659b8569..00000000 --- a/fhir/resources/tests/test_immunizationrecommendation.py +++ /dev/null @@ -1,202 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ImmunizationRecommendation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import immunizationrecommendation - - -def impl_immunizationrecommendation_1(inst): - assert inst.authority.reference == "Organization/hl7" - assert inst.date == fhirtypes.DateTime.validate("2015-02-09T11:04:15.817-05:00") - assert inst.id == "example" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.1235" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.recommendation[0].dateCriterion[0].code.coding[0].code == "earliest" - assert ( - inst.recommendation[0].dateCriterion[0].code.coding[0].display - == "Earliest Date" - ) - assert inst.recommendation[0].dateCriterion[0].code.coding[0].system == ( - "http://example.org/fhir/CodeSystem/immunization-" - "recommendation-date-criterion" - ) - assert inst.recommendation[0].dateCriterion[0].value == fhirtypes.DateTime.validate( - "2015-12-01T00:00:00-05:00" - ) - assert inst.recommendation[0].dateCriterion[1].code.coding[0].code == "recommended" - assert ( - inst.recommendation[0].dateCriterion[1].code.coding[0].display == "Recommended" - ) - assert inst.recommendation[0].dateCriterion[1].code.coding[0].system == ( - "http://example.org/fhir/CodeSystem/immunization-" - "recommendation-date-criterion" - ) - assert inst.recommendation[0].dateCriterion[1].value == fhirtypes.DateTime.validate( - "2015-12-01T00:00:00-05:00" - ) - assert inst.recommendation[0].dateCriterion[2].code.coding[0].code == "overdue" - assert ( - inst.recommendation[0].dateCriterion[2].code.coding[0].display - == "Past Due Date" - ) - assert inst.recommendation[0].dateCriterion[2].code.coding[0].system == ( - "http://example.org/fhir/CodeSystem/immunization-" - "recommendation-date-criterion" - ) - assert inst.recommendation[0].dateCriterion[2].value == fhirtypes.DateTime.validate( - "2016-12-28T00:00:00-05:00" - ) - assert inst.recommendation[0].description == "First sequence in protocol" - assert inst.recommendation[0].doseNumberPositiveInt == 1 - assert inst.recommendation[0].forecastStatus.text == "Not Complete" - assert inst.recommendation[0].series == "Vaccination Series 1" - assert inst.recommendation[0].seriesDosesPositiveInt == 3 - assert ( - inst.recommendation[0].supportingImmunization[0].reference - == "Immunization/example" - ) - assert ( - inst.recommendation[0].supportingPatientInformation[0].reference - == "Observation/example" - ) - assert inst.recommendation[0].vaccineCode[0].coding[0].code == "14745005" - assert ( - inst.recommendation[0].vaccineCode[0].coding[0].display == "Hepatitis A vaccine" - ) - assert ( - inst.recommendation[0].vaccineCode[0].coding[0].system - == "http://snomed.info/sct" - ) - assert inst.text.div == ( - '
Authored by ' "Joginder Madra
" - ) - assert inst.text.status == "generated" - - -def test_immunizationrecommendation_1(base_settings): - """No. 1 tests collection for ImmunizationRecommendation. - Test File: immunizationrecommendation-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "immunizationrecommendation-example.json" - ) - inst = immunizationrecommendation.ImmunizationRecommendation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ImmunizationRecommendation" == inst.resource_type - - impl_immunizationrecommendation_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ImmunizationRecommendation" == data["resourceType"] - - inst2 = immunizationrecommendation.ImmunizationRecommendation(**data) - impl_immunizationrecommendation_1(inst2) - - -def impl_immunizationrecommendation_2(inst): - assert inst.authority.reference == "Organization/hl7" - assert inst.date == fhirtypes.DateTime.validate("2015-02-09T11:04:15.817-05:00") - assert inst.id == "example" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.1235" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.recommendation[0].dateCriterion[0].code.coding[0].code == "30981-5" - assert ( - inst.recommendation[0].dateCriterion[0].code.coding[0].display - == "Earliest date to give" - ) - assert ( - inst.recommendation[0].dateCriterion[0].code.coding[0].system - == "http://loinc.org" - ) - assert inst.recommendation[0].dateCriterion[0].value == fhirtypes.DateTime.validate( - "2015-12-01T00:00:00-05:00" - ) - assert inst.recommendation[0].dateCriterion[1].code.coding[0].code == "recommended" - assert ( - inst.recommendation[0].dateCriterion[1].code.coding[0].display == "Recommended" - ) - assert inst.recommendation[0].dateCriterion[1].code.coding[0].system == ( - "http://example.org/fhir/CodeSystem/immunization-" - "recommendation-date-criterion" - ) - assert inst.recommendation[0].dateCriterion[1].value == fhirtypes.DateTime.validate( - "2015-12-01T00:00:00-05:00" - ) - assert inst.recommendation[0].dateCriterion[2].code.coding[0].code == "overdue" - assert ( - inst.recommendation[0].dateCriterion[2].code.coding[0].display - == "Past Due Date" - ) - assert inst.recommendation[0].dateCriterion[2].code.coding[0].system == ( - "http://example.org/fhir/CodeSystem/immunization-" - "recommendation-date-criterion" - ) - assert inst.recommendation[0].dateCriterion[2].value == fhirtypes.DateTime.validate( - "2016-12-28T00:00:00-05:00" - ) - assert inst.recommendation[0].description == "First sequence in protocol" - assert inst.recommendation[0].doseNumberPositiveInt == 1 - assert inst.recommendation[0].forecastStatus.text == "Not Complete" - assert inst.recommendation[0].series == "Vaccination Series 1" - assert inst.recommendation[0].seriesDosesPositiveInt == 3 - assert ( - inst.recommendation[0].supportingImmunization[0].reference - == "Immunization/example" - ) - assert ( - inst.recommendation[0].supportingPatientInformation[0].reference - == "Observation/example" - ) - assert inst.recommendation[0].targetDisease.coding[0].code == "40468003" - assert ( - inst.recommendation[0].targetDisease.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.text.div == ( - '
Authored by ' "Joginder Madra
" - ) - assert inst.text.status == "generated" - - -def test_immunizationrecommendation_2(base_settings): - """No. 2 tests collection for ImmunizationRecommendation. - Test File: immunizationrecommendation-example-target-disease.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "immunizationrecommendation-example-target-disease.json" - ) - inst = immunizationrecommendation.ImmunizationRecommendation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ImmunizationRecommendation" == inst.resource_type - - impl_immunizationrecommendation_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ImmunizationRecommendation" == data["resourceType"] - - inst2 = immunizationrecommendation.ImmunizationRecommendation(**data) - impl_immunizationrecommendation_2(inst2) diff --git a/fhir/resources/tests/test_implementationguide.py b/fhir/resources/tests/test_implementationguide.py deleted file mode 100644 index 7a936a0b..00000000 --- a/fhir/resources/tests/test_implementationguide.py +++ /dev/null @@ -1,102 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ImplementationGuide -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import implementationguide - - -def impl_implementationguide_1(inst): - assert inst.contact[0].name == "ONC" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://www.healthit.gov" - assert inst.contact[1].name == "HL7" - assert inst.contact[1].telecom[0].system == "url" - assert inst.contact[1].telecom[0].value == "http://hl7.org/fhir" - assert inst.copyright == "Published by ONC under the standard FHIR license (CC0)" - assert inst.date == fhirtypes.DateTime.validate("2015-01-01T11:15:33+10:00") - assert ( - inst.definition.grouping[0].description - == "Base package (not broken up into multiple packages)" - ) - assert inst.definition.grouping[0].name == "test" - assert inst.definition.page.generation == "html" - assert inst.definition.page.nameUrl == "http://example.com/patient-example.html" - assert inst.definition.page.page[0].generation == "html" - assert inst.definition.page.page[0].nameUrl == "http://example.com/list.html" - assert inst.definition.page.page[0].title == "Value Set Page" - assert inst.definition.page.title == "Example Patient Page" - assert inst.definition.parameter[0].code == "apply" - assert inst.definition.parameter[0].value == "version" - assert ( - inst.definition.resource[0].description - == "A test example to show how an implementation guide works" - ) - assert ( - inst.definition.resource[0].exampleCanonical - == "http://hl7.org/fhir/us/core/StructureDefinition/patient" - ) - assert inst.definition.resource[0].name == "Test Example" - assert inst.definition.resource[0].reference.reference == "Patient/test" - assert inst.dependsOn[0].uri == "http://hl7.org/fhir/ImplementationGuide/uscore" - assert inst.experimental is False - assert inst.fhirVersion[0] == "4.0.1" - assert ( - inst.global_fhir[0].profile - == "http://hl7.org/fhir/us/core/StructureDefinition/patient" - ) - assert inst.global_fhir[0].type == "Patient" - assert inst.id == "example" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.license == "CC0-1.0" - assert inst.manifest.image[0] == "fhir.png" - assert inst.manifest.other[0] == "fhir.css" - assert inst.manifest.page[0].anchor[0] == "patient-test" - assert inst.manifest.page[0].anchor[1] == "tx" - assert inst.manifest.page[0].anchor[2] == "uml" - assert inst.manifest.page[0].name == "patient-test.html" - assert inst.manifest.page[0].title == "Test Patient Example" - assert inst.manifest.rendering == "http://hl7.org/fhir/us/daf" - assert ( - inst.manifest.resource[0].exampleCanonical - == "http://hl7.org/fhir/us/core/StructureDefinition/patient" - ) - assert inst.manifest.resource[0].reference.reference == "Patient/test" - assert ( - inst.manifest.resource[0].relativePath - == "https://example.com/patient-test.html#patient-test" - ) - assert inst.name == "Data Access Framework (DAF)" - assert inst.packageId == "hl7.fhir.us.daf" - assert inst.publisher == "ONC / HL7 Joint project" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/us/daf" - assert inst.version == "0" - - -def test_implementationguide_1(base_settings): - """No. 1 tests collection for ImplementationGuide. - Test File: implementationguide-example.json - """ - filename = base_settings["unittest_data_dir"] / "implementationguide-example.json" - inst = implementationguide.ImplementationGuide.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ImplementationGuide" == inst.resource_type - - impl_implementationguide_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ImplementationGuide" == data["resourceType"] - - inst2 = implementationguide.ImplementationGuide(**data) - impl_implementationguide_1(inst2) diff --git a/fhir/resources/tests/test_insuranceplan.py b/fhir/resources/tests/test_insuranceplan.py deleted file mode 100644 index 5830028e..00000000 --- a/fhir/resources/tests/test_insuranceplan.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/InsurancePlan -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import insuranceplan - - -def impl_insuranceplan_1(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "foo" - assert inst.text.div == ( - '

Generated ' - "Narrative with Details

id: " - "example

name: foo

" - ) - assert inst.text.status == "generated" - - -def test_insuranceplan_1(base_settings): - """No. 1 tests collection for InsurancePlan. - Test File: insuranceplan-example.json - """ - filename = base_settings["unittest_data_dir"] / "insuranceplan-example.json" - inst = insuranceplan.InsurancePlan.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "InsurancePlan" == inst.resource_type - - impl_insuranceplan_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "InsurancePlan" == data["resourceType"] - - inst2 = insuranceplan.InsurancePlan(**data) - impl_insuranceplan_1(inst2) diff --git a/fhir/resources/tests/test_invoice.py b/fhir/resources/tests/test_invoice.py deleted file mode 100644 index c70eeef8..00000000 --- a/fhir/resources/tests/test_invoice.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Invoice -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import invoice - - -def impl_invoice_1(inst): - assert inst.account.reference == "Account/example" - assert inst.date == fhirtypes.DateTime.validate("2017-01-25T08:00:00+01:00") - assert inst.id == "example" - assert inst.identifier[0].system == "http://myHospital.org/Invoices" - assert inst.identifier[0].value == "654321" - assert inst.issuer.identifier.system == "http://myhospital/NamingSystem/departments" - assert inst.issuer.identifier.value == "CARD_INTERMEDIATE_CARE" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.participant[0].actor.reference == "Practitioner/example" - assert inst.participant[0].role.coding[0].code == "17561000" - assert inst.participant[0].role.coding[0].display == "Cardiologist" - assert inst.participant[0].role.coding[0].system == "http://snomed.info/sct" - assert inst.status == "issued" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Example of ' "Invoice
" - ) - assert inst.text.status == "generated" - assert inst.totalGross.currency == "EUR" - assert float(inst.totalGross.value) == float(48) - assert inst.totalNet.currency == "EUR" - assert float(inst.totalNet.value) == float(40) - - -def test_invoice_1(base_settings): - """No. 1 tests collection for Invoice. - Test File: invoice-example.json - """ - filename = base_settings["unittest_data_dir"] / "invoice-example.json" - inst = invoice.Invoice.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Invoice" == inst.resource_type - - impl_invoice_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Invoice" == data["resourceType"] - - inst2 = invoice.Invoice(**data) - impl_invoice_1(inst2) diff --git a/fhir/resources/tests/test_library.py b/fhir/resources/tests/test_library.py deleted file mode 100644 index 00316f63..00000000 --- a/fhir/resources/tests/test_library.py +++ /dev/null @@ -1,895 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Library -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import library - - -def impl_library_1(inst): - assert inst.author[0].name == "Kensaku Kawamoto, MD, PhD, MHS" - assert inst.author[1].name == "Bryn Rhodes" - assert inst.author[2].name == "Floyd Eisenberg, MD, MPH" - assert inst.author[3].name == "Robert McClure, MD, MPH" - assert inst.content[0].contentType == "application/xml" - assert inst.content[0].url == "http://example.com/elm/OMTK-modelinfo-0.1.0.xml" - assert inst.copyright == "© CDC 2016+." - assert inst.date == fhirtypes.DateTime.validate("2017-05-05T11:15:33+10:00") - assert inst.description == ( - "Opioid Management Terminology Knowledge Base Model " - "Definition for use in implementing CDC Opioid Prescribing " - "Guidelines." - ) - assert inst.experimental is True - assert inst.id == "omtk-modelinfo" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "OMTKModelInfo" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "Centers for Disease Control and Prevention (CDC)" - assert inst.purpose == ( - "This library defines the Opioid Management Terminology " "Knowledge Base model" - ) - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "OMTK Model Info" - assert inst.topic[0].text == "Opioid Prescribing" - assert inst.type.coding[0].code == "model-definition" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/library-type" - ) - assert inst.usage == ( - "This library is used to resolve data elements in the Opioid " - "Management Terminology Knowledge Base model" - ) - assert inst.useContext[0].code.code == "focus" - assert inst.useContext[0].code.display == "Clinical Focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "182888003" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].display - == "Medication requested (situation)" - ) - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[1].code.code == "focus" - assert inst.useContext[1].code.display == "Clinical Focus" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "82423001" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].display - == "Chronic pain (finding)" - ) - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "0.1.0" - - -def test_library_1(base_settings): - """No. 1 tests collection for Library. - Test File: library-omtk-modelinfo.json - """ - filename = base_settings["unittest_data_dir"] / "library-omtk-modelinfo.json" - inst = library.Library.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Library" == inst.resource_type - - impl_library_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Library" == data["resourceType"] - - inst2 = library.Library(**data) - impl_library_1(inst2) - - -def impl_library_2(inst): - assert inst.content[0].contentType == "text/cql" - assert ( - inst.content[0].url == "http://example.com/library-hiv-indicators-content.cql" - ) - assert inst.date == fhirtypes.DateTime.validate("2018-08-03T11:15:33+10:00") - assert inst.description == "HIV Indicators Reporting Example" - assert inst.experimental is True - assert inst.id == "hiv-indicators" - assert inst.identifier[0].system == "http://ohie.org/Library/" - assert inst.identifier[0].value == "hiv-indicators" - assert inst.relatedArtifact[0].type == "derived-from" - assert ( - inst.relatedArtifact[0].url - == "http://wiki.ihe.net/index.php/Aggregate_Data_Exchange_-_HIV" - ) - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "HIV Indicators" - assert inst.type.coding[0].code == "logic-library" - assert inst.type.coding[0].display == "Logic Library" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/library-type" - ) - assert inst.url == "http://ohie.org/Library/hiv-indicators" - assert inst.version == "0.0.0" - - -def test_library_2(base_settings): - """No. 2 tests collection for Library. - Test File: library-hiv-indicators.json - """ - filename = base_settings["unittest_data_dir"] / "library-hiv-indicators.json" - inst = library.Library.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Library" == inst.resource_type - - impl_library_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Library" == data["resourceType"] - - inst2 = library.Library(**data) - impl_library_2(inst2) - - -def impl_library_3(inst): - assert inst.content[0].contentType == "application/xml" - assert inst.content[0].url == "http://cqlrepository.org/quick-modelinfo.xml" - assert inst.date == fhirtypes.DateTime.validate("2016-07-08T11:15:33+10:00") - assert inst.description == "Model definition for the QUICK Logical Model" - assert inst.id == "library-quick-model-definition" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "QUICK" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "QUICK Model Definition" - assert inst.topic[0].text == "QUICK" - assert inst.type.coding[0].code == "model-definition" - assert inst.version == "1.0.0" - - -def test_library_3(base_settings): - """No. 3 tests collection for Library. - Test File: library-quick-model-definition.json - """ - filename = ( - base_settings["unittest_data_dir"] / "library-quick-model-definition.json" - ) - inst = library.Library.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Library" == inst.resource_type - - impl_library_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Library" == data["resourceType"] - - inst2 = library.Library(**data) - impl_library_3(inst2) - - -def impl_library_4(inst): - assert inst.author[0].name == "Kensaku Kawamoto, MD, PhD, MHS" - assert inst.author[1].name == "Bryn Rhodes" - assert inst.author[2].name == "Floyd Eisenberg, MD, MPH" - assert inst.author[3].name == "Robert McClure, MD, MPH" - assert inst.content[0].contentType == "application/elm+xml" - assert inst.copyright == "© CDC 2016+." - assert inst.dataRequirement[0].codeFilter[0].path == "medicationCodeableConcept" - assert ( - inst.dataRequirement[0].codeFilter[0].valueSet - == "http://example.org/fhir/ValueSet/benzodiazepines" - ) - assert inst.dataRequirement[0].type == "MedicationRequest" - assert inst.dataRequirement[1].codeFilter[0].path == "medicationCodeableConcept" - assert inst.dataRequirement[1].codeFilter[0].valueSet == ( - "http://example.org/fhir/ValueSet/opioids-abused-in-" "ambulatory-care" - ) - assert inst.dataRequirement[1].type == "MedicationRequest" - assert inst.date == fhirtypes.DateTime.validate("2018-03-25T13:49:09-06:00") - assert inst.description == ( - "Opioid decision support logic to avoid prescribing opioid " - "pain medication and benzodiazepines concurrently whenever " - "possible." - ) - assert inst.experimental is False - assert inst.id == "opioidcds-recommendation-11" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "OpioidCDS_REC_11" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "Centers for Disease Control and Prevention (CDC)" - assert inst.purpose == ( - "The purpose of this library is to determine whether opioid " - "pain medication and benzodiazepines have been prescribed " - "concurrently." - ) - assert ( - inst.relatedArtifact[0].display - == "CDC guideline for prescribing opioids for chronic pain" - ) - assert inst.relatedArtifact[0].type == "documentation" - assert inst.relatedArtifact[0].url == ( - "https://guidelines.gov/summaries/summary/50153/cdc-" - "guideline-for-prescribing-opioids-for-chronic-pain---united-" - "states-2016#420" - ) - assert inst.relatedArtifact[1].resource == "Library/opioidcds-common" - assert inst.relatedArtifact[1].type == "depends-on" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Opioid CDS Logic for recommendation #11" - assert inst.topic[0].text == "Opioid Prescribing" - assert inst.type.coding[0].code == "logic-library" - assert inst.type.coding[0].display == "Logic Library" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/library-type" - ) - assert inst.usage == ( - "This library is used to notify the prescriber/user to avoid " - "prescribing opioid pain medication and benzodiazepines " - "concurrently." - ) - assert inst.useContext[0].code.code == "focus" - assert inst.useContext[0].code.display == "Clinical Focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "182888003" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].display - == "Medication requested (situation)" - ) - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[1].code.code == "focus" - assert inst.useContext[1].code.display == "Clinical Focus" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "82423001" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].display - == "Chronic pain (finding)" - ) - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "0.1.0" - - -def test_library_4(base_settings): - """No. 4 tests collection for Library. - Test File: library-opioidcds-recommendation-11.json - """ - filename = ( - base_settings["unittest_data_dir"] / "library-opioidcds-recommendation-11.json" - ) - inst = library.Library.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Library" == inst.resource_type - - impl_library_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Library" == data["resourceType"] - - inst2 = library.Library(**data) - impl_library_4(inst2) - - -def impl_library_5(inst): - assert inst.author[0].name == "Kensaku Kawamoto, MD, PhD, MHS" - assert inst.author[1].name == "Bryn Rhodes" - assert inst.author[2].name == "Floyd Eisenberg, MD, MPH" - assert inst.author[3].name == "Robert McClure, MD, MPH" - assert inst.content[0].contentType == "application/elm+xml" - assert inst.copyright == "© CDC 2016+." - assert inst.dataRequirement[0].codeFilter[0].path == "medicationCodeableConcept" - assert inst.dataRequirement[0].codeFilter[0].valueSet == ( - "http://example.org/fhir/ValueSet/opioids-indicating-end-of-" "life" - ) - assert inst.dataRequirement[0].type == "MedicationRequest" - assert inst.dataRequirement[1].codeFilter[0].path == "code" - assert inst.dataRequirement[1].type == "Procedure" - assert inst.dataRequirement[2].codeFilter[0].path == "code" - assert inst.dataRequirement[2].type == "Procedure" - assert inst.dataRequirement[3].codeFilter[0].path == "medicationCodeableConcept" - assert inst.dataRequirement[3].codeFilter[0].valueSet == ( - "http://example.org/fhir/ValueSet/opioids-abused-in-" "ambulatory-care" - ) - assert inst.dataRequirement[3].type == "MedicationRequest" - assert inst.dataRequirement[4].type == "Encounter" - assert inst.date == fhirtypes.DateTime.validate("2018-03-25T13:49:09-06:00") - assert inst.experimental is False - assert inst.id == "opioidcds-recommendation-07" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "OpioidCDS_REC_07" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "Centers for Disease Control and Prevention (CDC)" - assert inst.purpose == ( - "The purpose of this library is to determine whether the " - "patient has been evaluated for benefits and harms within 1 " - "to 4 weeks of starting opioid therapy and every 3 months or " - "more subsequently." - ) - assert ( - inst.relatedArtifact[0].display - == "CDC guideline for prescribing opioids for chronic pain" - ) - assert inst.relatedArtifact[0].type == "documentation" - assert inst.relatedArtifact[0].url == ( - "https://guidelines.gov/summaries/summary/50153/cdc-" - "guideline-for-prescribing-opioids-for-chronic-pain---united-" - "states-2016#420" - ) - assert inst.relatedArtifact[1].resource == "Library/opioidcds-common" - assert inst.relatedArtifact[1].type == "depends-on" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Opioid CDS Logic for recommendation #7" - assert inst.topic[0].text == "Opioid Prescribing" - assert inst.type.coding[0].code == "logic-library" - assert inst.type.coding[0].display == "Logic Library" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/library-type" - ) - assert inst.usage == ( - "This library is used to notify the prescriber/user whether " - "an evaluation for benefits and harms associated with opioid " - "therapy is recommended for the patient." - ) - assert inst.useContext[0].code.code == "focus" - assert inst.useContext[0].code.display == "Clinical Focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "182888003" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].display - == "Medication requested (situation)" - ) - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[1].code.code == "focus" - assert inst.useContext[1].code.display == "Clinical Focus" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "82423001" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].display - == "Chronic pain (finding)" - ) - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "0.1.0" - - -def test_library_5(base_settings): - """No. 5 tests collection for Library. - Test File: library-opioidcds-recommendation-07.json - """ - filename = ( - base_settings["unittest_data_dir"] / "library-opioidcds-recommendation-07.json" - ) - inst = library.Library.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Library" == inst.resource_type - - impl_library_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Library" == data["resourceType"] - - inst2 = library.Library(**data) - impl_library_5(inst2) - - -def impl_library_6(inst): - assert inst.content[0].contentType == "application/xml" - assert inst.content[0].url == "http://cqlrepository.org/fhirmodel-modelinfo.xml" - assert inst.date == fhirtypes.DateTime.validate("2016-07-08T11:15:33+10:00") - assert inst.description == "Model definition for the FHIR Model" - assert inst.id == "library-fhir-model-definition" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "FHIR" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "FHIR Model Definition" - assert inst.topic[0].text == "FHIR" - assert inst.type.coding[0].code == "model-definition" - assert inst.version == "4.0.1" - - -def test_library_6(base_settings): - """No. 6 tests collection for Library. - Test File: library-fhir-model-definition.json - """ - filename = base_settings["unittest_data_dir"] / "library-fhir-model-definition.json" - inst = library.Library.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Library" == inst.resource_type - - impl_library_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Library" == data["resourceType"] - - inst2 = library.Library(**data) - impl_library_6(inst2) - - -def impl_library_7(inst): - assert inst.content[0].contentType == "text/cql" - assert inst.content[0].title == "FHIR Helpers" - assert inst.content[0].url == "https://example.com/library-fhir-helpers-content.cql" - assert inst.date == fhirtypes.DateTime.validate("2016-11-14T11:15:33+10:00") - assert inst.description == "FHIR Helpers" - assert inst.experimental is True - assert inst.id == "library-fhir-helpers-predecessor" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "FHIRHelpers" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.relatedArtifact[0].resource == "Library/fhir-model-definition" - assert inst.relatedArtifact[0].type == "depends-on" - assert inst.relatedArtifact[1].resource == "Library/library-fhir-helpers" - assert inst.relatedArtifact[1].type == "successor" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "FHIR Helpers" - assert inst.topic[0].text == "FHIR Helpers" - assert inst.type.coding[0].code == "logic-library" - assert inst.version == "1.6" - - -def test_library_7(base_settings): - """No. 7 tests collection for Library. - Test File: library-predecessor-example.json - """ - filename = base_settings["unittest_data_dir"] / "library-predecessor-example.json" - inst = library.Library.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Library" == inst.resource_type - - impl_library_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Library" == data["resourceType"] - - inst2 = library.Library(**data) - impl_library_7(inst2) - - -def impl_library_8(inst): - assert inst.author[0].name == "Kensaku Kawamoto, MD, PhD, MHS" - assert inst.author[1].name == "Bryn Rhodes" - assert inst.author[2].name == "Floyd Eisenberg, MD, MPH" - assert inst.author[3].name == "Robert McClure, MD, MPH" - assert inst.content[0].contentType == "application/elm+xml" - assert inst.copyright == "© CDC 2016+." - assert inst.dataRequirement[0].codeFilter[0].path == "medicationCodeableConcept" - assert inst.dataRequirement[0].codeFilter[0].valueSet == ( - "http://example.org/fhir/ValueSet/opioids-indicating-end-of-" "life" - ) - assert inst.dataRequirement[0].type == "MedicationRequest" - assert inst.dataRequirement[1].codeFilter[0].path == "medicationCodeableConcept" - assert inst.dataRequirement[1].codeFilter[0].valueSet == ( - "http://example.org/fhir/ValueSet/opioids-abused-in-" "ambulatory-care" - ) - assert inst.dataRequirement[1].type == "MedicationRequest" - assert inst.dataRequirement[2].codeFilter[0].path == "combo-code" - assert inst.dataRequirement[2].codeFilter[0].valueSet == ( - "http://example.org/fhir/ValueSet/illicit-drug-urine-" "screening" - ) - assert inst.dataRequirement[2].type == "Observation" - assert inst.dataRequirement[3].codeFilter[0].path == "combo-code" - assert ( - inst.dataRequirement[3].codeFilter[0].valueSet - == "http://example.org/fhir/ValueSet/opioid-urine-screening" - ) - assert inst.dataRequirement[3].type == "Observation" - assert inst.date == fhirtypes.DateTime.validate("2018-03-25T13:49:09-06:00") - assert inst.description == ( - "Opioid decision support logic to evaluate whether the " - "patient has had a urine screening in the past 12 months and " - "provide analysis." - ) - assert inst.experimental is False - assert inst.id == "opioidcds-recommendation-10" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "OpioidCDS_REC_10" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "Centers for Disease Control and Prevention (CDC)" - assert ( - inst.relatedArtifact[0].display - == "CDC guideline for prescribing opioids for chronic pain" - ) - assert inst.relatedArtifact[0].type == "documentation" - assert inst.relatedArtifact[0].url == ( - "https://guidelines.gov/summaries/summary/50153/cdc-" - "guideline-for-prescribing-opioids-for-chronic-pain---united-" - "states-2016#420" - ) - assert inst.relatedArtifact[1].resource == "Library/opioidcds-common" - assert inst.relatedArtifact[1].type == "depends-on" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Opioid CDS Logic for recommendation #10" - assert inst.topic[0].text == "Opioid Prescribing" - assert inst.type.coding[0].code == "logic-library" - assert inst.type.coding[0].display == "Logic Library" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/library-type" - ) - assert inst.usage == ( - "This library is used to notify the prescriber/user whether " - "the patient has had a urine screening in the past 12 months " - "and to provide analysis if true." - ) - assert inst.useContext[0].code.code == "focus" - assert inst.useContext[0].code.display == "Clinical Focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "182888003" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].display - == "Medication requested (situation)" - ) - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[1].code.code == "focus" - assert inst.useContext[1].code.display == "Clinical Focus" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "82423001" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].display - == "Chronic pain (finding)" - ) - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "0.1.0" - - -def test_library_8(base_settings): - """No. 8 tests collection for Library. - Test File: library-opioidcds-recommendation-10.json - """ - filename = ( - base_settings["unittest_data_dir"] / "library-opioidcds-recommendation-10.json" - ) - inst = library.Library.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Library" == inst.resource_type - - impl_library_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Library" == data["resourceType"] - - inst2 = library.Library(**data) - impl_library_8(inst2) - - -def impl_library_9(inst): - assert inst.content[0].contentType == "text/cql" - assert ( - inst.content[0].url == "http://example.com/library-cms146-example-content.cql" - ) - assert inst.dataRequirement[0].type == "Patient" - assert inst.dataRequirement[1].codeFilter[0].code[0].code == "diagnosis" - assert inst.dataRequirement[1].codeFilter[0].path == "category" - assert inst.dataRequirement[1].codeFilter[1].code[0].code == "confirmed" - assert inst.dataRequirement[1].codeFilter[1].path == "clinicalStatus" - assert inst.dataRequirement[1].codeFilter[2].path == "code" - assert ( - inst.dataRequirement[1].codeFilter[2].valueSet - == "urn:oid:2.16.840.1.113883.3.464.1003.102.12.1011" - ) - assert inst.dataRequirement[1].type == "Condition" - assert inst.dataRequirement[2].codeFilter[0].code[0].code == "diagnosis" - assert inst.dataRequirement[2].codeFilter[0].path == "category" - assert inst.dataRequirement[2].codeFilter[1].code[0].code == "confirmed" - assert inst.dataRequirement[2].codeFilter[1].path == "clinicalStatus" - assert inst.dataRequirement[2].codeFilter[2].path == "code" - assert ( - inst.dataRequirement[2].codeFilter[2].valueSet - == "urn:oid:2.16.840.1.113883.3.464.1003.102.12.1012" - ) - assert inst.dataRequirement[2].type == "Condition" - assert inst.dataRequirement[3].codeFilter[0].code[0].code == "finished" - assert inst.dataRequirement[3].codeFilter[0].path == "status" - assert inst.dataRequirement[3].codeFilter[1].code[0].code == "ambulatory" - assert inst.dataRequirement[3].codeFilter[1].path == "class" - assert inst.dataRequirement[3].codeFilter[2].path == "type" - assert ( - inst.dataRequirement[3].codeFilter[2].valueSet - == "urn:oid:2.16.840.1.113883.3.464.1003.101.12.1061" - ) - assert inst.dataRequirement[3].type == "Encounter" - assert inst.dataRequirement[4].codeFilter[0].path == "diagnosis" - assert ( - inst.dataRequirement[4].codeFilter[0].valueSet - == "urn:oid:2.16.840.1.113883.3.464.1003.198.12.1012" - ) - assert inst.dataRequirement[4].type == "DiagnosticReport" - assert inst.dataRequirement[5].codeFilter[0].path == "code" - assert ( - inst.dataRequirement[5].codeFilter[0].valueSet - == "urn:oid:2.16.840.1.113883.3.464.1003.196.12.1001" - ) - assert inst.dataRequirement[5].type == "Medication" - assert inst.dataRequirement[6].codeFilter[0].code[0].code == "active" - assert inst.dataRequirement[6].codeFilter[0].path == "status" - assert inst.dataRequirement[6].codeFilter[1].path == "medication.code" - assert ( - inst.dataRequirement[6].codeFilter[1].valueSet - == "urn:oid:2.16.840.1.113883.3.464.1003.196.12.1001" - ) - assert inst.dataRequirement[6].type == "MedicationRequest" - assert inst.dataRequirement[7].codeFilter[0].code[0].code == "completed" - assert inst.dataRequirement[7].codeFilter[0].path == "status" - assert inst.dataRequirement[7].codeFilter[1].path == "medication.code" - assert ( - inst.dataRequirement[7].codeFilter[1].valueSet - == "urn:oid:2.16.840.1.113883.3.464.1003.196.12.1001" - ) - assert inst.dataRequirement[7].type == "MedicationStatement" - assert inst.date == fhirtypes.DateTime.validate("2015-07-22T11:15:33+10:00") - assert inst.description == ( - "Logic for CMS 146: Appropriate Testing for Children with " "Pharyngitis" - ) - assert inst.id == "library-cms146-example" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "CMS146" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.relatedArtifact[0].resource == "Library/library-quick-model-definition" - assert inst.relatedArtifact[0].type == "depends-on" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "Appropriate Testing for Children with Pharyngitis" - assert inst.type.coding[0].code == "logic-library" - assert inst.version == "2.0.0" - - -def test_library_9(base_settings): - """No. 9 tests collection for Library. - Test File: library-cms146-example.json - """ - filename = base_settings["unittest_data_dir"] / "library-cms146-example.json" - inst = library.Library.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Library" == inst.resource_type - - impl_library_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Library" == data["resourceType"] - - inst2 = library.Library(**data) - impl_library_9(inst2) - - -def impl_library_10(inst): - assert inst.author[0].name == "Kensaku Kawamoto, MD, PhD, MHS" - assert inst.author[1].name == "Bryn Rhodes" - assert inst.author[2].name == "Floyd Eisenberg, MD, MPH" - assert inst.author[3].name == "Robert McClure, MD, MPH" - assert inst.content[0].contentType == "application/elm+xml" - assert inst.copyright == "© CDC 2016+." - assert inst.dataRequirement[0].codeFilter[0].code[0].code == "active" - assert inst.dataRequirement[0].codeFilter[0].path == "status" - assert inst.dataRequirement[0].codeFilter[1].code[0].code == "outpatient" - assert inst.dataRequirement[0].codeFilter[1].code[0].system == ( - "http://terminology.hl7.org/CodeSystem/medicationrequest-" "category" - ) - assert inst.dataRequirement[0].codeFilter[1].path == "category" - assert inst.dataRequirement[0].id == "medications" - assert inst.dataRequirement[0].type == "MedicationRequest" - assert inst.date == fhirtypes.DateTime.validate("2018-03-25T13:49:09-06:00") - assert inst.description == ( - "Opioid Decision Support Logic for use in implementing CDC " - "Opioid Prescribing Guidelines." - ) - assert inst.experimental is False - assert inst.id == "opioidcds-recommendation-05" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "OpioidCDS_REC_05" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "Centers for Disease Control and Prevention (CDC)" - assert inst.purpose == ( - "This library works in concert with the OMTK logic library to" - " provide decision support for Morphine Milligram Equivalence" - " calculations and dynamic value resolution." - ) - assert ( - inst.relatedArtifact[0].display - == "CDC guideline for prescribing opioids for chronic pain" - ) - assert inst.relatedArtifact[0].type == "documentation" - assert inst.relatedArtifact[0].url == ( - "https://guidelines.gov/summaries/summary/50153/cdc-" - "guideline-for-prescribing-opioids-for-chronic-pain---united-" - "states-2016#420" - ) - assert inst.relatedArtifact[1].resource == "Library/opioidcds-common" - assert inst.relatedArtifact[1].type == "depends-on" - assert inst.relatedArtifact[2].display == "MME Conversion Tables" - assert inst.relatedArtifact[2].type == "documentation" - assert inst.relatedArtifact[2].url == ( - "https://www.cdc.gov/drugoverdose/pdf/calculating_total_daily" "_dose-a.pdf" - ) - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Opioid CDS Logic for recommendation #5" - assert inst.topic[0].text == "Opioid Prescribing" - assert inst.type.coding[0].code == "logic-library" - assert inst.type.coding[0].display == "Logic Library" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/library-type" - ) - assert inst.usage == ( - "This library is to notify the prescriber/user whether the " - "current prescription exceeds the recommended MME." - ) - assert inst.useContext[0].code.code == "focus" - assert inst.useContext[0].code.display == "Clinical Focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "182888003" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].display - == "Medication requested (situation)" - ) - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[1].code.code == "focus" - assert inst.useContext[1].code.display == "Clinical Focus" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "82423001" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].display - == "Chronic pain (finding)" - ) - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "0.1.0" - - -def test_library_10(base_settings): - """No. 10 tests collection for Library. - Test File: library-opioidcds-recommendation-05.json - """ - filename = ( - base_settings["unittest_data_dir"] / "library-opioidcds-recommendation-05.json" - ) - inst = library.Library.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Library" == inst.resource_type - - impl_library_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Library" == data["resourceType"] - - inst2 = library.Library(**data) - impl_library_10(inst2) diff --git a/fhir/resources/tests/test_linkage.py b/fhir/resources/tests/test_linkage.py deleted file mode 100644 index 1f0b0475..00000000 --- a/fhir/resources/tests/test_linkage.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Linkage -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import linkage - - -def impl_linkage_1(inst): - assert inst.author.reference == "Practitioner/f201" - assert inst.id == "example" - assert ( - inst.item[0].resource.display == "Severe burn of left ear (Date: 24-May 2012)" - ) - assert inst.item[0].resource.reference == "Condition/example" - assert inst.item[0].type == "source" - assert ( - inst.item[1].resource.display == "Severe burn of left ear (Date: 24-May 2012)" - ) - assert inst.item[1].resource.reference == "Condition/condition-example" - assert inst.item[1].type == "alternate" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_linkage_1(base_settings): - """No. 1 tests collection for Linkage. - Test File: linkage-example.json - """ - filename = base_settings["unittest_data_dir"] / "linkage-example.json" - inst = linkage.Linkage.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Linkage" == inst.resource_type - - impl_linkage_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Linkage" == data["resourceType"] - - inst2 = linkage.Linkage(**data) - impl_linkage_1(inst2) diff --git a/fhir/resources/tests/test_list.py b/fhir/resources/tests/test_list.py deleted file mode 100644 index 4b9573fe..00000000 --- a/fhir/resources/tests/test_list.py +++ /dev/null @@ -1,501 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/List -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import list - - -def impl_list_1(inst): - assert inst.code.coding[0].code == "182836005" - assert inst.code.coding[0].display == "Review of medication" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Medication Review" - assert inst.date == fhirtypes.DateTime.validate("2013-11-20T23:10:23+11:00") - assert inst.entry[0].flag.coding[0].code == "01" - assert inst.entry[0].flag.coding[0].display == "Prescribed" - assert ( - inst.entry[0].flag.coding[0].system - == "http://nehta.gov.au/codes/medications/changetype" - ) - assert inst.entry[0].item.display == "hydroxocobalamin" - assert inst.entry[1].deleted is True - assert inst.entry[1].flag.coding[0].code == "02" - assert inst.entry[1].flag.coding[0].display == "Cancelled" - assert ( - inst.entry[1].flag.coding[0].system - == "http://nehta.gov.au/codes/medications/changetype" - ) - assert inst.entry[1].item.display == "Morphine Sulfate" - assert inst.id == "med-list" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "changes" - assert inst.source.reference == "Patient/example" - assert inst.status == "current" - assert inst.text.status == "generated" - - -def test_list_1(base_settings): - """No. 1 tests collection for List. - Test File: list-example-medlist.json - """ - filename = base_settings["unittest_data_dir"] / "list-example-medlist.json" - inst = list.List.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "List" == inst.resource_type - - impl_list_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "List" == data["resourceType"] - - inst2 = list.List(**data) - impl_list_1(inst2) - - -def impl_list_2(inst): - assert inst.code.coding[0].code == "8670-2" - assert inst.code.coding[0].display == "History of family member diseases" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.contained[0].id == "image" - assert inst.contained[1].id == "1" - assert inst.contained[2].id == "2" - assert inst.contained[3].id == "3" - assert inst.contained[4].id == "4" - assert inst.contained[5].id == "5" - assert inst.contained[6].id == "6" - assert inst.contained[7].id == "7" - assert inst.contained[8].id == "8" - assert inst.contained[9].id == "9" - assert inst.entry[0].item.reference == "#image" - assert inst.entry[1].item.reference == "#2" - assert inst.entry[2].item.reference == "#3" - assert inst.entry[3].item.reference == "#4" - assert inst.entry[4].item.reference == "#5" - assert inst.entry[5].item.reference == "#6" - assert inst.entry[6].item.reference == "#7" - assert inst.entry[7].item.reference == "#8" - assert inst.entry[8].item.reference == "#9" - assert inst.entry[9].item.reference == "#10" - assert inst.id == "prognosis" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "snapshot" - assert inst.status == "current" - assert inst.subject.display == "Annie Proband, female, born 1966" - assert inst.subject.reference == "Patient/proband" - assert inst.text.status == "generated" - - -def test_list_2(base_settings): - """No. 2 tests collection for List. - Test File: list-example-familyhistory-genetics-profile-annie.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "list-example-familyhistory-genetics-profile-annie.json" - ) - inst = list.List.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "List" == inst.resource_type - - impl_list_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "List" == data["resourceType"] - - inst2 = list.List(**data) - impl_list_2(inst2) - - -def impl_list_3(inst): - assert inst.code.coding[0].code == "346638" - assert inst.code.coding[0].display == "Patient Admission List" - assert inst.code.coding[0].system == "http://acme.com/list-codes" - assert inst.date == fhirtypes.DateTime.validate("2016-07-14T11:54:05+10:00") - assert inst.id == "example-simple-empty" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "snapshot" - assert inst.status == "current" - assert inst.text.status == "generated" - - -def test_list_3(base_settings): - """No. 3 tests collection for List. - Test File: list-example-simple-empty.json - """ - filename = base_settings["unittest_data_dir"] / "list-example-simple-empty.json" - inst = list.List.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "List" == inst.resource_type - - impl_list_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "List" == data["resourceType"] - - inst2 = list.List(**data) - impl_list_3(inst2) - - -def impl_list_4(inst): - assert inst.code.coding[0].code == "182836005" - assert inst.code.coding[0].display == "Review of medication" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Medication Review" - assert inst.date == fhirtypes.DateTime.validate("2012-11-26T07:30:23+11:00") - assert inst.emptyReason.coding[0].code == "nilknown" - assert inst.emptyReason.coding[0].display == "Nil Known" - assert ( - inst.emptyReason.coding[0].system - == "http://terminology.hl7.org/CodeSystem/list-empty-reason" - ) - assert inst.emptyReason.text == "The patient is not on any medications" - assert inst.id == "example-empty" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "snapshot" - assert inst.source.reference == "Patient/example" - assert inst.status == "current" - assert inst.text.status == "generated" - - -def test_list_4(base_settings): - """No. 4 tests collection for List. - Test File: list-example-empty.json - """ - filename = base_settings["unittest_data_dir"] / "list-example-empty.json" - inst = list.List.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "List" == inst.resource_type - - impl_list_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "List" == data["resourceType"] - - inst2 = list.List(**data) - impl_list_4(inst2) - - -def impl_list_5(inst): - assert inst.code.coding[0].code == "8670-2" - assert inst.code.coding[0].display == "History of family member diseases" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.contained[0].id == "1" - assert inst.contained[1].id == "2" - assert inst.contained[2].id == "3" - assert inst.contained[3].id == "4" - assert inst.contained[4].id == "5" - assert inst.contained[5].id == "6" - assert inst.contained[6].id == "7" - assert inst.contained[7].id == "8" - assert inst.entry[0].item.reference == "#1" - assert inst.entry[1].item.reference == "#2" - assert inst.entry[2].item.reference == "#3" - assert inst.entry[3].item.reference == "#4" - assert inst.entry[4].item.reference == "#5" - assert inst.entry[5].item.reference == "#6" - assert inst.entry[6].item.reference == "#7" - assert inst.entry[7].item.reference == "#8" - assert inst.entry[8].item.display == "Family history of cancer of colon" - assert inst.entry[8].item.reference == "Condition/family-history" - assert inst.id == "genetic" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "snapshot" - assert inst.status == "current" - assert inst.subject.display == "Peter Patient" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_list_5(base_settings): - """No. 5 tests collection for List. - Test File: list-example-familyhistory-genetics-profile.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "list-example-familyhistory-genetics-profile.json" - ) - inst = list.List.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "List" == inst.resource_type - - impl_list_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "List" == data["resourceType"] - - inst2 = list.List(**data) - impl_list_5(inst2) - - -def impl_list_6(inst): - assert inst.code.coding[0].code == "8670-2" - assert inst.code.coding[0].display == "History of family member diseases" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.contained[0].id == "fmh-1" - assert inst.contained[1].id == "fmh-2" - assert inst.entry[0].item.reference == "#fmh-1" - assert inst.entry[1].item.reference == "#fmh-2" - assert inst.id == "f201" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "snapshot" - assert inst.note[0].text == ( - "Both parents, both brothers and both children (twin) are " "still alive." - ) - assert inst.status == "current" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - - -def test_list_6(base_settings): - """No. 6 tests collection for List. - Test File: list-example-familyhistory-f201-roel.json - """ - filename = ( - base_settings["unittest_data_dir"] / "list-example-familyhistory-f201-roel.json" - ) - inst = list.List.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "List" == inst.resource_type - - impl_list_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "List" == data["resourceType"] - - inst2 = list.List(**data) - impl_list_6(inst2) - - -def impl_list_7(inst): - assert inst.date == fhirtypes.DateTime.validate("2012-11-25T22:17:00+11:00") - assert inst.encounter.reference == "Encounter/example" - assert inst.entry[0].deleted is True - assert inst.entry[0].flag.text == "Deleted due to error" - assert inst.entry[0].item.reference == "Condition/example" - assert inst.entry[1].flag.text == "Added" - assert inst.entry[1].item.reference == "Condition/example2" - assert inst.id == "example" - assert inst.identifier[0].system == "urn:uuid:a9fcea7c-fcdf-4d17-a5e0-f26dda030b59" - assert inst.identifier[0].value == "23974652" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "changes" - assert inst.source.reference == "Patient/example" - assert inst.status == "current" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_list_7(base_settings): - """No. 7 tests collection for List. - Test File: list-example.json - """ - filename = base_settings["unittest_data_dir"] / "list-example.json" - inst = list.List.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "List" == inst.resource_type - - impl_list_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "List" == data["resourceType"] - - inst2 = list.List(**data) - impl_list_7(inst2) - - -def impl_list_8(inst): - assert inst.code.coding[0].code == "52472-8" - assert inst.code.coding[0].display == "Allergies and Adverse Drug Reactions" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.code.text == "Current Allergy List" - assert inst.date == fhirtypes.DateTime.validate("2015-07-14T23:10:23+11:00") - assert inst.entry[0].item.reference == "AllergyIntolerance/example" - assert inst.entry[1].item.reference == "AllergyIntolerance/medication" - assert inst.id == "current-allergies" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "working" - assert inst.orderedBy.coding[0].code == "entry-date" - assert ( - inst.orderedBy.coding[0].system - == "http://terminology.hl7.org/CodeSystem/list-order" - ) - assert inst.source.reference == "Patient/example" - assert inst.status == "current" - assert inst.text.status == "generated" - assert inst.title == "Current Allergy List" - - -def test_list_8(base_settings): - """No. 8 tests collection for List. - Test File: list-example-allergies.json - """ - filename = base_settings["unittest_data_dir"] / "list-example-allergies.json" - inst = list.List.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "List" == inst.resource_type - - impl_list_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "List" == data["resourceType"] - - inst2 = list.List(**data) - impl_list_8(inst2) - - -def impl_list_9(inst): - assert inst.code.coding[0].code == "80738-8" - assert inst.code.coding[0].display == ( - "TPMT gene mutations found [Identifier] in Blood or Tissue by" - " Sequencing Nominal" - ) - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.code.text == ( - "TPMT gene mutations found [Identifier] in Blood or Tissue by" - " Sequencing Nominal" - ) - assert inst.contained[0].id == "1" - assert inst.contained[1].id == "2" - assert inst.contained[2].id == "3" - assert inst.contained[3].id == "4" - assert inst.contained[4].id == "5" - assert inst.contained[5].id == "6" - assert inst.entry[0].item.reference == "#1" - assert inst.entry[1].item.reference == "#2" - assert inst.entry[2].item.reference == "#3" - assert inst.entry[3].item.reference == "#4" - assert inst.entry[4].item.reference == "#5" - assert inst.entry[5].item.reference == "#6" - assert inst.id == "example-double-cousin-relationship" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "snapshot" - assert inst.status == "current" - assert inst.subject.display == "Pam Taylor" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_list_9(base_settings): - """No. 9 tests collection for List. - Test File: list-example-double-cousin-relationship-pedigree.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "list-example-double-cousin-relationship-pedigree.json" - ) - inst = list.List.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "List" == inst.resource_type - - impl_list_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "List" == data["resourceType"] - - inst2 = list.List(**data) - impl_list_9(inst2) - - -def impl_list_10(inst): - assert inst.date == fhirtypes.DateTime.validate("2018-02-21T12:17:00+11:00") - assert inst.entry[0].item.reference == "Patient/example" - assert inst.entry[1].item.reference == "Patient/pat1" - assert inst.entry[2].item.reference == "Patient/pat2" - assert inst.entry[3].item.reference == "Patient/pat3" - assert inst.entry[4].item.reference == "Patient/pat4" - assert inst.entry[5].item.reference == "Patient/1" - assert inst.entry[6].item.reference == "Patient/2" - assert inst.entry[7].item.reference == "Patient/3" - assert inst.entry[8].item.reference == "Patient/4" - assert inst.entry[9].item.reference == "Patient/5" - assert inst.id == "long" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "changes" - assert inst.status == "current" - assert inst.text.status == "generated" - - -def test_list_10(base_settings): - """No. 10 tests collection for List. - Test File: list-example-long.json - """ - filename = base_settings["unittest_data_dir"] / "list-example-long.json" - inst = list.List.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "List" == inst.resource_type - - impl_list_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "List" == data["resourceType"] - - inst2 = list.List(**data) - impl_list_10(inst2) diff --git a/fhir/resources/tests/test_location.py b/fhir/resources/tests/test_location.py deleted file mode 100644 index dcf017ce..00000000 --- a/fhir/resources/tests/test_location.py +++ /dev/null @@ -1,365 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Location -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import location - - -def impl_location_1(inst): - assert inst.address.city == "Den Burg" - assert inst.address.country == "NLD" - assert inst.address.line[0] == "Galapagosweg 91, Building A" - assert inst.address.postalCode == "9105 PZ" - assert inst.address.use == "work" - assert inst.alias[0] == "BU MC, SW, F2" - assert ( - inst.alias[1] == "Burgers University Medical Center, South Wing, second floor" - ) - assert inst.description == ( - "Second floor of the Old South Wing, formerly in use by " "Psychiatry" - ) - assert inst.endpoint[0].reference == "Endpoint/example" - assert inst.id == "1" - assert inst.identifier[0].value == "B1-S.F2" - assert inst.managingOrganization.reference == "Organization/f001" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "instance" - assert inst.name == "South Wing, second floor" - assert inst.physicalType.coding[0].code == "wi" - assert inst.physicalType.coding[0].display == "Wing" - assert ( - inst.physicalType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/location-physical-type" - ) - assert float(inst.position.altitude) == float(0) - assert float(inst.position.latitude) == float(42.25475478) - assert float(inst.position.longitude) == float(-83.6945691) - assert inst.status == "active" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "2328" - assert inst.telecom[1].system == "fax" - assert inst.telecom[1].use == "work" - assert inst.telecom[1].value == "2329" - assert inst.telecom[2].system == "email" - assert inst.telecom[2].value == "second wing admissions" - assert inst.telecom[3].system == "url" - assert inst.telecom[3].use == "work" - assert inst.telecom[3].value == "http://sampleorg.com/southwing" - assert inst.text.div == ( - '
Burgers UMC, ' - "South Wing, second floor
" - ) - assert inst.text.status == "generated" - - -def test_location_1(base_settings): - """No. 1 tests collection for Location. - Test File: location-example.json - """ - filename = base_settings["unittest_data_dir"] / "location-example.json" - inst = location.Location.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Location" == inst.resource_type - - impl_location_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Location" == data["resourceType"] - - inst2 = location.Location(**data) - impl_location_1(inst2) - - -def impl_location_2(inst): - assert inst.alias[0] == "South Wing OR 5" - assert inst.alias[1] == "Main Wing OR 2" - assert inst.description == ( - "Old South Wing, Neuro Radiology Operation Room 1 on second " "floor" - ) - assert inst.id == "2" - assert inst.identifier[0].value == "B1-S.F2.1.00" - assert inst.managingOrganization.reference == "Organization/f001" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "instance" - assert inst.name == "South Wing Neuro OR 1" - assert inst.operationalStatus.code == "H" - assert inst.operationalStatus.display == "Housekeeping" - assert ( - inst.operationalStatus.system == "http://terminology.hl7.org/CodeSystem/v2-0116" - ) - assert inst.partOf.reference == "Location/1" - assert inst.physicalType.coding[0].code == "ro" - assert inst.physicalType.coding[0].display == "Room" - assert ( - inst.physicalType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/location-physical-type" - ) - assert inst.status == "suspended" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].value == "2329" - assert inst.text.div == ( - '
Burgers UMC, ' - "South Wing, second floor, Neuro Radiology Operation Room " - "1
" - ) - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "RNEU" - assert inst.type[0].coding[0].display == "Neuroradiology unit" - assert ( - inst.type[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - - -def test_location_2(base_settings): - """No. 2 tests collection for Location. - Test File: location-example-room.json - """ - filename = base_settings["unittest_data_dir"] / "location-example-room.json" - inst = location.Location.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Location" == inst.resource_type - - impl_location_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Location" == data["resourceType"] - - inst2 = location.Location(**data) - impl_location_2(inst2) - - -def impl_location_3(inst): - assert inst.description == "Ambulance provided by Burgers University Medical Center" - assert inst.id == "amb" - assert inst.managingOrganization.reference == "Organization/f001" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "kind" - assert inst.name == "BUMC Ambulance" - assert inst.physicalType.coding[0].code == "ve" - assert inst.physicalType.coding[0].display == "Vehicle" - assert ( - inst.physicalType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/location-physical-type" - ) - assert inst.status == "active" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "mobile" - assert inst.telecom[0].value == "2329" - assert inst.text.div == ( - '
Mobile ' "Clinic
" - ) - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "AMB" - assert inst.type[0].coding[0].display == "Ambulance" - assert ( - inst.type[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - - -def test_location_3(base_settings): - """No. 3 tests collection for Location. - Test File: location-example-ambulance.json - """ - filename = base_settings["unittest_data_dir"] / "location-example-ambulance.json" - inst = location.Location.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Location" == inst.resource_type - - impl_location_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Location" == data["resourceType"] - - inst2 = location.Location(**data) - impl_location_3(inst2) - - -def impl_location_4(inst): - assert inst.description == ( - "All Pharmacies in the United Kingdom covered by the National" - " Pharmacy Association" - ) - assert inst.id == "ukp" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "kind" - assert inst.name == "UK Pharmacies" - assert inst.physicalType.coding[0].code == "jdn" - assert inst.physicalType.coding[0].display == "Jurisdiction" - assert ( - inst.physicalType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/location-physical-type" - ) - assert inst.status == "active" - assert inst.text.div == ( - '
UK ' "Pharmacies
" - ) - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "PHARM" - assert inst.type[0].coding[0].display == "Pharmacy" - assert ( - inst.type[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - - -def test_location_4(base_settings): - """No. 4 tests collection for Location. - Test File: location-example-ukpharmacy.json - """ - filename = base_settings["unittest_data_dir"] / "location-example-ukpharmacy.json" - inst = location.Location.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Location" == inst.resource_type - - impl_location_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Location" == data["resourceType"] - - inst2 = location.Location(**data) - impl_location_4(inst2) - - -def impl_location_5(inst): - assert inst.description == "Patient's Home" - assert inst.id == "ph" - assert inst.managingOrganization.reference == "Organization/f001" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "kind" - assert inst.name == "Patient's Home" - assert inst.physicalType.coding[0].code == "ho" - assert inst.physicalType.coding[0].display == "House" - assert ( - inst.physicalType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/location-physical-type" - ) - assert inst.status == "active" - assert inst.text.div == ( - '
Patient\'s ' "Home
" - ) - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "PTRES" - assert inst.type[0].coding[0].display == "Patient's Residence" - assert ( - inst.type[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - - -def test_location_5(base_settings): - """No. 5 tests collection for Location. - Test File: location-example-patients-home.json - """ - filename = ( - base_settings["unittest_data_dir"] / "location-example-patients-home.json" - ) - inst = location.Location.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Location" == inst.resource_type - - impl_location_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Location" == data["resourceType"] - - inst2 = location.Location(**data) - impl_location_5(inst2) - - -def impl_location_6(inst): - assert inst.address.city == "Ann Arbor" - assert inst.address.country == "USA" - assert inst.address.line[0] == "3300 Washtenaw Avenue, Suite 227" - assert inst.address.postalCode == "48104" - assert inst.address.state == "MI" - assert inst.description == "HL7 Headquarters" - assert inst.id == "hl7" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.mode == "instance" - assert inst.name == "Health Level Seven International" - assert inst.physicalType.coding[0].code == "bu" - assert inst.physicalType.coding[0].display == "Building" - assert ( - inst.physicalType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/location-physical-type" - ) - assert float(inst.position.latitude) == float(-83.69471) - assert float(inst.position.longitude) == float(42.2565) - assert inst.status == "active" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].value == "(+1) 734-677-7777" - assert inst.telecom[1].system == "fax" - assert inst.telecom[1].value == "(+1) 734-677-6622" - assert inst.telecom[2].system == "email" - assert inst.telecom[2].value == "hq@HL7.org" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "SLEEP" - assert inst.type[0].coding[0].display == "Sleep disorders unit" - assert ( - inst.type[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - - -def test_location_6(base_settings): - """No. 6 tests collection for Location. - Test File: location-example-hl7hq.json - """ - filename = base_settings["unittest_data_dir"] / "location-example-hl7hq.json" - inst = location.Location.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Location" == inst.resource_type - - impl_location_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Location" == data["resourceType"] - - inst2 = location.Location(**data) - impl_location_6(inst2) diff --git a/fhir/resources/tests/test_measure.py b/fhir/resources/tests/test_measure.py deleted file mode 100644 index 2fe935b9..00000000 --- a/fhir/resources/tests/test_measure.py +++ /dev/null @@ -1,699 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Measure -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import measure - - -def impl_measure_1(inst): - assert inst.date == fhirtypes.DateTime.validate("2015-03-08T11:15:33+10:00") - assert inst.description == ( - "Exclusive breastfeeding measure of outcomes for exclusive " - "breastmilk feeding of newborns." - ) - assert inst.group[0].id == "PopulationGroup1" - assert inst.group[0].population[0].code.coding[0].code == "initial-population" - assert inst.group[0].population[0].criteria.expression == "InitialPopulation1" - assert inst.group[0].population[0].criteria.language == "text/cql" - assert inst.group[0].population[1].code.coding[0].code == "denominator" - assert inst.group[0].population[1].criteria.expression == "Denominator1" - assert inst.group[0].population[1].criteria.language == "text/cql" - assert inst.group[0].population[2].code.coding[0].code == "denominator-exclusions" - assert inst.group[0].population[2].criteria.expression == "DenominatorExclusions1" - assert inst.group[0].population[2].criteria.language == "text/cql" - assert inst.group[0].population[3].code.coding[0].code == "numerator" - assert inst.group[0].population[3].criteria.expression == "Numerator1" - assert inst.group[0].population[3].criteria.language == "text/cql" - assert inst.group[1].id == "PopulationGroup2" - assert inst.group[1].population[0].code.coding[0].code == "initial-population" - assert inst.group[1].population[0].criteria.expression == "InitialPopulation2" - assert inst.group[1].population[0].criteria.language == "text/cql" - assert inst.group[1].population[1].code.coding[0].code == "denominator" - assert inst.group[1].population[1].criteria.expression == "Denominator2" - assert inst.group[1].population[1].criteria.language == "text/cql" - assert inst.group[1].population[2].code.coding[0].code == "denominator-exclusion" - assert inst.group[1].population[2].criteria.expression == "DenominatorExclusions2" - assert inst.group[1].population[2].criteria.language == "text/cql" - assert inst.group[1].population[3].code.coding[0].code == "numerator" - assert inst.group[1].population[3].criteria.expression == "Numerator2" - assert inst.group[1].population[3].criteria.language == "text/cql" - assert inst.id == "measure-exclusive-breastfeeding" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "exclusive-breastfeeding-measure" - assert inst.improvementNotation.coding[0].code == "increase" - assert inst.improvementNotation.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/measure-improvement-" "notation" - ) - assert inst.library[0] == "Library/library-exclusive-breastfeeding-cqm-logic" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.purpose == ( - "Measure of newborns who were fed breast milk only since " "birth" - ) - assert inst.relatedArtifact[0].citation == ( - "American Academy of Pediatrics. (2005). Section on " - "Breastfeeding. Policy Statement:Breastfeeding and the Use of" - " Human Milk. Pediatrics.115:496-506." - ) - assert inst.relatedArtifact[0].type == "documentation" - assert inst.relatedArtifact[1].type == "documentation" - assert inst.relatedArtifact[2].type == "documentation" - assert inst.relatedArtifact[3].type == "documentation" - assert inst.relatedArtifact[4].type == "documentation" - assert inst.relatedArtifact[5].type == "documentation" - assert inst.relatedArtifact[6].citation == ( - "Kramer, M.S. & Kakuma, R. (2002).Optimal duration of " - "exclusive breastfeeding. [107 refs] Cochrane Database of " - "Systematic Reviews. (1):CD003517." - ) - assert inst.relatedArtifact[6].type == "documentation" - assert inst.relatedArtifact[7].citation == ( - "Petrova, A., Hegyi, T., & Mehta, R. (2007). Maternal " - "race/ethnicity and one-month exclusive breastfeeding in " - "association with the in-hospital feeding modality. " - "Breastfeeding Medicine. 2(2):92-8." - ) - assert inst.relatedArtifact[7].type == "documentation" - assert inst.relatedArtifact[8].type == "documentation" - assert inst.relatedArtifact[9].type == "documentation" - assert inst.scoring.coding[0].code == "proportion" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Exclusive Breastfeeding Measure" - assert inst.topic[0].text == "Exclusive Breastfeeding" - assert inst.type[0].coding[0].code == "process" - assert inst.version == "4.0.1" - - -def test_measure_1(base_settings): - """No. 1 tests collection for Measure. - Test File: measure-exclusive-breastfeeding.json - """ - filename = ( - base_settings["unittest_data_dir"] / "measure-exclusive-breastfeeding.json" - ) - inst = measure.Measure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Measure" == inst.resource_type - - impl_measure_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Measure" == data["resourceType"] - - inst2 = measure.Measure(**data) - impl_measure_1(inst2) - - -def impl_measure_2(inst): - assert inst.group[0].id == "Main" - assert inst.group[0].population[0].code.coding[0].code == "initial-population" - assert inst.group[0].population[0].criteria.expression == "Initial Population" - assert inst.group[0].population[0].criteria.language == "text/cql" - assert inst.group[0].population[1].code.coding[0].code == "denominator" - assert inst.group[0].population[1].criteria.expression == "Denominator" - assert inst.group[0].population[1].criteria.language == "text/cql" - assert inst.group[0].population[2].code.coding[0].code == "numerator" - assert inst.group[0].population[2].criteria.expression == "Numerator" - assert inst.group[0].population[2].criteria.language == "text/cql" - assert inst.id == "component-b-example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.scoring.coding[0].code == "proportion" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "Screening for Depression" - - -def test_measure_2(base_settings): - """No. 2 tests collection for Measure. - Test File: measure-component-b-example.json - """ - filename = base_settings["unittest_data_dir"] / "measure-component-b-example.json" - inst = measure.Measure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Measure" == inst.resource_type - - impl_measure_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Measure" == data["resourceType"] - - inst2 = measure.Measure(**data) - impl_measure_2(inst2) - - -def impl_measure_3(inst): - assert inst.date == fhirtypes.DateTime.validate("2014-03-08T11:15:33+10:00") - assert inst.description == ( - "Exclusive breastfeeding measure of outcomes for exclusive " - "breastmilk feeding of newborns." - ) - assert inst.group[0].id == "PopulationGroup1" - assert inst.group[0].population[0].code.coding[0].code == "initial-population" - assert inst.group[0].population[0].criteria.expression == "InitialPopulation1" - assert inst.group[0].population[0].criteria.language == "text/cql" - assert inst.group[0].population[1].code.coding[0].code == "denominator" - assert inst.group[0].population[1].criteria.expression == "Denominator1" - assert inst.group[0].population[1].criteria.language == "text/cql" - assert inst.group[0].population[2].code.coding[0].code == "denominator-exclusions" - assert inst.group[0].population[2].criteria.expression == "DenominatorExclusions1" - assert inst.group[0].population[2].criteria.language == "text/cql" - assert inst.group[0].population[3].code.coding[0].code == "numerator" - assert inst.group[0].population[3].criteria.expression == "Numerator1" - assert inst.group[0].population[3].criteria.language == "text/cql" - assert inst.group[1].id == "PopulationGroup2" - assert inst.group[1].population[0].code.coding[0].code == "initial-population" - assert inst.group[1].population[0].criteria.expression == "InitialPopulation2" - assert inst.group[1].population[0].criteria.language == "text/cql" - assert inst.group[1].population[1].code.coding[0].code == "denominator" - assert inst.group[1].population[1].criteria.expression == "Denominator2" - assert inst.group[1].population[1].criteria.language == "text/cql" - assert inst.group[1].population[2].code.coding[0].code == "denominator-exclusion" - assert inst.group[1].population[2].criteria.expression == "DenominatorExclusions2" - assert inst.group[1].population[2].criteria.language == "text/cql" - assert inst.group[1].population[3].code.coding[0].code == "numerator" - assert inst.group[1].population[3].criteria.expression == "Numerator2" - assert inst.group[1].population[3].criteria.language == "text/cql" - assert inst.id == "measure-predecessor-example" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "exclusive-breastfeeding-measure" - assert inst.improvementNotation.coding[0].code == "increase" - assert inst.improvementNotation.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/measure-improvement-" "notation" - ) - assert inst.library[0] == "Library/library-exclusive-breastfeeding-cqm-logic" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.purpose == ( - "Measure of newborns who were fed breast milk only since " "birth" - ) - assert inst.relatedArtifact[0].citation == ( - "American Academy of Pediatrics. (2005). Section on " - "Breastfeeding. Policy Statement:Breastfeeding and the Use of" - " Human Milk. Pediatrics.115:496-506." - ) - assert inst.relatedArtifact[0].type == "documentation" - assert inst.relatedArtifact[1].type == "documentation" - assert inst.relatedArtifact[2].type == "documentation" - assert inst.relatedArtifact[3].type == "documentation" - assert inst.relatedArtifact[4].type == "documentation" - assert inst.relatedArtifact[5].type == "documentation" - assert inst.relatedArtifact[6].citation == ( - "Kramer, M.S. & Kakuma, R. (2002).Optimal duration of " - "exclusive breastfeeding. [107 refs] Cochrane Database of " - "Systematic Reviews. (1):CD003517." - ) - assert inst.relatedArtifact[6].type == "documentation" - assert inst.relatedArtifact[7].citation == ( - "Petrova, A., Hegyi, T., & Mehta, R. (2007). Maternal " - "race/ethnicity and one-month exclusive breastfeeding in " - "association with the in-hospital feeding modality. " - "Breastfeeding Medicine. 2(2):92-8." - ) - assert inst.relatedArtifact[7].type == "documentation" - assert inst.relatedArtifact[8].type == "documentation" - assert inst.relatedArtifact[9].type == "documentation" - assert inst.scoring.coding[0].code == "proportion" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Exclusive Breastfeeding Measure" - assert inst.topic[0].text == "Exclusive Breastfeeding" - assert inst.type[0].coding[0].code == "process" - assert inst.version == "4.0.1" - - -def test_measure_3(base_settings): - """No. 3 tests collection for Measure. - Test File: measure-predecessor-example.json - """ - filename = base_settings["unittest_data_dir"] / "measure-predecessor-example.json" - inst = measure.Measure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Measure" == inst.resource_type - - impl_measure_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Measure" == data["resourceType"] - - inst2 = measure.Measure(**data) - impl_measure_3(inst2) - - -def impl_measure_4(inst): - assert inst.date == fhirtypes.DateTime.validate("2018-03-08T11:15:33+10:00") - assert inst.experimental is True - assert inst.group[0].code.coding[0].code == "QRPH_ADX_ART1_N" - assert inst.group[0].code.coding[0].system == "http://ihe.net/qrph/adx/" - assert inst.group[0].description == ( - "Number of adults and children newly enrolled on " - "antiretroviral therapy (ART) in the reporting period" - ) - assert inst.group[0].population[0].code.text == "cohort" - assert inst.group[0].population[0].criteria.expression == ( - "Newly enrolled on antiretroviral therapy (ART) during " "measurement period" - ) - assert inst.group[0].population[0].criteria.language == "text/cql" - assert inst.group[0].stratifier[0].code.coding[0].code == "AGE_GROUP:SEX" - assert ( - inst.group[0].stratifier[0].code.coding[0].system == "http://ihe.net/qrph/adx/" - ) - assert inst.group[0].stratifier[0].criteria.expression == "Age Group/Sex" - assert inst.group[0].stratifier[0].criteria.language == "text/cql" - assert inst.group[1].code.coding[0].code == "QRPH_ADX_ART1_N_PREG_BF" - assert inst.group[1].code.coding[0].system == "http://ihe.net/qrph/adx/" - assert inst.group[1].description == ( - "Number of adults and children newly enrolled on ART in the " - "reporting period_pregnant and breastfeeding" - ) - assert inst.group[1].population[0].code.text == "cohort" - assert inst.group[1].population[0].criteria.expression == ( - "Newly enrolled on antiretroviral therapy (ART) during " - "measurement period (pregnant and breastfeeding)" - ) - assert inst.group[1].population[0].criteria.language == "text/cql" - assert inst.group[1].stratifier[0].code.coding[0].code == "PREG_BF" - assert ( - inst.group[1].stratifier[0].code.coding[0].system == "http://ihe.net/qrph/adx/" - ) - assert inst.group[1].stratifier[0].criteria.expression == "Pregnant/Breastfeeding" - assert inst.group[1].stratifier[0].criteria.language == "text/cql" - assert inst.group[2].code.coding[0].code == "QRPH_ADX_ART3_N" - assert inst.group[2].code.coding[0].system == "http://ihe.net/qrph/adx/" - assert inst.group[2].description == ( - "Number of adults and children currently receiving " - "antiretroviral therapy (ART)" - ) - assert inst.group[2].population[0].code.text == "cohort" - assert inst.group[2].population[0].criteria.expression == ( - "Receiving antiretroviral therapy (ART) during measurement " "period" - ) - assert inst.group[2].population[0].criteria.language == "text/cql" - assert inst.group[3].code.coding[0].code == "QRPH_ADX_ART5_N" - assert inst.group[3].code.coding[0].system == "http://ihe.net/qrph/adx/" - assert inst.group[3].description == ( - "Number of adults and children who are still on treatment at " - "12 months after initiating ART" - ) - assert inst.group[3].population[0].code.text == "cohort" - assert inst.group[3].population[0].criteria.expression == ( - "Receiving antiretroviral therapy (ART) at 12 months after " "initiating" - ) - assert inst.group[3].population[0].criteria.language == "text/cql" - assert inst.group[3].stratifier[0].component[0].code.coding[0].code == "AGE_GROUP" - assert ( - inst.group[3].stratifier[0].component[0].code.coding[0].system - == "http://ihe.net/qrph/adx/" - ) - assert inst.group[3].stratifier[0].component[0].criteria.expression == "Age Group" - assert inst.group[3].stratifier[0].component[0].criteria.language == "text/cql" - assert inst.group[3].stratifier[0].component[1].code.coding[0].code == "SEX" - assert ( - inst.group[3].stratifier[0].component[1].code.coding[0].system - == "http://ihe.net/qrph/adx/" - ) - assert inst.group[3].stratifier[0].component[1].criteria.expression == "Sex" - assert inst.group[3].stratifier[0].component[1].criteria.language == "text/cql" - assert inst.group[4].code.coding[0].code == "QRPH_ADX_ART5_N_PREG_BF" - assert inst.group[4].code.coding[0].system == "http://ihe.net/qrph/adx/" - assert inst.group[4].description == ( - "Number of adults and children who are still on treatment at " - "12 months after initiating ART-pregnant and breastfeeding" - ) - assert inst.group[4].population[0].code.text == "cohort" - assert inst.group[4].population[0].criteria.expression == ( - "Receiving antiretroviral therapy (ART) at 12 months after " - "initiating (pregnant and breastfeeding)" - ) - assert inst.group[4].population[0].criteria.language == "text/cql" - assert inst.group[4].stratifier[0].code.coding[0].code == "PREG_BF" - assert ( - inst.group[4].stratifier[0].code.coding[0].system == "http://ihe.net/qrph/adx/" - ) - assert inst.group[4].stratifier[0].criteria.expression == "Pregnant/Breastfeeding" - assert inst.group[4].stratifier[0].criteria.language == "text/cql" - assert inst.group[5].code.coding[0].code == "QRPH_ADX_ART5_D" - assert inst.group[5].code.coding[0].system == "http://ihe.net/qrph/adx/" - assert inst.group[5].description == ( - "Number of adults and children who initiated ART in the 12 " - "months prior to the beginning of the reporting period" - ) - assert inst.group[5].population[0].code.text == "cohort" - assert inst.group[5].population[0].criteria.expression == ( - "Initiated antiretroviral therapy (ART) in the 12 months " - "prior to measurement period" - ) - assert inst.group[5].population[0].criteria.language == "text/cql" - assert inst.group[5].stratifier[0].code.coding[0].code == "AGE_GROUP:SEX" - assert ( - inst.group[5].stratifier[0].code.coding[0].system == "http://ihe.net/qrph/adx/" - ) - assert inst.group[5].stratifier[0].criteria.expression == "Age Group/Sex" - assert inst.group[5].stratifier[0].criteria.language == "text/cql" - assert inst.group[6].code.coding[0].code == "QRPH_ADX_MTCT1_D" - assert inst.group[6].code.coding[0].system == "http://ihe.net/qrph/adx/" - assert inst.group[6].description == ( - "Number of pregnant women who attended ANC or had a facility-" - "based delivery in the reporting period" - ) - assert inst.group[6].population[0].code.text == "cohort" - assert inst.group[6].population[0].criteria.expression == ( - "Antenatal Care Visit or Live Birth during the Measurement " "Period" - ) - assert inst.group[6].population[0].criteria.language == "text/cql" - assert inst.group[6].stratifier[0].code.coding[0].code == "PMTCT_HIV_STATUS" - assert ( - inst.group[6].stratifier[0].code.coding[0].system == "http://ihe.net/qrph/adx/" - ) - assert inst.group[6].stratifier[0].criteria.expression == "PMTCT HIV Status" - assert inst.group[6].stratifier[0].criteria.language == "text/cql" - assert inst.group[7].code.coding[0].code == "QRPH_ADX_MTCT2_D" - assert inst.group[7].code.coding[0].system == "http://ihe.net/qrph/adx/" - assert inst.group[7].description == ( - "Number of HIV positive pregnant women who attended ANC or " - "had a facility-based delivery within the reporting period" - ) - assert inst.group[7].population[0].code.text == "cohort" - assert inst.group[7].population[0].criteria.expression == ( - "Antenatal Care Visit or Live Birth during Measurement Period" " (HIV Positive)" - ) - assert inst.group[7].population[0].criteria.language == "text/cql" - assert inst.group[8].code.coding[0].code == "QRPH_ADX_MTCT2_N" - assert inst.group[8].code.coding[0].system == "http://ihe.net/qrph/adx/" - assert inst.group[8].description == ( - "Number of HIV-positive pregnant women who received ART to " - "reduce the risk of mother-to-child-transmission during " - "pregnancy" - ) - assert inst.group[8].population[0].code.text == "cohort" - assert inst.group[8].population[0].criteria.expression == ( - "HIV-positive, pregnant, and receiving antiretroviral therapy" - " (ART) to reduce the risk of mother-to-child-transmission " - "during pregnancy" - ) - assert inst.group[8].population[0].criteria.language == "text/cql" - assert inst.group[8].stratifier[0].code.coding[0].code == "PMTCT_ART_STATUS" - assert ( - inst.group[8].stratifier[0].code.coding[0].system == "http://ihe.net/qrph/adx/" - ) - assert inst.group[8].stratifier[0].criteria.expression == "PMTCT ART Status" - assert inst.group[8].stratifier[0].criteria.language == "text/cql" - assert inst.group[9].code.coding[0].code == "QRPH_ADX_VLS3_N" - assert inst.group[9].code.coding[0].system == "http://ihe.net/qrph/adx/" - assert inst.group[9].description == ( - "Number of people living with HIV and on ART who have a " - "suppressed viral load results (<1000 copies/mL)" - ) - assert inst.group[9].population[0].code.text == "cohort" - assert inst.group[9].population[0].criteria.expression == ( - "Living with HIV and on ART with suppressed viral load " - "results (<1000 copies/mL)" - ) - assert inst.group[9].population[0].criteria.language == "text/cql" - assert inst.group[9].stratifier[0].code.coding[0].code == "AGE_GROUP:SEX" - assert ( - inst.group[9].stratifier[0].code.coding[0].system == "http://ihe.net/qrph/adx/" - ) - assert inst.group[9].stratifier[0].criteria.expression == "Age Group/Sex" - assert inst.group[9].stratifier[0].criteria.language == "text/cql" - assert inst.id == "hiv-indicators" - assert inst.identifier[0].system == "http://ohie.org/Measure/" - assert inst.identifier[0].value == "hiv-indicators" - assert inst.library[0] == "http://ohie.org/Library/hiv-indicators" - assert inst.name == "HIV" - assert inst.publisher == "Open HIE" - assert inst.relatedArtifact[0].type == "derived-from" - assert ( - inst.relatedArtifact[0].url - == "http://wiki.ihe.net/index.php/Aggregate_Data_Exchange_-_HIV" - ) - assert inst.scoring.coding[0].code == "cohort" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "HIV Indicators" - assert inst.url == "http://ohie.org/Measure/hiv-indicators" - assert inst.version == "0.0.0" - - -def test_measure_4(base_settings): - """No. 4 tests collection for Measure. - Test File: measure-hiv-indicators.json - """ - filename = base_settings["unittest_data_dir"] / "measure-hiv-indicators.json" - inst = measure.Measure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Measure" == inst.resource_type - - impl_measure_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Measure" == data["resourceType"] - - inst2 = measure.Measure(**data) - impl_measure_4(inst2) - - -def impl_measure_5(inst): - assert inst.approvalDate == fhirtypes.Date.validate("2016-01-01") - assert inst.author[0].name == "National Committee for Quality Assurance" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://www.ncqa.org/" - assert inst.date == fhirtypes.DateTime.validate("2017-03-10T11:15:33+10:00") - assert inst.description == ( - "Percentage of children 3-18 years of age who were diagnosed " - "with pharyngitis, ordered an antibiotic and received a group" - " A streptococcus (strep) test for the episode." - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2017-12-31T11:15:33+10:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2017-01-01T11:15:33+10:00" - ) - assert inst.experimental is True - assert inst.group[0].id == "CMS146-group-1" - assert inst.group[0].population[0].code.coding[0].code == "initial-population" - assert ( - inst.group[0].population[0].criteria.expression == "CMS146.InInitialPopulation" - ) - assert inst.group[0].population[0].criteria.language == "text/cql" - assert inst.group[0].population[1].code.coding[0].code == "numerator" - assert inst.group[0].population[1].criteria.expression == "CMS146.InNumerator" - assert inst.group[0].population[1].criteria.language == "text/cql" - assert inst.group[0].population[2].code.coding[0].code == "denominator" - assert inst.group[0].population[2].criteria.expression == "CMS146.InDenominator" - assert inst.group[0].population[2].criteria.language == "text/cql" - assert inst.group[0].population[3].code.coding[0].code == "denominator-exclusion" - assert ( - inst.group[0].population[3].criteria.expression - == "CMS146.InDenominatorExclusions" - ) - assert inst.group[0].population[3].criteria.language == "text/cql" - assert inst.group[0].stratifier[0].code.text == "stratifier-ages-up-to-9" - assert inst.group[0].stratifier[0].criteria.expression == "CMS146.AgesUpToNine" - assert inst.group[0].stratifier[0].criteria.language == "text/cql" - assert inst.group[0].stratifier[1].code.text == "stratifier-ages-10-plus" - assert inst.group[0].stratifier[1].criteria.expression == "CMS146.AgesTenPlus" - assert inst.group[0].stratifier[1].criteria.language == "text/cql" - assert inst.group[0].stratifier[2].code.text == "stratifier-gender" - assert inst.group[0].stratifier[2].criteria.expression == "Patient.gender" - assert inst.group[0].stratifier[2].criteria.language == "text/fhirpath" - assert inst.guidance == ( - "This is an episode of care measure that examines all " - "eligible episodes for the patient during the measurement " - "period. If the patient has more than one episode, include " - "all episodes in the measure" - ) - assert inst.id == "measure-cms146-example" - assert ( - inst.identifier[0].system - == "http://hl7.org/fhir/cqi/ecqm/Measure/Identifier/cms" - ) - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "146" - assert ( - inst.identifier[1].system - == "http://hl7.org/fhir/cqi/ecqm/Measure/Identifier/nqf" - ) - assert inst.identifier[1].use == "official" - assert inst.identifier[1].value == "0002" - assert inst.improvementNotation.coding[0].code == "increase" - assert inst.improvementNotation.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/measure-improvement-" "notation" - ) - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.lastReviewDate == fhirtypes.Date.validate("2016-09-01") - assert inst.library[0] == "Library/library-cms146-example" - assert inst.name == "CMS146" - assert inst.publisher == "National Committee for Quality Assurance" - assert inst.purpose == ( - "Measure of children with a group A streptococcus test in the" - " 7-day period from 3 days prior through 3 days after the " - "diagnosis of pharyngitis" - ) - assert inst.relatedArtifact[0].citation == ( - "Linder, J.A., D.W. Bates, G.M. Lee, J.A. Finkelstein. 2005. " - "_Antibiotic treatment of children with sore throat._ JAMA " - "294(18):2315-2322. " - ) - assert inst.relatedArtifact[0].type == "documentation" - assert inst.relatedArtifact[1].citation == ( - "Infectious Diseases Society of America. 2012. _Clinical " - "Practice Guideline for the Diagnosis and Management of Group" - " A Streptococcal Pharyngitis: 2012 Update._ " - ) - assert inst.relatedArtifact[1].type == "documentation" - assert inst.relatedArtifact[2].type == "documentation" - assert inst.scoring.coding[0].code == "proportion" - assert inst.status == "active" - assert inst.supplementalData[0].code.text == "supplemental-data-gender" - assert inst.supplementalData[0].criteria.expression == "Patient.gender" - assert inst.supplementalData[0].criteria.language == "text/fhirpath" - assert inst.supplementalData[1].code.text == "supplemental-data-deceased" - assert inst.supplementalData[1].criteria.expression == "deceasedBoolean" - assert inst.supplementalData[1].criteria.language == "text/fhirpath" - assert inst.text.status == "additional" - assert inst.title == "Appropriate Testing for Children with Pharyngitis" - assert inst.topic[0].coding[0].code == "57024-2" - assert inst.topic[0].coding[0].system == "http://loinc.org" - assert inst.type[0].coding[0].code == "process" - assert inst.url == "http://hl7.org/fhir/Measure/measure-cms146-example" - assert inst.useContext[0].code.code == "program" - assert inst.useContext[0].valueCodeableConcept.text == "eligibile-provider" - assert inst.useContext[1].code.code == "age" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueRange.high.unit == "a" - assert float(inst.useContext[1].valueRange.high.value) == float(18) - assert inst.useContext[1].valueRange.low.unit == "a" - assert float(inst.useContext[1].valueRange.low.value) == float(3) - assert inst.version == "1.0.0" - - -def test_measure_5(base_settings): - """No. 5 tests collection for Measure. - Test File: measure-cms146-example.json - """ - filename = base_settings["unittest_data_dir"] / "measure-cms146-example.json" - inst = measure.Measure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Measure" == inst.resource_type - - impl_measure_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Measure" == data["resourceType"] - - inst2 = measure.Measure(**data) - impl_measure_5(inst2) - - -def impl_measure_6(inst): - assert inst.group[0].id == "Main" - assert inst.group[0].population[0].code.coding[0].code == "initial-population" - assert inst.group[0].population[0].criteria.expression == "Initial Population" - assert inst.group[0].population[0].criteria.language == "text/cql" - assert inst.group[0].population[1].code.coding[0].code == "denominator" - assert inst.group[0].population[1].criteria.expression == "Denominator" - assert inst.group[0].population[1].criteria.language == "text/cql" - assert inst.group[0].population[2].code.coding[0].code == "numerator" - assert inst.group[0].population[2].criteria.expression == "Numerator" - assert inst.group[0].population[2].criteria.language == "text/cql" - assert inst.id == "component-a-example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.scoring.coding[0].code == "proportion" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "Screening for Alcohol Misuse" - - -def test_measure_6(base_settings): - """No. 6 tests collection for Measure. - Test File: measure-component-a-example.json - """ - filename = base_settings["unittest_data_dir"] / "measure-component-a-example.json" - inst = measure.Measure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Measure" == inst.resource_type - - impl_measure_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Measure" == data["resourceType"] - - inst2 = measure.Measure(**data) - impl_measure_6(inst2) - - -def impl_measure_7(inst): - assert inst.compositeScoring.coding[0].code == "opportunity" - assert inst.id == "composite-example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.relatedArtifact[0].resource == "Measure/component-a-example" - assert inst.relatedArtifact[0].type == "composed-of" - assert inst.relatedArtifact[1].resource == "Measure/component-b-example" - assert inst.relatedArtifact[1].type == "composed-of" - assert inst.scoring.coding[0].code == "proportion" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "Behavioral Assessment Composite Measure" - - -def test_measure_7(base_settings): - """No. 7 tests collection for Measure. - Test File: measure-composite-example.json - """ - filename = base_settings["unittest_data_dir"] / "measure-composite-example.json" - inst = measure.Measure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Measure" == inst.resource_type - - impl_measure_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Measure" == data["resourceType"] - - inst2 = measure.Measure(**data) - impl_measure_7(inst2) diff --git a/fhir/resources/tests/test_measurereport.py b/fhir/resources/tests/test_measurereport.py deleted file mode 100644 index fc69ec01..00000000 --- a/fhir/resources/tests/test_measurereport.py +++ /dev/null @@ -1,954 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MeasureReport -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import measurereport - - -def impl_measurereport_1(inst): - assert inst.contained[0].id == "reporter" - assert inst.date == fhirtypes.DateTime.validate("2014-04-01T11:15:33+10:00") - assert inst.evaluatedResource[0].reference == "Condition/123" - assert inst.group[0].id == "CMS146-group-1" - assert inst.group[0].population[0].code.coding[0].code == "initial-population" - assert inst.group[0].population[0].count == 1 - assert inst.group[0].population[1].code.coding[0].code == "numerator" - assert inst.group[0].population[1].count == 1 - assert inst.group[0].population[2].code.coding[0].code == "denominator" - assert inst.group[0].population[2].count == 1 - assert inst.group[0].population[3].code.coding[0].code == "denominator-exclusion" - assert inst.group[0].population[3].count == 0 - assert inst.group[0].stratifier[0].code[0].text == "stratifier-ages-up-to-9" - assert ( - inst.group[0].stratifier[0].stratum[0].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[0].stratum[0].population[0].count == 1 - assert ( - inst.group[0].stratifier[0].stratum[0].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[0].stratum[0].population[1].count == 1 - assert ( - inst.group[0].stratifier[0].stratum[0].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[0].stratum[0].population[2].count == 1 - assert ( - inst.group[0].stratifier[0].stratum[0].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[0].stratum[0].population[3].count == 0 - assert inst.group[0].stratifier[0].stratum[0].value.text == "true" - assert ( - inst.group[0].stratifier[0].stratum[1].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[0].stratum[1].population[0].count == 0 - assert ( - inst.group[0].stratifier[0].stratum[1].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[0].stratum[1].population[1].count == 0 - assert ( - inst.group[0].stratifier[0].stratum[1].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[0].stratum[1].population[2].count == 0 - assert ( - inst.group[0].stratifier[0].stratum[1].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[0].stratum[1].population[3].count == 0 - assert inst.group[0].stratifier[0].stratum[1].value.text == "false" - assert inst.group[0].stratifier[1].code[0].text == "stratifier-ages-10-plus" - assert ( - inst.group[0].stratifier[1].stratum[0].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[1].stratum[0].population[0].count == 0 - assert ( - inst.group[0].stratifier[1].stratum[0].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[1].stratum[0].population[1].count == 0 - assert ( - inst.group[0].stratifier[1].stratum[0].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[1].stratum[0].population[2].count == 0 - assert ( - inst.group[0].stratifier[1].stratum[0].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[1].stratum[0].population[3].count == 0 - assert inst.group[0].stratifier[1].stratum[0].value.text == "true" - assert ( - inst.group[0].stratifier[1].stratum[1].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[1].stratum[1].population[0].count == 1 - assert ( - inst.group[0].stratifier[1].stratum[1].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[1].stratum[1].population[1].count == 1 - assert ( - inst.group[0].stratifier[1].stratum[1].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[1].stratum[1].population[2].count == 1 - assert ( - inst.group[0].stratifier[1].stratum[1].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[1].stratum[1].population[3].count == 0 - assert inst.group[0].stratifier[1].stratum[1].value.text == "false" - assert inst.group[0].stratifier[2].code[0].text == "stratifier-gender" - assert ( - inst.group[0].stratifier[2].stratum[0].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[0].population[0].count == 1 - assert ( - inst.group[0].stratifier[2].stratum[0].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[0].population[1].count == 1 - assert ( - inst.group[0].stratifier[2].stratum[0].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[0].population[2].count == 1 - assert ( - inst.group[0].stratifier[2].stratum[0].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[2].stratum[0].population[3].count == 0 - assert inst.group[0].stratifier[2].stratum[0].value.text == "male" - assert ( - inst.group[0].stratifier[2].stratum[1].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[1].population[0].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[1].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[1].population[1].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[1].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[1].population[2].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[1].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[2].stratum[1].population[3].count == 0 - assert inst.group[0].stratifier[2].stratum[1].value.text == "female" - assert ( - inst.group[0].stratifier[2].stratum[2].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[2].population[0].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[2].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[2].population[1].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[2].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[2].population[2].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[2].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[2].stratum[2].population[3].count == 0 - assert inst.group[0].stratifier[2].stratum[2].value.text == "other" - assert ( - inst.group[0].stratifier[2].stratum[3].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[3].population[0].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[3].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[3].population[1].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[3].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[3].population[2].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[3].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[2].stratum[3].population[3].count == 0 - assert inst.group[0].stratifier[2].stratum[3].value.text == "unknown" - assert inst.id == "measurereport-cms146-cat1-example" - assert inst.identifier[0].value == "measurereport-cms146-cat1-example-2017-03-13" - assert inst.measure == "Measure/CMS146" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2014-03-31T11:15:33+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2014-01-01T11:15:33+10:00") - assert inst.reporter.reference == "#reporter" - assert inst.status == "complete" - assert inst.subject.reference == "Patient/123" - assert inst.text.status == "generated" - assert inst.type == "individual" - - -def test_measurereport_1(base_settings): - """No. 1 tests collection for MeasureReport. - Test File: measurereport-cms146-cat1-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "measurereport-cms146-cat1-example.json" - ) - inst = measurereport.MeasureReport.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MeasureReport" == inst.resource_type - - impl_measurereport_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MeasureReport" == data["resourceType"] - - inst2 = measurereport.MeasureReport(**data) - impl_measurereport_1(inst2) - - -def impl_measurereport_2(inst): - assert inst.contained[0].id == "reporter" - assert inst.date == fhirtypes.DateTime.validate("2014-04-01T11:15:33+10:00") - assert inst.group[0].id == "CMS146-group-1" - assert inst.group[0].population[0].code.coding[0].code == "initial-population" - assert inst.group[0].population[0].count == 500 - assert ( - inst.group[0].population[0].subjectResults.reference - == "List/CMS146-initial-population" - ) - assert inst.group[0].population[1].code.coding[0].code == "numerator" - assert inst.group[0].population[1].count == 200 - assert ( - inst.group[0].population[1].subjectResults.reference == "List/CMS146-numerator" - ) - assert inst.group[0].population[2].code.coding[0].code == "denominator" - assert inst.group[0].population[2].count == 500 - assert ( - inst.group[0].population[2].subjectResults.reference - == "List/CMS146-denominator" - ) - assert inst.group[0].population[3].code.coding[0].code == "denominator-exclusion" - assert inst.group[0].population[3].count == 100 - assert ( - inst.group[0].population[3].subjectResults.reference - == "List/CMS146-denominator-exclusions" - ) - assert inst.group[0].stratifier[0].code[0].text == "stratifier-ages-up-to-9" - assert ( - inst.group[0].stratifier[0].stratum[0].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[0].stratum[0].population[0].count == 250 - assert ( - inst.group[0].stratifier[0].stratum[0].population[0].subjectResults.reference - == "List/CMS146-stratifier-ages-up-to-9-true-initial-population" - ) - assert ( - inst.group[0].stratifier[0].stratum[0].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[0].stratum[0].population[1].count == 100 - assert ( - inst.group[0].stratifier[0].stratum[0].population[1].subjectResults.reference - == "List/CMS146-stratifier-ages-up-to-9-true-numerator" - ) - assert ( - inst.group[0].stratifier[0].stratum[0].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[0].stratum[0].population[2].count == 250 - assert ( - inst.group[0].stratifier[0].stratum[0].population[2].subjectResults.reference - == "List/CMS146-stratifier-ages-up-to-9-true-denominator" - ) - assert ( - inst.group[0].stratifier[0].stratum[0].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[0].stratum[0].population[3].count == 50 - assert inst.group[0].stratifier[0].stratum[0].population[ - 3 - ].subjectResults.reference == ( - "List/CMS146-stratifier-ages-up-to-9-true-denominator-" "exclusions" - ) - assert inst.group[0].stratifier[0].stratum[0].value.text == "true" - assert ( - inst.group[0].stratifier[0].stratum[1].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[0].stratum[1].population[0].count == 250 - assert ( - inst.group[0].stratifier[0].stratum[1].population[0].subjectResults.reference - == "List/CMS146-stratifier-ages-up-to-9-false-initial-population" - ) - assert ( - inst.group[0].stratifier[0].stratum[1].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[0].stratum[1].population[1].count == 100 - assert ( - inst.group[0].stratifier[0].stratum[1].population[1].subjectResults.reference - == "List/CMS146-stratifier-ages-up-to-9-false-numerator" - ) - assert ( - inst.group[0].stratifier[0].stratum[1].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[0].stratum[1].population[2].count == 250 - assert ( - inst.group[0].stratifier[0].stratum[1].population[2].subjectResults.reference - == "List/CMS146-stratifier-ages-up-to-9-false-denominator" - ) - assert ( - inst.group[0].stratifier[0].stratum[1].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[0].stratum[1].population[3].count == 50 - assert inst.group[0].stratifier[0].stratum[1].population[ - 3 - ].subjectResults.reference == ( - "List/CMS146-stratifier-ages-up-to-9-false-denominator-" "exclusions" - ) - assert inst.group[0].stratifier[0].stratum[1].value.text == "false" - assert inst.group[0].stratifier[1].code[0].text == "stratifier-ages-10-plus" - assert ( - inst.group[0].stratifier[1].stratum[0].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[1].stratum[0].population[0].count == 250 - assert ( - inst.group[0].stratifier[1].stratum[0].population[0].subjectResults.reference - == "List/CMS146-stratifier-ages-10-plus-true-initial-population" - ) - assert ( - inst.group[0].stratifier[1].stratum[0].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[1].stratum[0].population[1].count == 100 - assert ( - inst.group[0].stratifier[1].stratum[0].population[1].subjectResults.reference - == "List/CMS146-stratifier-ages-10-plus-true-numerator" - ) - assert ( - inst.group[0].stratifier[1].stratum[0].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[1].stratum[0].population[2].count == 250 - assert ( - inst.group[0].stratifier[1].stratum[0].population[2].subjectResults.reference - == "List/CMS146-stratifier-ages-10-plus-true-denominator" - ) - assert ( - inst.group[0].stratifier[1].stratum[0].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[1].stratum[0].population[3].count == 50 - assert inst.group[0].stratifier[1].stratum[0].population[ - 3 - ].subjectResults.reference == ( - "List/CMS146-stratifier-ages-10-plus-true-denominator-" "exclusions" - ) - assert inst.group[0].stratifier[1].stratum[0].value.text == "true" - assert ( - inst.group[0].stratifier[1].stratum[1].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[1].stratum[1].population[0].count == 250 - assert ( - inst.group[0].stratifier[1].stratum[1].population[0].subjectResults.reference - == "List/CMS146-stratifier-ages-10-plus-false-initial-population" - ) - assert ( - inst.group[0].stratifier[1].stratum[1].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[1].stratum[1].population[1].count == 100 - assert ( - inst.group[0].stratifier[1].stratum[1].population[1].subjectResults.reference - == "List/CMS146-stratifier-ages-10-plus-false-numerator" - ) - assert ( - inst.group[0].stratifier[1].stratum[1].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[1].stratum[1].population[2].count == 250 - assert ( - inst.group[0].stratifier[1].stratum[1].population[2].subjectResults.reference - == "List/CMS146-stratifier-ages-10-plus-false-denominator" - ) - assert ( - inst.group[0].stratifier[1].stratum[1].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[1].stratum[1].population[3].count == 50 - assert inst.group[0].stratifier[1].stratum[1].population[ - 3 - ].subjectResults.reference == ( - "List/CMS146-stratifier-ages-10-plus-false-denominator-" "exclusions" - ) - assert inst.group[0].stratifier[1].stratum[1].value.text == "false" - assert inst.group[0].stratifier[2].code[0].text == "stratifier-gender" - assert ( - inst.group[0].stratifier[2].stratum[0].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[0].population[0].count == 250 - assert ( - inst.group[0].stratifier[2].stratum[0].population[0].subjectResults.reference - == "List/CMS146-stratifier-gender-male-initial-population" - ) - assert ( - inst.group[0].stratifier[2].stratum[0].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[0].population[1].count == 100 - assert ( - inst.group[0].stratifier[2].stratum[0].population[1].subjectResults.reference - == "List/CMS146-stratifier-gender-male-numerator" - ) - assert ( - inst.group[0].stratifier[2].stratum[0].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[0].population[2].count == 250 - assert ( - inst.group[0].stratifier[2].stratum[0].population[2].subjectResults.reference - == "List/CMS146-stratifier-gender-male-denominator" - ) - assert ( - inst.group[0].stratifier[2].stratum[0].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[2].stratum[0].population[3].count == 50 - assert ( - inst.group[0].stratifier[2].stratum[0].population[3].subjectResults.reference - == "List/CMS146-stratifier-gender-male-denominator-exclusions" - ) - assert inst.group[0].stratifier[2].stratum[0].value.text == "male" - assert ( - inst.group[0].stratifier[2].stratum[1].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[1].population[0].count == 250 - assert ( - inst.group[0].stratifier[2].stratum[1].population[0].subjectResults.reference - == "List/CMS146-stratifier-gender-female-initial-population" - ) - assert ( - inst.group[0].stratifier[2].stratum[1].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[1].population[1].count == 100 - assert ( - inst.group[0].stratifier[2].stratum[1].population[1].subjectResults.reference - == "List/CMS146-stratifier-gender-female-numerator" - ) - assert ( - inst.group[0].stratifier[2].stratum[1].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[1].population[2].count == 250 - assert ( - inst.group[0].stratifier[2].stratum[1].population[2].subjectResults.reference - == "List/CMS146-stratifier-gender-female-denominator" - ) - assert ( - inst.group[0].stratifier[2].stratum[1].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[2].stratum[1].population[3].count == 50 - assert ( - inst.group[0].stratifier[2].stratum[1].population[3].subjectResults.reference - == "List/CMS146-stratifier-gender-female-denominator-exclusions" - ) - assert inst.group[0].stratifier[2].stratum[1].value.text == "female" - assert ( - inst.group[0].stratifier[2].stratum[2].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[2].population[0].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[2].population[0].subjectResults.reference - == "List/CMS146-stratifier-gender-other-initial-population" - ) - assert ( - inst.group[0].stratifier[2].stratum[2].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[2].population[1].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[2].population[1].subjectResults.reference - == "List/CMS146-stratifier-gender-other-numerator" - ) - assert ( - inst.group[0].stratifier[2].stratum[2].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[2].population[2].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[2].population[2].subjectResults.reference - == "List/CMS146-stratifier-gender-other-denominator" - ) - assert ( - inst.group[0].stratifier[2].stratum[2].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[2].stratum[2].population[3].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[2].population[3].subjectResults.reference - == "List/CMS146-stratifier-gender-other-denominator-exclusions" - ) - assert inst.group[0].stratifier[2].stratum[2].value.text == "other" - assert ( - inst.group[0].stratifier[2].stratum[3].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[3].population[0].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[3].population[0].subjectResults.reference - == "List/CMS146-stratifier-gender-unknown-initial-population" - ) - assert ( - inst.group[0].stratifier[2].stratum[3].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[3].population[1].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[3].population[1].subjectResults.reference - == "List/CMS146-stratifier-gender-unknown-numerator" - ) - assert ( - inst.group[0].stratifier[2].stratum[3].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[3].population[2].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[3].population[2].subjectResults.reference - == "List/CMS146-stratifier-gender-unknown-denominator" - ) - assert ( - inst.group[0].stratifier[2].stratum[3].population[3].code.coding[0].code - == "denominator-exclusions" - ) - assert inst.group[0].stratifier[2].stratum[3].population[3].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[3].population[3].subjectResults.reference - == "List/CMS146-stratifier-gender-unknown-denominator-exclusions" - ) - assert inst.group[0].stratifier[2].stratum[3].value.text == "unknown" - assert inst.id == "measurereport-cms146-cat2-example" - assert inst.identifier[0].value == "measurereport-cms146-cat2-example-2017-03-13" - assert inst.measure == "Measure/CMS146" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2014-03-31T11:15:33+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2014-01-01T11:15:33+10:00") - assert inst.reporter.reference == "#reporter" - assert inst.status == "complete" - assert inst.text.status == "generated" - assert inst.type == "subject-list" - - -def test_measurereport_2(base_settings): - """No. 2 tests collection for MeasureReport. - Test File: measurereport-cms146-cat2-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "measurereport-cms146-cat2-example.json" - ) - inst = measurereport.MeasureReport.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MeasureReport" == inst.resource_type - - impl_measurereport_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MeasureReport" == data["resourceType"] - - inst2 = measurereport.MeasureReport(**data) - impl_measurereport_2(inst2) - - -def impl_measurereport_3(inst): - assert inst.group[0].code.coding[0].code == "QRPH_ADX_ART1_N" - assert float(inst.group[0].measureScore.value) == float(0) - assert inst.group[0].stratifier[0].code[0].coding[0].code == "AGE_GROUP:SEX" - assert float(inst.group[0].stratifier[0].stratum[0].measureScore.value) == float(0) - assert inst.group[0].stratifier[0].stratum[0].value.coding[0].code == "P0Y--P1Y:F" - assert float(inst.group[0].stratifier[0].stratum[1].measureScore.value) == float(0) - assert inst.group[0].stratifier[0].stratum[1].value.coding[0].code == "P0Y--P1Y:M" - assert float(inst.group[0].stratifier[0].stratum[2].measureScore.value) == float(0) - assert inst.group[0].stratifier[0].stratum[2].value.coding[0].code == "P1Y--P5Y:F" - assert float(inst.group[0].stratifier[0].stratum[3].measureScore.value) == float(0) - assert inst.group[0].stratifier[0].stratum[3].value.coding[0].code == "P1Y--P5Y:M" - assert float(inst.group[0].stratifier[0].stratum[4].measureScore.value) == float(0) - assert inst.group[0].stratifier[0].stratum[4].value.coding[0].code == "P10Y--P15Y:F" - assert float(inst.group[0].stratifier[0].stratum[5].measureScore.value) == float(0) - assert inst.group[0].stratifier[0].stratum[5].value.coding[0].code == "P10Y--P15Y:M" - assert inst.group[1].code.coding[0].code == "QRPH_ADX_ART1_N" - assert float(inst.group[1].measureScore.value) == float(0) - assert inst.group[1].stratifier[0].code[0].coding[0].code == "AGE_GROUP:SEX" - assert float(inst.group[1].stratifier[0].stratum[0].measureScore.value) == float(0) - assert inst.group[1].stratifier[0].stratum[0].value.coding[0].code == "P0Y--P1Y:F" - assert float(inst.group[1].stratifier[0].stratum[1].measureScore.value) == float(0) - assert inst.group[1].stratifier[0].stratum[1].value.coding[0].code == "P0Y--P1Y:M" - assert float(inst.group[1].stratifier[0].stratum[2].measureScore.value) == float(0) - assert inst.group[1].stratifier[0].stratum[2].value.coding[0].code == "P1Y--P5Y:F" - assert float(inst.group[1].stratifier[0].stratum[3].measureScore.value) == float(0) - assert inst.group[1].stratifier[0].stratum[3].value.coding[0].code == "P1Y--P5Y:M" - assert float(inst.group[1].stratifier[0].stratum[4].measureScore.value) == float(0) - assert inst.group[1].stratifier[0].stratum[4].value.coding[0].code == "P10Y--P15Y:F" - assert float(inst.group[1].stratifier[0].stratum[5].measureScore.value) == float(0) - assert inst.group[1].stratifier[0].stratum[5].value.coding[0].code == "P10Y--P15Y:M" - assert inst.group[2].code.coding[0].code == "QRPH_ADX_ART1_N" - assert float(inst.group[2].measureScore.value) == float(0) - assert inst.group[2].stratifier[0].code[0].coding[0].code == "AGE_GROUP" - assert inst.group[2].stratifier[0].code[1].coding[0].code == "SEX" - assert ( - inst.group[2].stratifier[0].stratum[0].component[0].code.coding[0].code - == "AGE_GROUP" - ) - assert ( - inst.group[2].stratifier[0].stratum[0].component[0].value.coding[0].code - == "P0Y--P1Y" - ) - assert ( - inst.group[2].stratifier[0].stratum[0].component[1].code.coding[0].code == "SEX" - ) - assert ( - inst.group[2].stratifier[0].stratum[0].component[1].value.coding[0].code == "F" - ) - assert float(inst.group[2].stratifier[0].stratum[0].measureScore.value) == float(0) - assert ( - inst.group[2].stratifier[0].stratum[1].component[0].code.coding[0].code - == "AGE_GROUP" - ) - assert ( - inst.group[2].stratifier[0].stratum[1].component[0].value.coding[0].code - == "P0Y--P1Y" - ) - assert ( - inst.group[2].stratifier[0].stratum[1].component[1].code.coding[0].code == "SEX" - ) - assert ( - inst.group[2].stratifier[0].stratum[1].component[1].value.coding[0].code == "M" - ) - assert float(inst.group[2].stratifier[0].stratum[1].measureScore.value) == float(0) - assert ( - inst.group[2].stratifier[0].stratum[2].component[0].code.coding[0].code - == "AGE_GROUP" - ) - assert ( - inst.group[2].stratifier[0].stratum[2].component[0].value.coding[0].code - == "P1Y--P5Y" - ) - assert ( - inst.group[2].stratifier[0].stratum[2].component[1].code.coding[0].code == "SEX" - ) - assert ( - inst.group[2].stratifier[0].stratum[2].component[1].value.coding[0].code == "F" - ) - assert float(inst.group[2].stratifier[0].stratum[2].measureScore.value) == float(0) - assert ( - inst.group[2].stratifier[0].stratum[3].component[0].code.coding[0].code - == "AGE_GROUP" - ) - assert ( - inst.group[2].stratifier[0].stratum[3].component[0].value.coding[0].code - == "P1Y--P5Y" - ) - assert ( - inst.group[2].stratifier[0].stratum[3].component[1].code.coding[0].code == "SEX" - ) - assert ( - inst.group[2].stratifier[0].stratum[3].component[1].value.coding[0].code == "F" - ) - assert float(inst.group[2].stratifier[0].stratum[3].measureScore.value) == float(0) - assert inst.id == "hiv-indicators" - assert inst.measure == "http://ohie.org/Measure/hiv-indicators" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2018-01-31T11:15:33+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2018-01-01T11:15:33+10:00") - assert inst.reporter.reference == "Organization/ZW01" - assert inst.status == "complete" - assert inst.text.status == "generated" - assert inst.type == "summary" - - -def test_measurereport_3(base_settings): - """No. 3 tests collection for MeasureReport. - Test File: measurereport-hiv-indicators.json - """ - filename = base_settings["unittest_data_dir"] / "measurereport-hiv-indicators.json" - inst = measurereport.MeasureReport.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MeasureReport" == inst.resource_type - - impl_measurereport_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MeasureReport" == data["resourceType"] - - inst2 = measurereport.MeasureReport(**data) - impl_measurereport_3(inst2) - - -def impl_measurereport_4(inst): - assert inst.contained[0].id == "reporter" - assert inst.date == fhirtypes.DateTime.validate("2014-04-01T11:15:33+10:00") - assert inst.group[0].id == "CMS146-group-1" - assert inst.group[0].population[0].code.coding[0].code == "initial-population" - assert inst.group[0].population[0].count == 500 - assert inst.group[0].population[1].code.coding[0].code == "numerator" - assert inst.group[0].population[1].count == 200 - assert inst.group[0].population[2].code.coding[0].code == "denominator" - assert inst.group[0].population[2].count == 500 - assert inst.group[0].population[3].code.coding[0].code == "denominator-exclusion" - assert inst.group[0].population[3].count == 100 - assert inst.group[0].stratifier[0].code[0].text == "stratifier-ages-up-to-9" - assert ( - inst.group[0].stratifier[0].stratum[0].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[0].stratum[0].population[0].count == 250 - assert ( - inst.group[0].stratifier[0].stratum[0].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[0].stratum[0].population[1].count == 100 - assert ( - inst.group[0].stratifier[0].stratum[0].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[0].stratum[0].population[2].count == 250 - assert ( - inst.group[0].stratifier[0].stratum[0].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[0].stratum[0].population[3].count == 50 - assert inst.group[0].stratifier[0].stratum[0].value.text == "true" - assert ( - inst.group[0].stratifier[0].stratum[1].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[0].stratum[1].population[0].count == 250 - assert ( - inst.group[0].stratifier[0].stratum[1].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[0].stratum[1].population[1].count == 100 - assert ( - inst.group[0].stratifier[0].stratum[1].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[0].stratum[1].population[2].count == 250 - assert ( - inst.group[0].stratifier[0].stratum[1].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[0].stratum[1].population[3].count == 50 - assert inst.group[0].stratifier[0].stratum[1].value.text == "false" - assert inst.group[0].stratifier[1].code[0].text == "stratifier-ages-10-plus" - assert ( - inst.group[0].stratifier[1].stratum[0].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[1].stratum[0].population[0].count == 250 - assert ( - inst.group[0].stratifier[1].stratum[0].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[1].stratum[0].population[1].count == 100 - assert ( - inst.group[0].stratifier[1].stratum[0].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[1].stratum[0].population[2].count == 250 - assert ( - inst.group[0].stratifier[1].stratum[0].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[1].stratum[0].population[3].count == 50 - assert inst.group[0].stratifier[1].stratum[0].value.text == "true" - assert ( - inst.group[0].stratifier[1].stratum[1].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[1].stratum[1].population[0].count == 250 - assert ( - inst.group[0].stratifier[1].stratum[1].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[1].stratum[1].population[1].count == 100 - assert ( - inst.group[0].stratifier[1].stratum[1].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[1].stratum[1].population[2].count == 250 - assert ( - inst.group[0].stratifier[1].stratum[1].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[1].stratum[1].population[3].count == 50 - assert inst.group[0].stratifier[1].stratum[1].value.text == "false" - assert inst.group[0].stratifier[2].code[0].text == "stratifier-gender" - assert ( - inst.group[0].stratifier[2].stratum[0].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[0].population[0].count == 250 - assert ( - inst.group[0].stratifier[2].stratum[0].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[0].population[1].count == 100 - assert ( - inst.group[0].stratifier[2].stratum[0].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[0].population[2].count == 250 - assert ( - inst.group[0].stratifier[2].stratum[0].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[2].stratum[0].population[3].count == 50 - assert inst.group[0].stratifier[2].stratum[0].value.text == "male" - assert ( - inst.group[0].stratifier[2].stratum[1].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[1].population[0].count == 250 - assert ( - inst.group[0].stratifier[2].stratum[1].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[1].population[1].count == 100 - assert ( - inst.group[0].stratifier[2].stratum[1].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[1].population[2].count == 250 - assert ( - inst.group[0].stratifier[2].stratum[1].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[2].stratum[1].population[3].count == 50 - assert inst.group[0].stratifier[2].stratum[1].value.text == "female" - assert ( - inst.group[0].stratifier[2].stratum[2].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[2].population[0].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[2].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[2].population[1].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[2].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[2].population[2].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[2].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[2].stratum[2].population[3].count == 0 - assert inst.group[0].stratifier[2].stratum[2].value.text == "other" - assert ( - inst.group[0].stratifier[2].stratum[3].population[0].code.coding[0].code - == "initial-population" - ) - assert inst.group[0].stratifier[2].stratum[3].population[0].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[3].population[1].code.coding[0].code - == "numerator" - ) - assert inst.group[0].stratifier[2].stratum[3].population[1].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[3].population[2].code.coding[0].code - == "denominator" - ) - assert inst.group[0].stratifier[2].stratum[3].population[2].count == 0 - assert ( - inst.group[0].stratifier[2].stratum[3].population[3].code.coding[0].code - == "denominator-exclusion" - ) - assert inst.group[0].stratifier[2].stratum[3].population[3].count == 0 - assert inst.group[0].stratifier[2].stratum[3].value.text == "unknown" - assert inst.id == "measurereport-cms146-cat3-example" - assert inst.identifier[0].value == "measurereport-cms146-cat3-example-2017-03-13" - assert inst.measure == "Measure/CMS146" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2014-03-31T11:15:33+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2014-01-01T11:15:33+10:00") - assert inst.reporter.reference == "#reporter" - assert inst.status == "complete" - assert inst.text.status == "generated" - assert inst.type == "summary" - - -def test_measurereport_4(base_settings): - """No. 4 tests collection for MeasureReport. - Test File: measurereport-cms146-cat3-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "measurereport-cms146-cat3-example.json" - ) - inst = measurereport.MeasureReport.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MeasureReport" == inst.resource_type - - impl_measurereport_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MeasureReport" == data["resourceType"] - - inst2 = measurereport.MeasureReport(**data) - impl_measurereport_4(inst2) diff --git a/fhir/resources/tests/test_media.py b/fhir/resources/tests/test_media.py deleted file mode 100644 index 2e1ec4b6..00000000 --- a/fhir/resources/tests/test_media.py +++ /dev/null @@ -1,238 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Media -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import media - - -def impl_media_1(inst): - assert inst.content.contentType == "image/gif" - assert inst.content.creation == fhirtypes.DateTime.validate( - "2009-09-03T11:15:33+10:00" - ) - assert inst.content.id == "a1" - assert inst.createdDateTime == fhirtypes.DateTime.validate( - "2017-12-17T11:15:33+10:00" - ) - assert inst.device.display == "Acme Camera" - assert inst.frames == 1 - assert inst.height == 145 - assert inst.id == "example" - assert inst.issued == fhirtypes.Instant.validate("2017-12-17T14:56:18Z") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.modality.coding[0].code == "diagram" - assert ( - inst.modality.coding[0].system - == "http://terminology.hl7.org/CodeSystem/media-modality" - ) - assert inst.operator.reference == "Practitioner/xcda-author" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/xcda" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "image" - assert inst.type.coding[0].display == "Image" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/media-type" - ) - assert inst.width == 126 - - -def test_media_1(base_settings): - """No. 1 tests collection for Media. - Test File: media-example.json - """ - filename = base_settings["unittest_data_dir"] / "media-example.json" - inst = media.Media.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Media" == inst.resource_type - - impl_media_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Media" == data["resourceType"] - - inst2 = media.Media(**data) - impl_media_1(inst2) - - -def impl_media_2(inst): - assert inst.content.contentType == "application/dicom" - assert inst.device.display == "G.E. Medical Systems" - assert inst.extension[0].url == "http://nema.org/fhir/extensions#0002-0010" - assert inst.extension[0].valueUri == "urn:oid:1.2.840.10008.1.2.1" - assert inst.height == 480 - assert inst.id == "1.2.840.11361907579238403408700.3.1.04.19970327150033" - assert inst.identifier[0].system == "urn:dicom:uid" - assert inst.identifier[0].type.text == "InstanceUID" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == ( - "urn:oid:1.2.840.11361907579238403408700.3.1.04.1997032715003" "3" - ) - assert inst.identifier[1].system == "http://acme-imaging.com/accession/2012" - assert inst.identifier[1].type.text == "accessionNo" - assert inst.identifier[1].value == "1234567" - assert inst.identifier[2].system == "urn:dicom:uid" - assert inst.identifier[2].type.text == "studyId" - assert ( - inst.identifier[2].value - == "urn:oid:1.2.840.113619.2.21.848.34082.0.538976288.3" - ) - assert inst.identifier[3].system == "urn:dicom:uid" - assert inst.identifier[3].type.text == "seriesId" - assert ( - inst.identifier[3].value - == "urn:oid:1.2.840.113619.2.21.3408.700.0.757923840.3.0" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.modality.coding[0].code == "US" - assert ( - inst.modality.coding[0].system == "http://dicom.nema.org/resources/ontology/DCM" - ) - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - assert inst.view.coding[0].code == "399067008" - assert inst.view.coding[0].display == "Lateral projection" - assert inst.view.coding[0].system == "http://snomed.info/sct" - assert inst.width == 640 - - -def test_media_2(base_settings): - """No. 2 tests collection for Media. - Test File: media-example-dicom.json - """ - filename = base_settings["unittest_data_dir"] / "media-example-dicom.json" - inst = media.Media.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Media" == inst.resource_type - - impl_media_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Media" == data["resourceType"] - - inst2 = media.Media(**data) - impl_media_2(inst2) - - -def impl_media_3(inst): - assert inst.basedOn[0].identifier.assigner.display == "XYZ Medical Clinic" - assert ( - inst.basedOn[0].identifier.system - == "http://someclinic.org/fhir/NamingSystem/imaging-orders" - ) - assert inst.basedOn[0].identifier.value == "111222" - assert inst.bodySite.coding[0].code == "85151006" - assert inst.bodySite.coding[0].display == "Structure of left hand (body structure)" - assert inst.bodySite.coding[0].system == "http://snomed.info/sct" - assert inst.content.contentType == "image/jpeg" - assert inst.content.creation == fhirtypes.DateTime.validate( - "2016-03-15T11:15:33+10:00" - ) - assert inst.content.id == "a1" - assert inst.content.url == "http://someimagingcenter.org/fhir/Binary/A12345" - assert inst.createdDateTime == fhirtypes.DateTime.validate( - "2016-03-15T11:15:33+10:00" - ) - assert inst.encounter.reference == "Encounter/example" - assert inst.height == 432 - assert inst.id == "xray" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.modality.coding[0].code == "39714003" - assert inst.modality.coding[0].display == "Skeletal X-ray of wrist and hand" - assert inst.modality.coding[0].system == "http://snomed.info/sct" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Xray of left ' - "hand for Patient Henry Levin (MRN 12345) 2016-03-15
" - ) - assert inst.text.status == "generated" - assert inst.width == 640 - - -def test_media_3(base_settings): - """No. 3 tests collection for Media. - Test File: media-example-xray.json - """ - filename = base_settings["unittest_data_dir"] / "media-example-xray.json" - inst = media.Media.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Media" == inst.resource_type - - impl_media_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Media" == data["resourceType"] - - inst2 = media.Media(**data) - impl_media_3(inst2) - - -def impl_media_4(inst): - assert inst.content.contentType == "audio/mpeg" - assert inst.content.data == bytes_validator( - "dG9vIGJpZyB0b28gaW5jbHVkZSB0aGUgd2hvbGU=" - ) - assert inst.content.id == "a1" - assert float(inst.duration) == float(65) - assert inst.id == "sound" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.operator.reference == "Practitioner/xcda-author" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/xcda" - assert inst.text.div == ( - '
Sound recording ' - "of speech example for Patient Henry Levin (MRN " - '12345):
diagram
' - ) - assert inst.text.status == "generated" - - -def test_media_4(base_settings): - """No. 4 tests collection for Media. - Test File: media-example-sound.json - """ - filename = base_settings["unittest_data_dir"] / "media-example-sound.json" - inst = media.Media.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Media" == inst.resource_type - - impl_media_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Media" == data["resourceType"] - - inst2 = media.Media(**data) - impl_media_4(inst2) diff --git a/fhir/resources/tests/test_medication.py b/fhir/resources/tests/test_medication.py deleted file mode 100644 index d1aebc2b..00000000 --- a/fhir/resources/tests/test_medication.py +++ /dev/null @@ -1,512 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Medication -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medication - - -def impl_medication_1(inst): - assert inst.batch.expirationDate == fhirtypes.DateTime.validate( - "2019-10-31T11:15:33+10:00" - ) - assert inst.batch.lotNumber == "12345" - assert inst.code.coding[0].code == "0169-7501-11" - assert inst.code.coding[0].display == "Novolog 100u/ml" - assert inst.code.coding[0].system == "http://hl7.org/fhir/sid/ndc" - assert inst.contained[0].id == "org3" - assert inst.form.coding[0].code == "385219001" - assert inst.form.coding[0].display == "Injection solution (qualifier value)" - assert inst.form.coding[0].system == "http://snomed.info/sct" - assert inst.id == "med0307" - assert inst.ingredient[0].itemCodeableConcept.coding[0].code == "325072002" - assert ( - inst.ingredient[0].itemCodeableConcept.coding[0].display - == "Insulin Aspart (substance)" - ) - assert ( - inst.ingredient[0].itemCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.ingredient[0].strength.denominator.code == "mL" - assert inst.ingredient[0].strength.denominator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[0].strength.denominator.value) == float(1) - assert inst.ingredient[0].strength.numerator.code == "U" - assert inst.ingredient[0].strength.numerator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[0].strength.numerator.value) == float(100) - assert inst.manufacturer.reference == "#org3" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medication_1(base_settings): - """No. 1 tests collection for Medication. - Test File: medicationexample0307.json - """ - filename = base_settings["unittest_data_dir"] / "medicationexample0307.json" - inst = medication.Medication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Medication" == inst.resource_type - - impl_medication_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Medication" == data["resourceType"] - - inst2 = medication.Medication(**data) - impl_medication_1(inst2) - - -def impl_medication_2(inst): - assert inst.code.coding[0].code == "373994007" - assert inst.code.coding[0].display == "Prednisone 5mg tablet (Product)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.contained[0].id == "sub03" - assert inst.form.coding[0].code == "385055001" - assert inst.form.coding[0].display == "Tablet dose form (qualifier value)" - assert inst.form.coding[0].system == "http://snomed.info/sct" - assert inst.id == "med0311" - assert inst.ingredient[0].itemReference.reference == "#sub03" - assert inst.ingredient[0].strength.denominator.code == "TAB" - assert ( - inst.ingredient[0].strength.denominator.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert float(inst.ingredient[0].strength.denominator.value) == float(1) - assert inst.ingredient[0].strength.numerator.code == "mg" - assert inst.ingredient[0].strength.numerator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[0].strength.numerator.value) == float(5) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medication_2(base_settings): - """No. 2 tests collection for Medication. - Test File: medicationexample0311.json - """ - filename = base_settings["unittest_data_dir"] / "medicationexample0311.json" - inst = medication.Medication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Medication" == inst.resource_type - - impl_medication_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Medication" == data["resourceType"] - - inst2 = medication.Medication(**data) - impl_medication_2(inst2) - - -def impl_medication_3(inst): - assert inst.code.coding[0].code == "430127000" - assert inst.code.coding[0].display == "Oral Form Oxycodone (product)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.contained[0].id == "sub03" - assert inst.form.coding[0].code == "385055001" - assert inst.form.coding[0].display == "Tablet dose form (qualifier value)" - assert inst.form.coding[0].system == "http://snomed.info/sct" - assert inst.id == "med0310" - assert inst.ingredient[0].itemReference.reference == "#sub03" - assert inst.ingredient[0].strength.denominator.code == "TAB" - assert ( - inst.ingredient[0].strength.denominator.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert float(inst.ingredient[0].strength.denominator.value) == float(1) - assert inst.ingredient[0].strength.numerator.code == "mg" - assert inst.ingredient[0].strength.numerator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[0].strength.numerator.value) == float(5) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medication_3(base_settings): - """No. 3 tests collection for Medication. - Test File: medicationexample0310.json - """ - filename = base_settings["unittest_data_dir"] / "medicationexample0310.json" - inst = medication.Medication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Medication" == inst.resource_type - - impl_medication_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Medication" == data["resourceType"] - - inst2 = medication.Medication(**data) - impl_medication_3(inst2) - - -def impl_medication_4(inst): - assert inst.batch.expirationDate == fhirtypes.DateTime.validate( - "2019-10-31T11:15:33+10:00" - ) - assert inst.batch.lotNumber == "12345" - assert inst.code.coding[0].code == "51144-050-01" - assert inst.code.coding[0].display == "Adcetris" - assert inst.code.coding[0].system == "http://hl7.org/fhir/sid/ndc" - assert inst.contained[0].id == "org3" - assert inst.form.coding[0].code == "421637006" - assert inst.form.coding[0].display == ( - "Lyophilized powder for injectable solution (qualifier value)" " " - ) - assert inst.form.coding[0].system == "http://snomed.info/sct" - assert inst.id == "med0306" - assert inst.manufacturer.reference == "#org3" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medication_4(base_settings): - """No. 4 tests collection for Medication. - Test File: medicationexample0306.json - """ - filename = base_settings["unittest_data_dir"] / "medicationexample0306.json" - inst = medication.Medication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Medication" == inst.resource_type - - impl_medication_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Medication" == data["resourceType"] - - inst2 = medication.Medication(**data) - impl_medication_4(inst2) - - -def impl_medication_5(inst): - assert inst.batch.expirationDate == fhirtypes.DateTime.validate( - "2017-05-22T11:15:33+10:00" - ) - assert inst.batch.lotNumber == "9494788" - assert inst.code.coding[0].code == "0069-2587-10" - assert ( - inst.code.coding[0].display - == "Vancomycin Hydrochloride (VANCOMYCIN HYDROCHLORIDE)" - ) - assert inst.code.coding[0].system == "http://hl7.org/fhir/sid/ndc" - assert inst.contained[0].id == "org4" - assert inst.form.coding[0].code == "385219001" - assert inst.form.coding[0].display == "Injection Solution (qualifier value)" - assert inst.form.coding[0].system == "http://snomed.info/sct" - assert inst.id == "med0301" - assert inst.ingredient[0].isActive is True - assert inst.ingredient[0].itemCodeableConcept.coding[0].code == "66955" - assert ( - inst.ingredient[0].itemCodeableConcept.coding[0].display - == "Vancomycin Hydrochloride" - ) - assert ( - inst.ingredient[0].itemCodeableConcept.coding[0].system - == "http://www.nlm.nih.gov/research/umls/rxnorm" - ) - assert inst.ingredient[0].strength.denominator.code == "mL" - assert inst.ingredient[0].strength.denominator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[0].strength.denominator.value) == float(10) - assert inst.ingredient[0].strength.numerator.code == "mg" - assert inst.ingredient[0].strength.numerator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[0].strength.numerator.value) == float(500) - assert inst.manufacturer.reference == "#org4" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_medication_5(base_settings): - """No. 5 tests collection for Medication. - Test File: medicationexample0301.json - """ - filename = base_settings["unittest_data_dir"] / "medicationexample0301.json" - inst = medication.Medication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Medication" == inst.resource_type - - impl_medication_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Medication" == data["resourceType"] - - inst2 = medication.Medication(**data) - impl_medication_5(inst2) - - -def impl_medication_6(inst): - assert inst.form.coding[0].code == "385219001" - assert inst.form.coding[0].display == "Injection Solution (qualifier value)" - assert inst.form.coding[0].system == "http://snomed.info/sct" - assert inst.form.text == "Injection Solution (qualifier value)" - assert inst.id == "med0317" - assert inst.ingredient[0].itemCodeableConcept.coding[0].code == "204520" - assert ( - inst.ingredient[0].itemCodeableConcept.coding[0].display == "Potassium Chloride" - ) - assert ( - inst.ingredient[0].itemCodeableConcept.coding[0].system - == "http://www.nlm.nih.gov/research/umls/rxnorm" - ) - assert inst.ingredient[0].strength.denominator.code == "mL" - assert inst.ingredient[0].strength.denominator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[0].strength.denominator.value) == float(1) - assert inst.ingredient[0].strength.numerator.code == "meq" - assert inst.ingredient[0].strength.numerator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[0].strength.numerator.value) == float(2) - assert inst.ingredient[1].itemCodeableConcept.coding[0].code == "313002" - assert ( - inst.ingredient[1].itemCodeableConcept.coding[0].display - == "Sodium Chloride 0.9% injectable solution" - ) - assert ( - inst.ingredient[1].itemCodeableConcept.coding[0].system - == "http://www.nlm.nih.gov/research/umls/rxnorm" - ) - assert inst.ingredient[1].strength.denominator.code == "mL" - assert inst.ingredient[1].strength.denominator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[1].strength.denominator.value) == float(100) - assert inst.ingredient[1].strength.numerator.code == "g" - assert inst.ingredient[1].strength.numerator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[1].strength.numerator.value) == float(0.9) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medication_6(base_settings): - """No. 6 tests collection for Medication. - Test File: medicationexample0317.json - """ - filename = base_settings["unittest_data_dir"] / "medicationexample0317.json" - inst = medication.Medication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Medication" == inst.resource_type - - impl_medication_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Medication" == data["resourceType"] - - inst2 = medication.Medication(**data) - impl_medication_6(inst2) - - -def impl_medication_7(inst): - assert inst.code.text == "Amoxicillin 250mg/5ml Suspension" - assert inst.id == "medicationexample1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.div == ( - '
Amoxicillin ' - "250mg/5ml Suspension
" - ) - assert inst.text.status == "generated" - - -def test_medication_7(base_settings): - """No. 7 tests collection for Medication. - Test File: medicationexample1.json - """ - filename = base_settings["unittest_data_dir"] / "medicationexample1.json" - inst = medication.Medication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Medication" == inst.resource_type - - impl_medication_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Medication" == data["resourceType"] - - inst2 = medication.Medication(**data) - impl_medication_7(inst2) - - -def impl_medication_8(inst): - assert inst.batch.expirationDate == fhirtypes.DateTime.validate( - "2017-05-22T11:15:33+10:00" - ) - assert inst.batch.lotNumber == "9494788" - assert inst.code.coding[0].code == "213293" - assert inst.code.coding[0].display == "Capecitabine 500mg oral tablet (Xeloda)" - assert inst.code.coding[0].system == "http://www.nlm.nih.gov/research/umls/rxnorm" - assert inst.contained[0].id == "org2" - assert inst.contained[1].id == "sub04" - assert inst.form.coding[0].code == "385055001" - assert inst.form.coding[0].display == "Tablet dose form (qualifier value)" - assert inst.form.coding[0].system == "http://snomed.info/sct" - assert inst.id == "medexample015" - assert inst.ingredient[0].itemReference.reference == "#sub04" - assert inst.ingredient[0].strength.denominator.code == "TAB" - assert ( - inst.ingredient[0].strength.denominator.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert float(inst.ingredient[0].strength.denominator.value) == float(1) - assert inst.ingredient[0].strength.numerator.code == "mg" - assert inst.ingredient[0].strength.numerator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[0].strength.numerator.value) == float(500) - assert inst.manufacturer.reference == "#org2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medication_8(base_settings): - """No. 8 tests collection for Medication. - Test File: medicationexample15.json - """ - filename = base_settings["unittest_data_dir"] / "medicationexample15.json" - inst = medication.Medication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Medication" == inst.resource_type - - impl_medication_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Medication" == data["resourceType"] - - inst2 = medication.Medication(**data) - impl_medication_8(inst2) - - -def impl_medication_9(inst): - assert inst.code.coding[0].code == "108761006" - assert inst.code.coding[0].display == "Capecitabine (product)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.contained[0].id == "sub03" - assert inst.form.coding[0].code == "385055001" - assert inst.form.coding[0].display == "Tablet dose form (qualifier value)" - assert inst.form.coding[0].system == "http://snomed.info/sct" - assert inst.id == "med0321" - assert inst.ingredient[0].itemReference.reference == "#sub03" - assert inst.ingredient[0].strength.denominator.code == "385055001" - assert inst.ingredient[0].strength.denominator.system == "http://snomed.info/sct" - assert inst.ingredient[0].strength.denominator.unit == "Tablet" - assert float(inst.ingredient[0].strength.denominator.value) == float(1) - assert inst.ingredient[0].strength.numerator.code == "mg" - assert inst.ingredient[0].strength.numerator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[0].strength.numerator.value) == float(500) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medication_9(base_settings): - """No. 9 tests collection for Medication. - Test File: medicationexample0321.json - """ - filename = base_settings["unittest_data_dir"] / "medicationexample0321.json" - inst = medication.Medication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Medication" == inst.resource_type - - impl_medication_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Medication" == data["resourceType"] - - inst2 = medication.Medication(**data) - impl_medication_9(inst2) - - -def impl_medication_10(inst): - assert inst.code.coding[0].code == "324252006" - assert inst.code.coding[0].display == "Azithromycin 250mg capsule (product)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.contained[0].id == "sub03" - assert inst.form.coding[0].code == "385055001" - assert inst.form.coding[0].display == "Tablet dose form (qualifier value)" - assert inst.form.coding[0].system == "http://snomed.info/sct" - assert inst.id == "med0320" - assert inst.ingredient[0].itemReference.reference == "#sub03" - assert inst.ingredient[0].strength.denominator.code == "TAB" - assert ( - inst.ingredient[0].strength.denominator.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert float(inst.ingredient[0].strength.denominator.value) == float(1) - assert inst.ingredient[0].strength.numerator.code == "mg" - assert inst.ingredient[0].strength.numerator.system == "http://unitsofmeasure.org" - assert float(inst.ingredient[0].strength.numerator.value) == float(250) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medication_10(base_settings): - """No. 10 tests collection for Medication. - Test File: medicationexample0320.json - """ - filename = base_settings["unittest_data_dir"] / "medicationexample0320.json" - inst = medication.Medication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Medication" == inst.resource_type - - impl_medication_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Medication" == data["resourceType"] - - inst2 = medication.Medication(**data) - impl_medication_10(inst2) diff --git a/fhir/resources/tests/test_medicationadministration.py b/fhir/resources/tests/test_medicationadministration.py deleted file mode 100644 index 900b8566..00000000 --- a/fhir/resources/tests/test_medicationadministration.py +++ /dev/null @@ -1,654 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicationAdministration -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicationadministration - - -def impl_medicationadministration_1(inst): - assert inst.contained[0].id == "med0301" - assert inst.contained[1].id == "signature" - assert inst.context.display == "encounter who leads to this prescription" - assert inst.context.reference == "Encounter/f001" - assert inst.dosage.dose.code == "mg" - assert inst.dosage.dose.system == "http://unitsofmeasure.org" - assert inst.dosage.dose.unit == "mg" - assert float(inst.dosage.dose.value) == float(500) - assert inst.dosage.method.text == "IV Push" - assert inst.dosage.route.coding[0].code == "47625008" - assert inst.dosage.route.coding[0].display == "Intravenous route (qualifier value)" - assert inst.dosage.route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.text == "500mg IV q6h x 3 days" - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T14:30:00+01:00" - ) - assert inst.eventHistory[0].display == "Author's Signature" - assert inst.eventHistory[0].reference == "#signature" - assert inst.id == "medadmin0301" - assert inst.medicationReference.reference == "#med0301" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.display == "Patrick Pump" - assert inst.performer[0].actor.reference == "Practitioner/f007" - assert inst.reasonCode[0].coding[0].code == "b" - assert inst.reasonCode[0].coding[0].display == "Given as Ordered" - assert inst.reasonCode[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/reason-medication-" "given" - ) - assert inst.request.reference == "MedicationRequest/medrx0318" - assert inst.status == "in-progress" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationadministration_1(base_settings): - """No. 1 tests collection for MedicationAdministration. - Test File: medicationadministration0301.json - """ - filename = base_settings["unittest_data_dir"] / "medicationadministration0301.json" - inst = medicationadministration.MedicationAdministration.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationAdministration" == inst.resource_type - - impl_medicationadministration_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationAdministration" == data["resourceType"] - - inst2 = medicationadministration.MedicationAdministration(**data) - impl_medicationadministration_1(inst2) - - -def impl_medicationadministration_2(inst): - assert inst.contained[0].id == "med0303" - assert inst.context.reference == "Encounter/f001" - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2015-01-15T14:30:00+01:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T14:30:00+01:00" - ) - assert inst.id == "medadminexample03" - assert inst.medicationReference.reference == "#med0303" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == ( - "Patient started Bupropion this morning - will administer in " - "a reduced dose tomorrow" - ) - assert inst.request.reference == "MedicationRequest/medrx0317" - assert inst.status == "on-hold" - assert inst.statusReason[0].coding[0].code == "373147003" - assert inst.statusReason[0].coding[0].display == ( - "Administration of medication not done due to a " "contraindication (situation)" - ) - assert inst.statusReason[0].coding[0].system == "http://snomed.info/sct" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.supportingInformation[0].reference == "Condition/f204" - assert inst.text.status == "generated" - - -def test_medicationadministration_2(base_settings): - """No. 2 tests collection for MedicationAdministration. - Test File: medicationadministrationexample3.json - """ - filename = ( - base_settings["unittest_data_dir"] / "medicationadministrationexample3.json" - ) - inst = medicationadministration.MedicationAdministration.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationAdministration" == inst.resource_type - - impl_medicationadministration_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationAdministration" == data["resourceType"] - - inst2 = medicationadministration.MedicationAdministration(**data) - impl_medicationadministration_2(inst2) - - -def impl_medicationadministration_3(inst): - assert inst.contained[0].id == "med0313" - assert inst.context.display == "encounter who leads to this prescription" - assert inst.context.reference == "Encounter/f001" - assert inst.device[0].reference == "Device/f001" - assert inst.dosage.dose.code == "mg" - assert inst.dosage.dose.system == "http://unitsofmeasure.org" - assert inst.dosage.dose.unit == "mg" - assert float(inst.dosage.dose.value) == float(7) - assert inst.dosage.method.coding[0].code == "420620005" - assert ( - inst.dosage.method.coding[0].display - == "Push - dosing instruction imperative (qualifier value)" - ) - assert inst.dosage.method.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.rateQuantity.code == "min" - assert inst.dosage.rateQuantity.system == "http://unitsofmeasure.org" - assert inst.dosage.rateQuantity.unit == "min" - assert float(inst.dosage.rateQuantity.value) == float(4) - assert inst.dosage.route.coding[0].code == "255560000" - assert inst.dosage.route.coding[0].display == "Intravenous" - assert inst.dosage.route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.text == ( - "0.05 - 0.1mg/kg IV over 2-5 minutes every 15 minutes as " "needed" - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2015-01-15T14:30:00+01:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T04:30:00+01:00" - ) - assert inst.id == "medadmin0307" - assert inst.medicationReference.reference == "#med0313" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.display == "Patrick Pump" - assert inst.performer[0].actor.reference == "Practitioner/f007" - assert inst.performer[0].function.coding[0].code == "performer" - assert inst.performer[0].function.coding[0].display == "Performer" - assert inst.performer[0].function.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/med-admin-perform-" "function" - ) - assert inst.request.reference == "MedicationRequest/medrx0315" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationadministration_3(base_settings): - """No. 3 tests collection for MedicationAdministration. - Test File: medicationadministration0307.json - """ - filename = base_settings["unittest_data_dir"] / "medicationadministration0307.json" - inst = medicationadministration.MedicationAdministration.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationAdministration" == inst.resource_type - - impl_medicationadministration_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationAdministration" == data["resourceType"] - - inst2 = medicationadministration.MedicationAdministration(**data) - impl_medicationadministration_3(inst2) - - -def impl_medicationadministration_4(inst): - assert inst.contained[0].id == "med0304" - assert inst.dosage.dose.code == "TAB" - assert ( - inst.dosage.dose.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dosage.dose.unit == "TAB" - assert float(inst.dosage.dose.value) == float(1) - assert inst.dosage.route.coding[0].code == "26643006" - assert inst.dosage.route.coding[0].display == "Oral Route" - assert inst.dosage.route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.text == ( - "0.25mg PO every 6-12 hours as needed for menses from Jan " - "15-20, 2015. Do not exceed more than 4mg per day" - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2015-01-16T02:03:00+01:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T22:03:00+01:00" - ) - assert inst.id == "medadmin0311" - assert inst.medicationReference.reference == "#med0304" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.display == "Patrick Pump" - assert inst.performer[0].actor.reference == "Practitioner/f007" - assert inst.reasonCode[0].coding[0].code == "266599000" - assert inst.reasonCode[0].coding[0].display == "Dysmenorrhea" - assert inst.reasonCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.request.reference == "MedicationRequest/medrx0305" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationadministration_4(base_settings): - """No. 4 tests collection for MedicationAdministration. - Test File: medicationadministration0311.json - """ - filename = base_settings["unittest_data_dir"] / "medicationadministration0311.json" - inst = medicationadministration.MedicationAdministration.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationAdministration" == inst.resource_type - - impl_medicationadministration_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationAdministration" == data["resourceType"] - - inst2 = medicationadministration.MedicationAdministration(**data) - impl_medicationadministration_4(inst2) - - -def impl_medicationadministration_5(inst): - assert inst.contained[0].id == "med0304" - assert inst.dosage.dose.code == "mg" - assert inst.dosage.dose.system == "http://unitsofmeasure.org" - assert inst.dosage.dose.unit == "mg" - assert float(inst.dosage.dose.value) == float(6) - assert inst.dosage.route.coding[0].code == "26643006" - assert inst.dosage.route.coding[0].display == "Oral route (qualifier value)" - assert inst.dosage.route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.text == ( - "6 mg PO daily for remission induction; adjust dosage to " - "white blood cell (WBC) count. With hold treatment if WBC is" - " less than 15,000/µL; resume when WBC is greater than " - "50,000/µL" - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2015-01-16T02:03:00+01:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T22:03:00+01:00" - ) - assert inst.id == "medadmin0310" - assert inst.medicationReference.reference == "#med0304" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.display == "Patrick Pump" - assert inst.performer[0].actor.reference == "Practitioner/f007" - assert inst.request.reference == "MedicationRequest/medrx0306" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationadministration_5(base_settings): - """No. 5 tests collection for MedicationAdministration. - Test File: medicationadministration0310.json - """ - filename = base_settings["unittest_data_dir"] / "medicationadministration0310.json" - inst = medicationadministration.MedicationAdministration.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationAdministration" == inst.resource_type - - impl_medicationadministration_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationAdministration" == data["resourceType"] - - inst2 = medicationadministration.MedicationAdministration(**data) - impl_medicationadministration_5(inst2) - - -def impl_medicationadministration_6(inst): - assert inst.contained[0].id == "med0306" - assert inst.context.display == "encounter who leads to this prescription" - assert inst.context.reference == "Encounter/f001" - assert inst.dosage.dose.code == "TAB" - assert ( - inst.dosage.dose.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dosage.dose.unit == "TAB" - assert float(inst.dosage.dose.value) == float(2) - assert inst.dosage.method.coding[0].code == "421521009" - assert ( - inst.dosage.method.coding[0].display - == "Swallow - dosing instruction imperative (qualifier value)" - ) - assert inst.dosage.method.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.route.coding[0].code == "26643006" - assert inst.dosage.route.coding[0].display == "Oral Route" - assert inst.dosage.route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.text == "Two tablets at once" - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2015-01-15T14:30:00+01:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T04:30:00+01:00" - ) - assert inst.id == "medadmin0306" - assert inst.medicationReference.reference == "#med0306" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.display == "Patrick Pump" - assert inst.performer[0].actor.reference == "Practitioner/f007" - assert inst.performer[0].function.coding[0].code == "performer" - assert inst.performer[0].function.coding[0].display == "Performer" - assert inst.performer[0].function.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/med-admin-perform-" "function" - ) - assert inst.request.reference == "MedicationRequest/medrx0302" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationadministration_6(base_settings): - """No. 6 tests collection for MedicationAdministration. - Test File: medicationadministration0306.json - """ - filename = base_settings["unittest_data_dir"] / "medicationadministration0306.json" - inst = medicationadministration.MedicationAdministration.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationAdministration" == inst.resource_type - - impl_medicationadministration_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationAdministration" == data["resourceType"] - - inst2 = medicationadministration.MedicationAdministration(**data) - impl_medicationadministration_6(inst2) - - -def impl_medicationadministration_7(inst): - assert inst.contained[0].id == "med0318" - assert inst.device[0].reference == "Device/f001" - assert inst.dosage.dose.code == "mL" - assert inst.dosage.dose.system == "http://unitsofmeasure.org" - assert inst.dosage.dose.unit == "mL" - assert float(inst.dosage.dose.value) == float(1000) - assert inst.dosage.method.text == "PICC line" - assert inst.dosage.rateRatio.denominator.code == "h" - assert inst.dosage.rateRatio.denominator.system == "http://unitsofmeasure.org" - assert inst.dosage.rateRatio.denominator.unit == "h" - assert float(inst.dosage.rateRatio.denominator.value) == float(1) - assert inst.dosage.rateRatio.numerator.code == "mL" - assert inst.dosage.rateRatio.numerator.system == "http://unitsofmeasure.org" - assert inst.dosage.rateRatio.numerator.unit == "mL" - assert float(inst.dosage.rateRatio.numerator.value) == float(50) - assert inst.dosage.route.coding[0].code == "255560000" - assert inst.dosage.route.coding[0].display == "Intravenous" - assert inst.dosage.route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.site.coding[0].code == "6073002" - assert ( - inst.dosage.site.coding[0].display - == "Structure of ligament of left superior vena cava" - ) - assert inst.dosage.site.coding[0].system == "http://snomed.info/sct" - assert ( - inst.dosage.text - == "1000mL infused at 50ml/hour for 4 hours - hung at 2200 hours" - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2015-01-16T02:03:00+01:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T22:03:00+01:00" - ) - assert inst.id == "medadmin0309" - assert inst.medicationReference.reference == "#med0318" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.display == "Patrick Pump" - assert inst.performer[0].actor.reference == "Practitioner/f007" - assert inst.performer[0].function.coding[0].code == "performer" - assert inst.performer[0].function.coding[0].display == "Performer" - assert inst.performer[0].function.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/med-admin-perform-" "function" - ) - assert inst.request.reference == "MedicationRequest/medrx0323" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationadministration_7(base_settings): - """No. 7 tests collection for MedicationAdministration. - Test File: medicationadministration0309.json - """ - filename = base_settings["unittest_data_dir"] / "medicationadministration0309.json" - inst = medicationadministration.MedicationAdministration.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationAdministration" == inst.resource_type - - impl_medicationadministration_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationAdministration" == data["resourceType"] - - inst2 = medicationadministration.MedicationAdministration(**data) - impl_medicationadministration_7(inst2) - - -def impl_medicationadministration_8(inst): - assert inst.dosage.dose.code == "mg" - assert inst.dosage.dose.system == "http://unitsofmeasure.org" - assert inst.dosage.dose.unit == "mg" - assert float(inst.dosage.dose.value) == float(240) - assert inst.dosage.site.coding[0].code == "34402009" - assert inst.dosage.site.coding[0].display == "Rectum structure" - assert inst.dosage.site.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.text == ( - "Insert one suppository rectally twice daily as needed for " - "fever to a maximim of 3 per day" - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2015-01-16T02:03:00+01:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T22:03:00+01:00" - ) - assert inst.id == "medadmin0313" - assert inst.medicationCodeableConcept.coding[0].code == "322254008" - assert ( - inst.medicationCodeableConcept.coding[0].display - == "Paracetamol 240mg suppository (product)" - ) - assert inst.medicationCodeableConcept.coding[0].system == "http://snomed.info/sct" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.display == "Patrick Pump" - assert inst.performer[0].actor.reference == "Practitioner/f007" - assert inst.reasonCode[0].coding[0].code == "c" - assert inst.reasonCode[0].coding[0].display == "Emergency" - assert inst.reasonCode[0].coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/reason-medication-" "given" - ) - assert inst.request.reference == "MedicationRequest/medrx0324" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationadministration_8(base_settings): - """No. 8 tests collection for MedicationAdministration. - Test File: medicationadministration0313.json - """ - filename = base_settings["unittest_data_dir"] / "medicationadministration0313.json" - inst = medicationadministration.MedicationAdministration.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationAdministration" == inst.resource_type - - impl_medicationadministration_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationAdministration" == data["resourceType"] - - inst2 = medicationadministration.MedicationAdministration(**data) - impl_medicationadministration_8(inst2) - - -def impl_medicationadministration_9(inst): - assert inst.contained[0].id == "med0306" - assert inst.context.display == "encounter who leads to this prescription" - assert inst.context.reference == "Encounter/f001" - assert inst.dosage.dose.code == "mg/kg" - assert inst.dosage.dose.system == "http://unitsofmeasure.org" - assert inst.dosage.dose.unit == "mg/kg" - assert float(inst.dosage.dose.value) == float(1.8) - assert inst.dosage.rateQuantity.code == "min" - assert inst.dosage.rateQuantity.system == "http://unitsofmeasure.org" - assert inst.dosage.rateQuantity.unit == "min" - assert float(inst.dosage.rateQuantity.value) == float(20) - assert inst.dosage.route.coding[0].code == "255560000" - assert inst.dosage.route.coding[0].display == "Intravenous" - assert inst.dosage.route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.text == "1.8 mg/kg IV infusion over 30 minutes" - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2015-01-15T14:30:00+01:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T04:30:00+01:00" - ) - assert inst.id == "medadmin0305" - assert inst.instantiates[0] == ( - "http://www.bccancer.bc.ca/chemotherapy-protocols-" - "site/Documents/Lymphoma-" - "Myeloma/ULYBRENTUX%20Protocol_1Jun2017.pdf" - ) - assert inst.medicationReference.reference == "#med0306" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.display == "Patrick Pump" - assert inst.performer[0].actor.reference == "Practitioner/f007" - assert inst.request.reference == "MedicationRequest/medrx0316" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationadministration_9(base_settings): - """No. 9 tests collection for MedicationAdministration. - Test File: medicationadministration0305.json - """ - filename = base_settings["unittest_data_dir"] / "medicationadministration0305.json" - inst = medicationadministration.MedicationAdministration.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationAdministration" == inst.resource_type - - impl_medicationadministration_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationAdministration" == data["resourceType"] - - inst2 = medicationadministration.MedicationAdministration(**data) - impl_medicationadministration_9(inst2) - - -def impl_medicationadministration_10(inst): - assert inst.contained[0].id == "med0303" - assert inst.context.display == "encounter who leads to this prescription" - assert inst.context.reference == "Encounter/f001" - assert inst.dosage.dose.code == "mg" - assert inst.dosage.dose.system == "http://unitsofmeasure.org" - assert inst.dosage.dose.unit == "mg" - assert float(inst.dosage.dose.value) == float(3) - assert inst.dosage.method.coding[0].code == "422145002" - assert ( - inst.dosage.method.coding[0].display - == "Inject - dosing instruction imperative (qualifier value)" - ) - assert inst.dosage.method.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.route.coding[0].code == "47625008" - assert inst.dosage.route.coding[0].display == "Intravenous route (qualifier value)" - assert inst.dosage.route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage.text == ( - "Rapid daily-dose escalation, until tolerated, from 3 mg/d, " - "and then 10 mg/d, to the recommended maintenance dose of 30 " - "mg IV over 120 min, 3 times per wk on alternate days for up " - "to 12 wk" - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2015-01-15T14:30:00+01:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T04:30:00+01:00" - ) - assert inst.id == "medadmin0304" - assert inst.medicationReference.reference == "#med0303" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.display == "Patrick Pump" - assert inst.performer[0].actor.reference == "Practitioner/f007" - assert inst.reasonReference[0].reference == "Condition/f202" - assert inst.request.reference == "MedicationRequest/medrx0319" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationadministration_10(base_settings): - """No. 10 tests collection for MedicationAdministration. - Test File: medicationadministration0304.json - """ - filename = base_settings["unittest_data_dir"] / "medicationadministration0304.json" - inst = medicationadministration.MedicationAdministration.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationAdministration" == inst.resource_type - - impl_medicationadministration_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationAdministration" == data["resourceType"] - - inst2 = medicationadministration.MedicationAdministration(**data) - impl_medicationadministration_10(inst2) diff --git a/fhir/resources/tests/test_medicationdispense.py b/fhir/resources/tests/test_medicationdispense.py deleted file mode 100644 index ae32fc91..00000000 --- a/fhir/resources/tests/test_medicationdispense.py +++ /dev/null @@ -1,887 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicationDispense -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicationdispense - - -def impl_medicationdispense_1(inst): - assert inst.authorizingPrescription[0].reference == "MedicationRequest/medrx0316" - assert inst.contained[0].id == "med0306" - assert inst.daysSupply.code == "d" - assert inst.daysSupply.system == "http://unitsofmeasure.org" - assert inst.daysSupply.unit == "Day" - assert float(inst.daysSupply.value) == float(1) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "mg/kg" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "mg/kg" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 1.8 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].route.coding[0].code == "255560000" - assert inst.dosageInstruction[0].route.coding[0].display == "Intravenous" - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == ( - "1.8 mg/kg IV infusion over 30 minutes every 3 weeks for 16 " "cycles" - ) - assert inst.dosageInstruction[0].timing.repeat.count == 16 - assert inst.dosageInstruction[0].timing.repeat.frequency == 1 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(3) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "wk" - assert inst.id == "meddisp0317" - assert inst.medicationReference.display == "Brentixumab Vedotin (Adcetris)" - assert inst.medicationReference.reference == "#med0306" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.reference == "Practitioner/f006" - assert inst.quantity.code == "415818005" - assert inst.quantity.system == "http://snomed.info/sct" - assert float(inst.quantity.value) == float(3) - assert inst.status == "stopped" - assert inst.subject.display == "Donald Duck " - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "TF" - assert inst.type.coding[0].display == "Trial Fill" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.whenHandedOver == fhirtypes.DateTime.validate( - "2015-06-26T07:13:00+05:00" - ) - assert inst.whenPrepared == fhirtypes.DateTime.validate("2015-06-25T07:13:00+05:00") - - -def test_medicationdispense_1(base_settings): - """No. 1 tests collection for MedicationDispense. - Test File: medicationdispense0317.json - """ - filename = base_settings["unittest_data_dir"] / "medicationdispense0317.json" - inst = medicationdispense.MedicationDispense.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationDispense" == inst.resource_type - - impl_medicationdispense_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationDispense" == data["resourceType"] - - inst2 = medicationdispense.MedicationDispense(**data) - impl_medicationdispense_1(inst2) - - -def impl_medicationdispense_2(inst): - assert inst.authorizingPrescription[0].reference == "MedicationRequest/medrx0318" - assert inst.contained[0].id == "med0301" - assert inst.daysSupply.code == "d" - assert inst.daysSupply.system == "http://unitsofmeasure.org" - assert inst.daysSupply.unit == "Day" - assert float(inst.daysSupply.value) == float(3) - assert inst.destination.reference == "Location/ph" - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "mg" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "mg" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 500 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].method.coding[0].code == "420620005" - assert ( - inst.dosageInstruction[0].method.coding[0].display - == "Push - dosing instruction imperative (qualifier value)" - ) - assert inst.dosageInstruction[0].method.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].route.coding[0].code == "255560000" - assert inst.dosageInstruction[0].route.coding[0].display == "Intravenous" - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == "500mg IV q6h x 3 days" - assert inst.dosageInstruction[0].timing.repeat.frequency == 1 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(6) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "h" - assert inst.id == "meddisp0301" - assert inst.location.display == "Pharmacy" - assert inst.location.reference == "Location/ukp" - assert inst.medicationReference.display == "Vancomycin Hydrochloride" - assert inst.medicationReference.reference == "#med0301" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.reference == "Practitioner/f006" - assert inst.quantity.code == "Vial" - assert ( - inst.quantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.quantity.unit == "Vial" - assert float(inst.quantity.value) == float(12) - assert inst.receiver[0].display == "Donald Duck" - assert inst.receiver[0].reference == "Patient/pat1" - assert inst.status == "in-progress" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.supportingInformation[0].reference == "Condition/f203" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "EM" - assert inst.type.coding[0].display == "Emergency Supply" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.whenPrepared == fhirtypes.DateTime.validate("2015-01-15T10:20:00Z") - - -def test_medicationdispense_2(base_settings): - """No. 2 tests collection for MedicationDispense. - Test File: medicationdispense0301.json - """ - filename = base_settings["unittest_data_dir"] / "medicationdispense0301.json" - inst = medicationdispense.MedicationDispense.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationDispense" == inst.resource_type - - impl_medicationdispense_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationDispense" == data["resourceType"] - - inst2 = medicationdispense.MedicationDispense(**data) - impl_medicationdispense_2(inst2) - - -def impl_medicationdispense_3(inst): - assert inst.authorizingPrescription[0].reference == "MedicationRequest/medrx0321" - assert inst.daysSupply.code == "d" - assert inst.daysSupply.system == "http://unitsofmeasure.org" - assert inst.daysSupply.unit == "Day" - assert float(inst.daysSupply.value) == float(10) - assert ( - inst.dosageInstruction[0].additionalInstruction[0].coding[0].code == "418914006" - ) - assert inst.dosageInstruction[0].additionalInstruction[0].coding[0].display == ( - "Warning. May cause drowsiness. If affected do not drive or " - "operate machinery. Avoid alcoholic drink (qualifier value)" - ) - assert ( - inst.dosageInstruction[0].additionalInstruction[0].coding[0].system - == "http://snomed.info/sct" - ) - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].code == "203082005" - ) - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].display - == "Fibromyalgia (disorder)" - ) - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "TAB" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "TAB" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 1 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].route.coding[0].code == "26643006" - assert inst.dosageInstruction[0].route.coding[0].display == "Oral Route" - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert ( - inst.dosageInstruction[0].text == "1 tablet every four hours as needed for pain" - ) - assert inst.dosageInstruction[0].timing.repeat.frequency == 1 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(4) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "h" - assert inst.id == "meddisp0321" - assert inst.medicationCodeableConcept.coding[0].code == "49999-051-30" - assert ( - inst.medicationCodeableConcept.coding[0].display - == "Vicodin 5mg Hydrocodone, 500mg Acetaminophen tablet " - ) - assert ( - inst.medicationCodeableConcept.coding[0].system == "http://hl7.org/fhir/sid/ndc" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.reference == "Practitioner/f006" - assert inst.quantity.code == "TAB" - assert ( - inst.quantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert float(inst.quantity.value) == float(30) - assert inst.status == "in-progress" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "RFP" - assert inst.type.coding[0].display == "Refill - Part Fill" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.whenPrepared == fhirtypes.DateTime.validate("2015-01-15T10:20:00Z") - - -def test_medicationdispense_3(base_settings): - """No. 3 tests collection for MedicationDispense. - Test File: medicationdispense0321.json - """ - filename = base_settings["unittest_data_dir"] / "medicationdispense0321.json" - inst = medicationdispense.MedicationDispense.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationDispense" == inst.resource_type - - impl_medicationdispense_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationDispense" == data["resourceType"] - - inst2 = medicationdispense.MedicationDispense(**data) - impl_medicationdispense_3(inst2) - - -def impl_medicationdispense_4(inst): - assert inst.authorizingPrescription[0].reference == "MedicationRequest/medrx0323" - assert inst.contained[0].id == "med0318" - assert inst.daysSupply.code == "d" - assert inst.daysSupply.system == "http://unitsofmeasure.org" - assert inst.daysSupply.unit == "Day" - assert float(inst.daysSupply.value) == float(1) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "mL" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "mL" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 1000 - ) - assert inst.dosageInstruction[0].doseAndRate[0].rateRatio.denominator.code == "h" - assert ( - inst.dosageInstruction[0].doseAndRate[0].rateRatio.denominator.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].rateRatio.denominator.unit == "h" - assert float( - inst.dosageInstruction[0].doseAndRate[0].rateRatio.denominator.value - ) == float(1) - assert inst.dosageInstruction[0].doseAndRate[0].rateRatio.numerator.code == "mL" - assert ( - inst.dosageInstruction[0].doseAndRate[0].rateRatio.numerator.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].rateRatio.numerator.unit == "mL" - assert float( - inst.dosageInstruction[0].doseAndRate[0].rateRatio.numerator.value - ) == float(50) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].route.coding[0].code == "255560000" - assert inst.dosageInstruction[0].route.coding[0].display == "Intravenous" - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert ( - inst.dosageInstruction[0].text - == "1000mL infused at 50ml/hour for 4 hours - hang at 2200 hours" - ) - assert inst.dosageInstruction[0].timing.event[0] == fhirtypes.DateTime.validate( - "2015-01-15T22:00:00+11:00" - ) - assert inst.dosageInstruction[0].timing.repeat.frequency == 1 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(24) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "h" - assert inst.id == "meddisp0320" - assert inst.medicationReference.display == "TPN Solution" - assert inst.medicationReference.reference == "#med0318" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.reference == "Practitioner/f006" - assert inst.quantity.code == "ml" - assert inst.quantity.system == "http://unitsofmeasure.org" - assert float(inst.quantity.value) == float(1000) - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - assert inst.whenHandedOver == fhirtypes.DateTime.validate( - "2015-03-17T17:13:00+05:00" - ) - assert inst.whenPrepared == fhirtypes.DateTime.validate("2015-03-16T17:13:00+05:00") - - -def test_medicationdispense_4(base_settings): - """No. 4 tests collection for MedicationDispense. - Test File: medicationdispense0320.json - """ - filename = base_settings["unittest_data_dir"] / "medicationdispense0320.json" - inst = medicationdispense.MedicationDispense.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationDispense" == inst.resource_type - - impl_medicationdispense_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationDispense" == data["resourceType"] - - inst2 = medicationdispense.MedicationDispense(**data) - impl_medicationdispense_4(inst2) - - -def impl_medicationdispense_5(inst): - assert inst.authorizingPrescription[0].reference == "MedicationRequest/medrx0320" - assert inst.daysSupply.code == "d" - assert inst.daysSupply.system == "http://unitsofmeasure.org" - assert inst.daysSupply.unit == "Day" - assert float(inst.daysSupply.value) == float(30) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "U" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "U" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 20 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].route.coding[0].code == "263887005" - assert ( - inst.dosageInstruction[0].route.coding[0].display - == "Subcutaneous (qualifier value)" - ) - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == "20 Units SC three times daily" - assert inst.dosageInstruction[0].timing.repeat.frequency == 3 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.id == "meddisp0316" - assert inst.medicationCodeableConcept.coding[0].code == "285018" - assert ( - inst.medicationCodeableConcept.coding[0].display - == "Lantus 100 unit/ml injectable solution" - ) - assert ( - inst.medicationCodeableConcept.coding[0].system - == "http://www.nlm.nih.gov/research/umls/rxnorm" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.reference == "Practitioner/f006" - assert inst.quantity.code == "ml" - assert inst.quantity.system == "http://unitsofmeasure.org" - assert float(inst.quantity.value) == float(10) - assert inst.status == "in-progress" - assert inst.subject.display == "Donald Duck " - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "RFP" - assert inst.type.coding[0].display == "Refill - Part Fill" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.whenPrepared == fhirtypes.DateTime.validate("2015-06-25T07:13:00+05:00") - - -def test_medicationdispense_5(base_settings): - """No. 5 tests collection for MedicationDispense. - Test File: medicationdispense0316.json - """ - filename = base_settings["unittest_data_dir"] / "medicationdispense0316.json" - inst = medicationdispense.MedicationDispense.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationDispense" == inst.resource_type - - impl_medicationdispense_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationDispense" == data["resourceType"] - - inst2 = medicationdispense.MedicationDispense(**data) - impl_medicationdispense_5(inst2) - - -def impl_medicationdispense_6(inst): - assert inst.authorizingPrescription[0].reference == "MedicationRequest/medrx0321" - assert inst.daysSupply.code == "d" - assert inst.daysSupply.system == "http://unitsofmeasure.org" - assert inst.daysSupply.unit == "Day" - assert float(inst.daysSupply.value) == float(30) - assert inst.dosageInstruction[0].additionalInstruction[0].text == "Shake Well" - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "ea" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "ea" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 1 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == "Use two sprays twice daily" - assert inst.dosageInstruction[0].timing.repeat.frequency == 2 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.id == "meddisp0327" - assert inst.medicationCodeableConcept.coding[0].code == "746763" - assert inst.medicationCodeableConcept.coding[0].display == ( - "Proventil 0.09mg/actuat (Albuterol sulfate 0.108mg/actuat " "from mouthpiece)" - ) - assert ( - inst.medicationCodeableConcept.coding[0].system - == "http://www.nlm.nih.gov/research/umls/rxnorm" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.reference == "Practitioner/f006" - assert inst.quantity.code == "ml" - assert inst.quantity.system == "http://unitsofmeasure.org" - assert float(inst.quantity.value) == float(30) - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "TF" - assert inst.type.coding[0].display == "Trial Fill" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.whenHandedOver == fhirtypes.DateTime.validate("2015-01-15T16:20:00Z") - assert inst.whenPrepared == fhirtypes.DateTime.validate("2015-01-15T10:20:00Z") - - -def test_medicationdispense_6(base_settings): - """No. 6 tests collection for MedicationDispense. - Test File: medicationdispense0327.json - """ - filename = base_settings["unittest_data_dir"] / "medicationdispense0327.json" - inst = medicationdispense.MedicationDispense.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationDispense" == inst.resource_type - - impl_medicationdispense_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationDispense" == data["resourceType"] - - inst2 = medicationdispense.MedicationDispense(**data) - impl_medicationdispense_6(inst2) - - -def impl_medicationdispense_7(inst): - assert inst.authorizingPrescription[0].reference == "MedicationRequest/medrx0309" - assert inst.contained[0].id == "medexample015" - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "mg" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "mg" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 500 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].route.coding[0].code == "394899003" - assert ( - inst.dosageInstruction[0].route.coding[0].display - == "oral administration of treatment" - ) - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].timing.repeat.frequency == 2 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(21) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.id == "meddisp008" - assert inst.medicationReference.reference == "#medexample015" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.reference == "Practitioner/f006" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationdispense_7(base_settings): - """No. 7 tests collection for MedicationDispense. - Test File: medicationdispenseexample8.json - """ - filename = base_settings["unittest_data_dir"] / "medicationdispenseexample8.json" - inst = medicationdispense.MedicationDispense.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationDispense" == inst.resource_type - - impl_medicationdispense_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationDispense" == data["resourceType"] - - inst2 = medicationdispense.MedicationDispense(**data) - impl_medicationdispense_7(inst2) - - -def impl_medicationdispense_8(inst): - assert inst.authorizingPrescription[0].reference == "MedicationRequest/medrx0331" - assert inst.contained[0].id == "med0352" - assert inst.daysSupply.code == "d" - assert inst.daysSupply.system == "http://unitsofmeasure.org" - assert inst.daysSupply.unit == "Day" - assert float(inst.daysSupply.value) == float(1) - assert inst.dosageInstruction[0].additionalInstruction[0].text == ( - "Take along with one 2mg Coumadin tablet for a total daily " - "dose of 7mg as prescribed by physician" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "mg" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "mg" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 2 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].sequence == 1 - assert ( - inst.dosageInstruction[0].text - == "7mg (=one 5mg tablet PLUS one 2mg tablet) once daily" - ) - assert inst.dosageInstruction[0].timing.repeat.frequency == 1 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.id == "meddisp0331" - assert inst.medicationReference.display == "Coumadin 2mg tablet" - assert inst.medicationReference.reference == "#med0352" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.reference == "Practitioner/f006" - assert inst.quantity.code == "415818006" - assert inst.quantity.system == "http://snomed.info/sct" - assert float(inst.quantity.value) == float(1) - assert inst.status == "in-progress" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "DF" - assert inst.type.coding[0].display == "Daily Fill" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.whenPrepared == fhirtypes.DateTime.validate("2015-01-15T10:20:00Z") - - -def test_medicationdispense_8(base_settings): - """No. 8 tests collection for MedicationDispense. - Test File: medicationdispense0331.json - """ - filename = base_settings["unittest_data_dir"] / "medicationdispense0331.json" - inst = medicationdispense.MedicationDispense.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationDispense" == inst.resource_type - - impl_medicationdispense_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationDispense" == data["resourceType"] - - inst2 = medicationdispense.MedicationDispense(**data) - impl_medicationdispense_8(inst2) - - -def impl_medicationdispense_9(inst): - assert inst.authorizingPrescription[0].reference == "MedicationRequest/medrx0324" - assert inst.daysSupply.code == "d" - assert inst.daysSupply.system == "http://unitsofmeasure.org" - assert inst.daysSupply.unit == "Day" - assert float(inst.daysSupply.value) == float(10) - assert ( - inst.dosageInstruction[0].additionalInstruction[0].coding[0].code == "418637003" - ) - assert inst.dosageInstruction[0].additionalInstruction[0].coding[0].display == ( - "Do not take with any other paracetamol products (qualifier " "value)" - ) - assert ( - inst.dosageInstruction[0].additionalInstruction[0].coding[0].system - == "http://snomed.info/sct" - ) - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].code == "386661006" - ) - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].display - == "Fever (finding)" - ) - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "mg" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "mg" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 240 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].maxDosePerPeriod.denominator.code == "d" - assert ( - inst.dosageInstruction[0].maxDosePerPeriod.denominator.system - == "http://unitsofmeasure.org" - ) - assert float(inst.dosageInstruction[0].maxDosePerPeriod.denominator.value) == float( - 1 - ) - assert inst.dosageInstruction[0].maxDosePerPeriod.numerator.code == "mg" - assert ( - inst.dosageInstruction[0].maxDosePerPeriod.numerator.system - == "http://unitsofmeasure.org" - ) - assert float(inst.dosageInstruction[0].maxDosePerPeriod.numerator.value) == float( - 720 - ) - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == ( - "Insert two suppositories (240mg) rectally twice daily as " - "needed for fever to a maximim of 6 per day" - ) - assert inst.dosageInstruction[0].timing.repeat.frequency == 2 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.id == "meddisp0311" - assert inst.medicationCodeableConcept.coding[0].code == "50090-0001" - assert ( - inst.medicationCodeableConcept.coding[0].display - == "Acetaminophen 120mg Suppository" - ) - assert ( - inst.medicationCodeableConcept.coding[0].system == "http://hl7.org/fhir/sid/ndc" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.reference == "Practitioner/f006" - assert inst.quantity.code == "RECSUPP" - assert ( - inst.quantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert float(inst.quantity.value) == float(60) - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "RFP" - assert inst.type.coding[0].display == "Refill - Part Fill" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.whenHandedOver == fhirtypes.DateTime.validate("2015-01-15T16:20:00Z") - assert inst.whenPrepared == fhirtypes.DateTime.validate("2015-01-15T10:20:00Z") - - -def test_medicationdispense_9(base_settings): - """No. 9 tests collection for MedicationDispense. - Test File: medicationdispense0311.json - """ - filename = base_settings["unittest_data_dir"] / "medicationdispense0311.json" - inst = medicationdispense.MedicationDispense.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationDispense" == inst.resource_type - - impl_medicationdispense_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationDispense" == data["resourceType"] - - inst2 = medicationdispense.MedicationDispense(**data) - impl_medicationdispense_9(inst2) - - -def impl_medicationdispense_10(inst): - assert inst.authorizingPrescription[0].reference == "MedicationRequest/medrx0306" - assert inst.daysSupply.code == "d" - assert inst.daysSupply.system == "http://unitsofmeasure.org" - assert inst.daysSupply.unit == "Day" - assert float(inst.daysSupply.value) == float(30) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "mg" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "mg" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 6 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "calculated" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Calculated" - ) - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == "Take 3 tablets (6mg) once daily" - assert inst.dosageInstruction[0].timing.repeat.frequency == 1 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.id == "meddisp0307" - assert inst.medicationCodeableConcept.coding[0].code == "76388-713-25" - assert ( - inst.medicationCodeableConcept.coding[0].display - == "Myleran 2mg tablet, film coated" - ) - assert ( - inst.medicationCodeableConcept.coding[0].system == "http://hl7.org/fhir/sid/ndc" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.reference == "Practitioner/f006" - assert inst.quantity.code == "TAB" - assert ( - inst.quantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert float(inst.quantity.value) == float(90) - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "RFP" - assert inst.type.coding[0].display == "Refill - Part Fill" - assert ( - inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActCode" - ) - assert inst.whenHandedOver == fhirtypes.DateTime.validate("2015-01-15T16:20:00Z") - assert inst.whenPrepared == fhirtypes.DateTime.validate("2015-01-15T10:20:00Z") - - -def test_medicationdispense_10(base_settings): - """No. 10 tests collection for MedicationDispense. - Test File: medicationdispense0307.json - """ - filename = base_settings["unittest_data_dir"] / "medicationdispense0307.json" - inst = medicationdispense.MedicationDispense.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationDispense" == inst.resource_type - - impl_medicationdispense_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationDispense" == data["resourceType"] - - inst2 = medicationdispense.MedicationDispense(**data) - impl_medicationdispense_10(inst2) diff --git a/fhir/resources/tests/test_medicationknowledge.py b/fhir/resources/tests/test_medicationknowledge.py deleted file mode 100644 index a7014d7d..00000000 --- a/fhir/resources/tests/test_medicationknowledge.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicationKnowledge -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicationknowledge - - -def impl_medicationknowledge_1(inst): - assert inst.amount.unit == "mg/ml" - assert float(inst.amount.value) == float(50) - assert inst.code.coding[0].code == "0069-2587-10" - assert ( - inst.code.coding[0].display - == "Vancomycin Hydrochloride (VANCOMYCIN HYDROCHLORIDE)" - ) - assert inst.code.coding[0].system == "http://hl7.org/fhir/sid/ndc" - assert inst.contained[0].id == "org4" - assert inst.doseForm.coding[0].code == "385219001" - assert inst.doseForm.coding[0].display == "Injection Solution (qualifier value)" - assert inst.doseForm.coding[0].system == "http://snomed.info/sct" - assert inst.id == "example" - assert inst.manufacturer.reference == "#org4" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "active" - assert inst.synonym[0] == "Vancomycin Hydrochloride (VANCOMYCIN HYDROCHLORIDE)" - assert inst.text.status == "generated" - - -def test_medicationknowledge_1(base_settings): - """No. 1 tests collection for MedicationKnowledge. - Test File: medicationknowledge-example.json - """ - filename = base_settings["unittest_data_dir"] / "medicationknowledge-example.json" - inst = medicationknowledge.MedicationKnowledge.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationKnowledge" == inst.resource_type - - impl_medicationknowledge_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationKnowledge" == data["resourceType"] - - inst2 = medicationknowledge.MedicationKnowledge(**data) - impl_medicationknowledge_1(inst2) diff --git a/fhir/resources/tests/test_medicationrequest.py b/fhir/resources/tests/test_medicationrequest.py deleted file mode 100644 index a2e92515..00000000 --- a/fhir/resources/tests/test_medicationrequest.py +++ /dev/null @@ -1,934 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicationRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicationrequest - - -def impl_medicationrequest_1(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2015-01-15T11:15:33+10:00") - assert inst.dispenseRequest.expectedSupplyDuration.code == "d" - assert ( - inst.dispenseRequest.expectedSupplyDuration.system - == "http://unitsofmeasure.org" - ) - assert inst.dispenseRequest.expectedSupplyDuration.unit == "days" - assert float(inst.dispenseRequest.expectedSupplyDuration.value) == float(30) - assert inst.dispenseRequest.numberOfRepeatsAllowed == 3 - assert inst.dispenseRequest.quantity.code == "mL" - assert inst.dispenseRequest.quantity.system == "http://unitsofmeasure.org" - assert inst.dispenseRequest.quantity.unit == "mL" - assert float(inst.dispenseRequest.quantity.value) == float(30) - assert inst.dispenseRequest.validityPeriod.end == fhirtypes.DateTime.validate( - "2016-01-15T11:15:33+10:00" - ) - assert inst.dispenseRequest.validityPeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T11:15:33+10:00" - ) - assert inst.dosageInstruction[0].additionalInstruction[0].text == "Shake Well" - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "ea" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "ea" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 1 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == "Use two sprays twice daily" - assert inst.dosageInstruction[0].timing.repeat.frequency == 2 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.id == "medrx0326" - assert inst.identifier[0].system == "http://www.bmc.nl/portal/prescriptions" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345689" - assert inst.intent == "order" - assert inst.medicationCodeableConcept.coding[0].code == "746763" - assert ( - inst.medicationCodeableConcept.coding[0].display - == "Proventil HFA 90mcg/actuat metered dose inhaler, 200 actuat" - ) - assert ( - inst.medicationCodeableConcept.coding[0].system - == "http://www.nlm.nih.gov/research/umls/rxnorm" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.requester.display == "Patrick Pump" - assert inst.requester.reference == "Practitioner/f007" - assert inst.status == "on-hold" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.substitution.allowedBoolean is True - assert inst.substitution.reason.coding[0].code == "FP" - assert inst.substitution.reason.coding[0].display == "formulary policy" - assert ( - inst.substitution.reason.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medicationrequest_1(base_settings): - """No. 1 tests collection for MedicationRequest. - Test File: medicationrequest0326.json - """ - filename = base_settings["unittest_data_dir"] / "medicationrequest0326.json" - inst = medicationrequest.MedicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationRequest" == inst.resource_type - - impl_medicationrequest_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationRequest" == data["resourceType"] - - inst2 = medicationrequest.MedicationRequest(**data) - impl_medicationrequest_1(inst2) - - -def impl_medicationrequest_2(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2015-01-15T11:15:33+10:00") - assert inst.contained[0].id == "med0305" - assert inst.dispenseRequest.expectedSupplyDuration.code == "d" - assert ( - inst.dispenseRequest.expectedSupplyDuration.system - == "http://unitsofmeasure.org" - ) - assert inst.dispenseRequest.expectedSupplyDuration.unit == "days" - assert float(inst.dispenseRequest.expectedSupplyDuration.value) == float(30) - assert inst.dispenseRequest.numberOfRepeatsAllowed == 1 - assert inst.dispenseRequest.quantity.code == "mL" - assert inst.dispenseRequest.quantity.system == "http://unitsofmeasure.org" - assert inst.dispenseRequest.quantity.unit == "mL" - assert float(inst.dispenseRequest.quantity.value) == float(10) - assert inst.dispenseRequest.validityPeriod.end == fhirtypes.DateTime.validate( - "2016-01-15T11:15:33+10:00" - ) - assert inst.dispenseRequest.validityPeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T11:15:33+10:00" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "OPDROP" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "OPDROP" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 1 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].method.coding[0].code == "421538008" - assert ( - inst.dosageInstruction[0].method.coding[0].display - == "Instill - dosing instruction imperative (qualifier value)" - ) - assert inst.dosageInstruction[0].method.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].route.coding[0].code == "54485002" - assert ( - inst.dosageInstruction[0].route.coding[0].display - == "Ophthalmic route (qualifier value)" - ) - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == "Instil one drop in each eye twice daily" - assert inst.dosageInstruction[0].timing.repeat.frequency == 2 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.encounter.display == "encounter who leads to this prescription" - assert inst.encounter.reference == "Encounter/f002" - assert inst.id == "medrx0330" - assert inst.identifier[0].system == "http://www.bmc.nl/portal/prescriptions" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345689" - assert inst.intent == "order" - assert inst.medicationReference.reference == "#med0305" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.requester.display == "Patrick Pump" - assert inst.requester.reference == "Practitioner/f007" - assert inst.status == "active" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.substitution.allowedBoolean is False - assert inst.substitution.reason.coding[0].code == "FP" - assert inst.substitution.reason.coding[0].display == "formulary policy" - assert ( - inst.substitution.reason.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medicationrequest_2(base_settings): - """No. 2 tests collection for MedicationRequest. - Test File: medicationrequest0330.json - """ - filename = base_settings["unittest_data_dir"] / "medicationrequest0330.json" - inst = medicationrequest.MedicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationRequest" == inst.resource_type - - impl_medicationrequest_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationRequest" == data["resourceType"] - - inst2 = medicationrequest.MedicationRequest(**data) - impl_medicationrequest_2(inst2) - - -def impl_medicationrequest_3(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2015-01-15T11:15:33+10:00") - assert inst.contained[0].id == "med0309" - assert inst.dosageInstruction[0].additionalInstruction[0].text == "Take at bedtime" - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].code == "32914008" - ) - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].display - == "Restless Legs" - ) - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseRange.high.code == "TAB" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseRange.high.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseRange.high.unit == "TAB" - assert float( - inst.dosageInstruction[0].doseAndRate[0].doseRange.high.value - ) == float(2) - assert inst.dosageInstruction[0].doseAndRate[0].doseRange.low.code == "TAB" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseRange.low.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseRange.low.unit == "TAB" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseRange.low.value) == float( - 1 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].route.coding[0].code == "26643006" - assert inst.dosageInstruction[0].route.coding[0].display == "Oral Route" - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == ( - "Take 1-2 tablets once daily at bedtime as needed for " "restless legs" - ) - assert inst.dosageInstruction[0].timing.repeat.frequency == 1 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.encounter.display == "encounter who leads to this prescription" - assert inst.encounter.reference == "Encounter/f001" - assert inst.id == "medrx0310" - assert inst.identifier[0].system == "http://www.bmc.nl/portal/prescriptions" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345689" - assert inst.intent == "order" - assert inst.medicationReference.reference == "#med0309" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.requester.display == "Patrick Pump" - assert inst.requester.reference == "Practitioner/f007" - assert inst.status == "active" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationrequest_3(base_settings): - """No. 3 tests collection for MedicationRequest. - Test File: medicationrequest0310.json - """ - filename = base_settings["unittest_data_dir"] / "medicationrequest0310.json" - inst = medicationrequest.MedicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationRequest" == inst.resource_type - - impl_medicationrequest_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationRequest" == data["resourceType"] - - inst2 = medicationrequest.MedicationRequest(**data) - impl_medicationrequest_3(inst2) - - -def impl_medicationrequest_4(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2015-01-15T11:15:33+10:00") - assert inst.contained[0].id == "med0304" - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "mg" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "mg" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 6 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].route.coding[0].code == "26643006" - assert ( - inst.dosageInstruction[0].route.coding[0].display - == "Oral route (qualifier value)" - ) - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == ( - "6 mg PO daily for remission induction; adjust dosage to " - "white blood cell (WBC) count. With hold treatment if WBC is" - " less than 15,000/µL; resume when WBC is greater than " - "50,000/µL" - ) - assert inst.dosageInstruction[0].timing.repeat.frequency == 1 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.id == "medrx0306" - assert inst.identifier[0].system == "http://www.bmc.nl/portal/prescriptions" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345689" - assert inst.intent == "order" - assert inst.medicationReference.display == "Myleran 2mg tablet" - assert inst.medicationReference.reference == "#med0304" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.reasonCode[0].coding[0].code == "92818009" - assert inst.reasonCode[0].coding[0].display == "Chronic myeloid Leukemia (disorder)" - assert inst.reasonCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.requester.display == "Patrick Pump" - assert inst.requester.reference == "Practitioner/f007" - assert inst.status == "active" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationrequest_4(base_settings): - """No. 4 tests collection for MedicationRequest. - Test File: medicationrequest0306.json - """ - filename = base_settings["unittest_data_dir"] / "medicationrequest0306.json" - inst = medicationrequest.MedicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationRequest" == inst.resource_type - - impl_medicationrequest_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationRequest" == data["resourceType"] - - inst2 = medicationrequest.MedicationRequest(**data) - impl_medicationrequest_4(inst2) - - -def impl_medicationrequest_5(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2015-01-15T11:15:33+10:00") - assert inst.contained[0].id == "med0308" - assert inst.dispenseRequest.expectedSupplyDuration.code == "d" - assert ( - inst.dispenseRequest.expectedSupplyDuration.system - == "http://unitsofmeasure.org" - ) - assert inst.dispenseRequest.expectedSupplyDuration.unit == "days" - assert float(inst.dispenseRequest.expectedSupplyDuration.value) == float(10) - assert inst.dispenseRequest.quantity.code == "TAB" - assert ( - inst.dispenseRequest.quantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dispenseRequest.quantity.unit == "TAB" - assert float(inst.dispenseRequest.quantity.value) == float(30) - assert inst.dispenseRequest.validityPeriod.end == fhirtypes.DateTime.validate( - "2016-01-15T11:15:33+10:00" - ) - assert inst.dispenseRequest.validityPeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T11:15:33+10:00" - ) - assert ( - inst.dosageInstruction[0].additionalInstruction[0].coding[0].code == "418914006" - ) - assert inst.dosageInstruction[0].additionalInstruction[0].coding[0].display == ( - "Warning. May cause drowsiness. If affected do not drive or " - "operate machinery. Avoid alcoholic drink (qualifier value)" - ) - assert ( - inst.dosageInstruction[0].additionalInstruction[0].coding[0].system - == "http://snomed.info/sct" - ) - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].code == "203082005" - ) - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].display - == "Fibromyalgia (disorder)" - ) - assert ( - inst.dosageInstruction[0].asNeededCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "TAB" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "TAB" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 1 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].route.coding[0].code == "26643006" - assert inst.dosageInstruction[0].route.coding[0].display == "Oral Route" - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert ( - inst.dosageInstruction[0].text == "1 tablet every four hours as needed for pain" - ) - assert inst.dosageInstruction[0].timing.repeat.frequency == 1 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(4) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "h" - assert inst.encounter.display == "encounter who leads to this prescription" - assert inst.encounter.reference == "Encounter/f001" - assert inst.id == "medrx0307" - assert inst.identifier[0].system == "http://www.bmc.nl/portal/prescriptions" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345689" - assert inst.intent == "order" - assert inst.medicationReference.reference == "#med0308" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.requester.display == "Patrick Pump" - assert inst.requester.reference == "Practitioner/f007" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.substitution.allowedBoolean is True - assert inst.substitution.reason.coding[0].code == "FP" - assert inst.substitution.reason.coding[0].display == "formulary policy" - assert ( - inst.substitution.reason.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medicationrequest_5(base_settings): - """No. 5 tests collection for MedicationRequest. - Test File: medicationrequest0307.json - """ - filename = base_settings["unittest_data_dir"] / "medicationrequest0307.json" - inst = medicationrequest.MedicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationRequest" == inst.resource_type - - impl_medicationrequest_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationRequest" == data["resourceType"] - - inst2 = medicationrequest.MedicationRequest(**data) - impl_medicationrequest_5(inst2) - - -def impl_medicationrequest_6(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2015-01-15T11:15:33+10:00") - assert inst.contained[0].id == "med0350" - assert inst.dispenseRequest.expectedSupplyDuration.code == "d" - assert ( - inst.dispenseRequest.expectedSupplyDuration.system - == "http://unitsofmeasure.org" - ) - assert inst.dispenseRequest.expectedSupplyDuration.unit == "days" - assert float(inst.dispenseRequest.expectedSupplyDuration.value) == float(30) - assert inst.dispenseRequest.numberOfRepeatsAllowed == 3 - assert inst.dispenseRequest.quantity.code == "TAB" - assert ( - inst.dispenseRequest.quantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dispenseRequest.quantity.unit == "TAB" - assert float(inst.dispenseRequest.quantity.value) == float(30) - assert inst.dispenseRequest.validityPeriod.end == fhirtypes.DateTime.validate( - "2016-01-15T11:15:33+10:00" - ) - assert inst.dispenseRequest.validityPeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T11:15:33+10:00" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "mg" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "mg" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 7 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == "7mg once daily" - assert inst.dosageInstruction[0].timing.repeat.frequency == 1 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.id == "medrx0331" - assert inst.identifier[0].system == "http://www.bmc.nl/portal/prescriptions" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345689" - assert inst.intent == "order" - assert inst.medicationReference.reference == "#med0350" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.requester.display == "Patrick Pump" - assert inst.requester.reference == "Practitioner/f007" - assert inst.status == "active" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.substitution.allowedBoolean is True - assert inst.substitution.reason.coding[0].code == "FP" - assert inst.substitution.reason.coding[0].display == "formulary policy" - assert ( - inst.substitution.reason.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medicationrequest_6(base_settings): - """No. 6 tests collection for MedicationRequest. - Test File: medicationrequest0331.json - """ - filename = base_settings["unittest_data_dir"] / "medicationrequest0331.json" - inst = medicationrequest.MedicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationRequest" == inst.resource_type - - impl_medicationrequest_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationRequest" == data["resourceType"] - - inst2 = medicationrequest.MedicationRequest(**data) - impl_medicationrequest_6(inst2) - - -def impl_medicationrequest_7(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2015-01-15T11:15:33+10:00") - assert inst.dispenseRequest.expectedSupplyDuration.code == "d" - assert ( - inst.dispenseRequest.expectedSupplyDuration.system - == "http://unitsofmeasure.org" - ) - assert inst.dispenseRequest.expectedSupplyDuration.unit == "days" - assert float(inst.dispenseRequest.expectedSupplyDuration.value) == float(14) - assert inst.dispenseRequest.quantity.code == "patch" - assert ( - inst.dispenseRequest.quantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dispenseRequest.quantity.unit == "patch" - assert float(inst.dispenseRequest.quantity.value) == float(6) - assert inst.dispenseRequest.validityPeriod.end == fhirtypes.DateTime.validate( - "2016-01-15T11:15:33+10:00" - ) - assert inst.dispenseRequest.validityPeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T11:15:33+10:00" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "patch" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "patch" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 1 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == "apply one patch three times per week" - assert inst.dosageInstruction[0].timing.repeat.frequency == 3 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "wk" - assert inst.id == "medrx0327" - assert inst.identifier[0].system == "http://www.bmc.nl/portal/prescriptions" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345689" - assert inst.intent == "order" - assert inst.medicationCodeableConcept.coding[0].code == "333919005" - assert ( - inst.medicationCodeableConcept.coding[0].display - == "Fentanyl 25micrograms/hour patch (product)" - ) - assert inst.medicationCodeableConcept.coding[0].system == "http://snomed.info/sct" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.requester.display == "Patrick Pump" - assert inst.requester.reference == "Practitioner/f007" - assert inst.status == "active" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationrequest_7(base_settings): - """No. 7 tests collection for MedicationRequest. - Test File: medicationrequest0327.json - """ - filename = base_settings["unittest_data_dir"] / "medicationrequest0327.json" - inst = medicationrequest.MedicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationRequest" == inst.resource_type - - impl_medicationrequest_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationRequest" == data["resourceType"] - - inst2 = medicationrequest.MedicationRequest(**data) - impl_medicationrequest_7(inst2) - - -def impl_medicationrequest_8(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2015-01-15T11:15:33+10:00") - assert inst.contained[0].id == "med0306" - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "mg/kg" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "mg/kg" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 1.8 - ) - assert inst.dosageInstruction[0].doseAndRate[0].rateRatio.denominator.code == "min" - assert ( - inst.dosageInstruction[0].doseAndRate[0].rateRatio.denominator.system - == "http://unitsofmeasure.org" - ) - assert float( - inst.dosageInstruction[0].doseAndRate[0].rateRatio.denominator.value - ) == float(20) - assert inst.dosageInstruction[0].doseAndRate[0].rateRatio.numerator.code == "mg/kg" - assert ( - inst.dosageInstruction[0].doseAndRate[0].rateRatio.numerator.system - == "http://unitsofmeasure.org" - ) - assert float( - inst.dosageInstruction[0].doseAndRate[0].rateRatio.numerator.value - ) == float(1.8) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].maxDosePerLifetime.code == "mg" - assert ( - inst.dosageInstruction[0].maxDosePerLifetime.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].maxDosePerLifetime.unit == "mg" - assert float(inst.dosageInstruction[0].maxDosePerLifetime.value) == float(400) - assert inst.dosageInstruction[0].route.coding[0].code == "255560000" - assert inst.dosageInstruction[0].route.coding[0].display == "Intravenous" - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == ( - "1.8 mg/kg IV infusion over 20 minutes every 3 weeks for 16 " "cycles" - ) - assert inst.dosageInstruction[0].timing.repeat.count == 16 - assert inst.dosageInstruction[0].timing.repeat.frequency == 1 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(3) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "wk" - assert inst.encounter.display == "encounter who leads to this prescription" - assert inst.encounter.reference == "Encounter/f001" - assert inst.id == "medrx0316" - assert inst.identifier[0].system == "http://www.bmc.nl/portal/prescriptions" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345689" - assert inst.instantiatesUri[0] == ( - "http://www.bccancer.bc.ca/chemotherapy-protocols-" - "site/Documents/Lymphoma-" - "Myeloma/ULYBRENTUX%20Protocol_1Jun2017.pdf" - ) - assert inst.intent == "order" - assert inst.medicationReference.reference == "#med0306" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.requester.display == "Patrick Pump" - assert inst.requester.reference == "Practitioner/f007" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationrequest_8(base_settings): - """No. 8 tests collection for MedicationRequest. - Test File: medicationrequest0316.json - """ - filename = base_settings["unittest_data_dir"] / "medicationrequest0316.json" - inst = medicationrequest.MedicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationRequest" == inst.resource_type - - impl_medicationrequest_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationRequest" == data["resourceType"] - - inst2 = medicationrequest.MedicationRequest(**data) - impl_medicationrequest_8(inst2) - - -def impl_medicationrequest_9(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2015-01-15T11:15:33+10:00") - assert inst.dispenseRequest.expectedSupplyDuration.code == "d" - assert ( - inst.dispenseRequest.expectedSupplyDuration.system - == "http://unitsofmeasure.org" - ) - assert inst.dispenseRequest.expectedSupplyDuration.unit == "days" - assert float(inst.dispenseRequest.expectedSupplyDuration.value) == float(30) - assert inst.dispenseRequest.numberOfRepeatsAllowed == 6 - assert inst.dispenseRequest.quantity.code == "mL" - assert inst.dispenseRequest.quantity.system == "http://unitsofmeasure.org" - assert inst.dispenseRequest.quantity.unit == "mL" - assert float(inst.dispenseRequest.quantity.value) == float(10) - assert inst.dispenseRequest.validityPeriod.end == fhirtypes.DateTime.validate( - "2016-01-15T11:15:33+10:00" - ) - assert inst.dispenseRequest.validityPeriod.start == fhirtypes.DateTime.validate( - "2015-01-15T11:15:33+10:00" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.code == "U" - assert ( - inst.dosageInstruction[0].doseAndRate[0].doseQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].doseQuantity.unit == "U" - assert float(inst.dosageInstruction[0].doseAndRate[0].doseQuantity.value) == float( - 20 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].route.coding[0].code == "263887005" - assert ( - inst.dosageInstruction[0].route.coding[0].display - == "Subcutaneous (qualifier value)" - ) - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == "20 Units SC three times daily" - assert inst.dosageInstruction[0].timing.repeat.frequency == 3 - assert float(inst.dosageInstruction[0].timing.repeat.period) == float(1) - assert inst.dosageInstruction[0].timing.repeat.periodUnit == "d" - assert inst.id == "medrx0320" - assert inst.identifier[0].system == "http://www.bmc.nl/portal/prescriptions" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345689" - assert inst.intent == "order" - assert inst.medicationCodeableConcept.coding[0].code == "285018" - assert ( - inst.medicationCodeableConcept.coding[0].display - == "Lantus 100 unit/ml injectable solution" - ) - assert ( - inst.medicationCodeableConcept.coding[0].system - == "http://www.nlm.nih.gov/research/umls/rxnorm" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.reasonCode[0].coding[0].code == "473189005" - assert ( - inst.reasonCode[0].coding[0].display - == "On subcutaneous insulin for diabetes mellitus (finding)" - ) - assert inst.reasonCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.requester.display == "Patrick Pump" - assert inst.requester.reference == "Practitioner/f007" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationrequest_9(base_settings): - """No. 9 tests collection for MedicationRequest. - Test File: medicationrequest0320.json - """ - filename = base_settings["unittest_data_dir"] / "medicationrequest0320.json" - inst = medicationrequest.MedicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationRequest" == inst.resource_type - - impl_medicationrequest_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationRequest" == data["resourceType"] - - inst2 = medicationrequest.MedicationRequest(**data) - impl_medicationrequest_9(inst2) - - -def impl_medicationrequest_10(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2015-01-15T11:15:33+10:00") - assert inst.contained[0].id == "med0336" - assert ( - inst.dosageInstruction[0].doseAndRate[0].rateQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.dosageInstruction[0].doseAndRate[0].rateQuantity.unit == "ug/kg/min" - assert float(inst.dosageInstruction[0].doseAndRate[0].rateQuantity.value) == float( - 4 - ) - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosageInstruction[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosageInstruction[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosageInstruction[0].route.coding[0].code == "47625008" - assert ( - inst.dosageInstruction[0].route.coding[0].display - == "Intravenous route (qualifier value)" - ) - assert inst.dosageInstruction[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosageInstruction[0].sequence == 1 - assert inst.dosageInstruction[0].text == "Dopamine 4mcg/kg/min" - assert float(inst.dosageInstruction[0].timing.repeat.duration) == float(33.33) - assert inst.dosageInstruction[0].timing.repeat.durationUnit == "h" - assert inst.id == "medrx0336" - assert inst.identifier[0].system == "http://www.bmc.nl/portal/prescriptions" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345689" - assert inst.intent == "order" - assert inst.medicationReference.display == "Dopamine 400mg in 500mL D5W" - assert inst.medicationReference.reference == "#med0336" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.requester.display == "Patrick Pump" - assert inst.requester.reference == "Practitioner/f007" - assert inst.status == "completed" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.supportingInformation[0].reference == "Observation/example" - assert inst.text.status == "generated" - - -def test_medicationrequest_10(base_settings): - """No. 10 tests collection for MedicationRequest. - Test File: medicationrequest0336.json - """ - filename = base_settings["unittest_data_dir"] / "medicationrequest0336.json" - inst = medicationrequest.MedicationRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationRequest" == inst.resource_type - - impl_medicationrequest_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationRequest" == data["resourceType"] - - inst2 = medicationrequest.MedicationRequest(**data) - impl_medicationrequest_10(inst2) diff --git a/fhir/resources/tests/test_medicationstatement.py b/fhir/resources/tests/test_medicationstatement.py deleted file mode 100644 index ea28ebf9..00000000 --- a/fhir/resources/tests/test_medicationstatement.py +++ /dev/null @@ -1,443 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicationStatement -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicationstatement - - -def impl_medicationstatement_1(inst): - assert inst.basedOn[0].reference == "CarePlan/gpvisit" - assert inst.context.reference == "Encounter/f203" - assert inst.dateAsserted == fhirtypes.DateTime.validate("2015-02-22T11:15:33+10:00") - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2014-01-23T11:15:33+10:00" - ) - assert inst.id == "example005" - assert inst.informationSource.display == "Donald Duck" - assert inst.informationSource.reference == "Patient/pat1" - assert inst.medicationCodeableConcept.coding[0].code == "27658006" - assert inst.medicationCodeableConcept.coding[0].display == "Amoxicillin (product)" - assert inst.medicationCodeableConcept.coding[0].system == "http://snomed.info/sct" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == ( - "Patient indicated that they thought it was Amoxicillin they " - "were taking but it was really Erythromycin" - ) - assert inst.status == "entered-in-error" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationstatement_1(base_settings): - """No. 1 tests collection for MedicationStatement. - Test File: medicationstatementexample5.json - """ - filename = base_settings["unittest_data_dir"] / "medicationstatementexample5.json" - inst = medicationstatement.MedicationStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationStatement" == inst.resource_type - - impl_medicationstatement_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationStatement" == data["resourceType"] - - inst2 = medicationstatement.MedicationStatement(**data) - impl_medicationstatement_1(inst2) - - -def impl_medicationstatement_2(inst): - assert inst.dateAsserted == fhirtypes.DateTime.validate("2015-02-22T11:15:33+10:00") - assert inst.dosage[0].asNeededBoolean is False - assert inst.dosage[0].maxDosePerPeriod.denominator.code == "d" - assert ( - inst.dosage[0].maxDosePerPeriod.denominator.system - == "http://unitsofmeasure.org" - ) - assert float(inst.dosage[0].maxDosePerPeriod.denominator.value) == float(1) - assert inst.dosage[0].maxDosePerPeriod.numerator.code == "385055001" - assert inst.dosage[0].maxDosePerPeriod.numerator.system == "http://snomed.info/sct" - assert inst.dosage[0].maxDosePerPeriod.numerator.unit == "capsules" - assert float(inst.dosage[0].maxDosePerPeriod.numerator.value) == float(3) - assert inst.dosage[0].route.coding[0].code == "260548002" - assert inst.dosage[0].route.coding[0].display == "Oral" - assert inst.dosage[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage[0].text == "one capsule three times daily" - assert inst.dosage[0].timing.repeat.frequency == 3 - assert float(inst.dosage[0].timing.repeat.period) == float(1) - assert inst.dosage[0].timing.repeat.periodUnit == "d" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2014-01-23T11:15:33+10:00" - ) - assert inst.id == "example004" - assert inst.informationSource.display == "Donald Duck" - assert inst.informationSource.reference == "Patient/pat1" - assert inst.medicationCodeableConcept.coding[0].code == "27658006" - assert inst.medicationCodeableConcept.coding[0].display == "Amoxicillin (product)" - assert inst.medicationCodeableConcept.coding[0].system == "http://snomed.info/sct" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "Patient indicates they miss the occasional dose" - assert inst.partOf[0].reference == "Observation/blood-pressure" - assert inst.reasonCode[0].coding[0].code == "65363002" - assert inst.reasonCode[0].coding[0].display == "Otitis Media" - assert inst.reasonCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.status == "active" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationstatement_2(base_settings): - """No. 2 tests collection for MedicationStatement. - Test File: medicationstatementexample4.json - """ - filename = base_settings["unittest_data_dir"] / "medicationstatementexample4.json" - inst = medicationstatement.MedicationStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationStatement" == inst.resource_type - - impl_medicationstatement_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationStatement" == data["resourceType"] - - inst2 = medicationstatement.MedicationStatement(**data) - impl_medicationstatement_2(inst2) - - -def impl_medicationstatement_3(inst): - assert inst.dateAsserted == fhirtypes.DateTime.validate("2014-02-22T11:15:33+10:00") - assert inst.dosage[0].asNeededBoolean is False - assert inst.dosage[0].doseAndRate[0].doseQuantity.code == "tab" - assert ( - inst.dosage[0].doseAndRate[0].doseQuantity.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dosage[0].doseAndRate[0].doseQuantity.unit == "tab" - assert float(inst.dosage[0].doseAndRate[0].doseQuantity.value) == float(1) - assert inst.dosage[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosage[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosage[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosage[0].maxDosePerPeriod.denominator.code == "d" - assert ( - inst.dosage[0].maxDosePerPeriod.denominator.system - == "http://unitsofmeasure.org" - ) - assert float(inst.dosage[0].maxDosePerPeriod.denominator.value) == float(1) - assert float(inst.dosage[0].maxDosePerPeriod.numerator.value) == float(1) - assert inst.dosage[0].route.coding[0].code == "260548002" - assert inst.dosage[0].route.coding[0].display == "Oral" - assert inst.dosage[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage[0].sequence == 1 - assert inst.dosage[0].text == "1 tablet per day" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2014-02-01T11:15:33+10:00" - ) - assert inst.id == "example003" - assert inst.informationSource.display == "Donald Duck" - assert inst.informationSource.reference == "Patient/pat1" - assert inst.medicationCodeableConcept.text == "Little Pink Pill for water retention" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == ( - "Patient cannot remember the name of the tablet, but takes it" - " every day in the morning for water retention" - ) - assert inst.reasonReference[0].reference == "Observation/blood-pressure" - assert inst.status == "active" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationstatement_3(base_settings): - """No. 3 tests collection for MedicationStatement. - Test File: medicationstatementexample3.json - """ - filename = base_settings["unittest_data_dir"] / "medicationstatementexample3.json" - inst = medicationstatement.MedicationStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationStatement" == inst.resource_type - - impl_medicationstatement_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationStatement" == data["resourceType"] - - inst2 = medicationstatement.MedicationStatement(**data) - impl_medicationstatement_3(inst2) - - -def impl_medicationstatement_4(inst): - assert inst.contained[0].id == "med0309" - assert inst.dateAsserted == fhirtypes.DateTime.validate("2015-02-22T11:15:33+10:00") - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2015-01-23T11:15:33+10:00" - ) - assert inst.id == "example002" - assert inst.informationSource.display == "Donald Duck" - assert inst.informationSource.reference == "Patient/pat1" - assert inst.medicationReference.reference == "#med0309" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert ( - inst.note[0].text == "Patient cannot take acetaminophen as per Dr instructions" - ) - assert inst.status == "active" - assert inst.statusReason[0].coding[0].code == "166643006" - assert inst.statusReason[0].coding[0].display == "Liver enzymes abnormal" - assert inst.statusReason[0].coding[0].system == "http://snomed.info/sct" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationstatement_4(base_settings): - """No. 4 tests collection for MedicationStatement. - Test File: medicationstatementexample2.json - """ - filename = base_settings["unittest_data_dir"] / "medicationstatementexample2.json" - inst = medicationstatement.MedicationStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationStatement" == inst.resource_type - - impl_medicationstatement_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationStatement" == data["resourceType"] - - inst2 = medicationstatement.MedicationStatement(**data) - impl_medicationstatement_4(inst2) - - -def impl_medicationstatement_5(inst): - assert inst.category.coding[0].code == "inpatient" - assert inst.category.coding[0].display == "Inpatient" - assert inst.category.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/medication-statement-" "category" - ) - assert inst.contained[0].id == "med0309" - assert inst.dateAsserted == fhirtypes.DateTime.validate("2015-02-22T11:15:33+10:00") - assert inst.derivedFrom[0].reference == "MedicationRequest/medrx002" - assert inst.dosage[0].additionalInstruction[0].text == "Taking at bedtime" - assert inst.dosage[0].asNeededCodeableConcept.coding[0].code == "32914008" - assert inst.dosage[0].asNeededCodeableConcept.coding[0].display == "Restless Legs" - assert ( - inst.dosage[0].asNeededCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.dosage[0].doseAndRate[0].doseRange.high.code == "TAB" - assert ( - inst.dosage[0].doseAndRate[0].doseRange.high.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dosage[0].doseAndRate[0].doseRange.high.unit == "TAB" - assert float(inst.dosage[0].doseAndRate[0].doseRange.high.value) == float(2) - assert inst.dosage[0].doseAndRate[0].doseRange.low.code == "TAB" - assert ( - inst.dosage[0].doseAndRate[0].doseRange.low.system - == "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm" - ) - assert inst.dosage[0].doseAndRate[0].doseRange.low.unit == "TAB" - assert float(inst.dosage[0].doseAndRate[0].doseRange.low.value) == float(1) - assert inst.dosage[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosage[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosage[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosage[0].route.coding[0].code == "26643006" - assert inst.dosage[0].route.coding[0].display == "Oral Route" - assert inst.dosage[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage[0].sequence == 1 - assert inst.dosage[0].text == ( - "1-2 tablets once daily at bedtime as needed for restless " "legs" - ) - assert inst.dosage[0].timing.repeat.frequency == 1 - assert float(inst.dosage[0].timing.repeat.period) == float(1) - assert inst.dosage[0].timing.repeat.periodUnit == "d" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2015-01-23T11:15:33+10:00" - ) - assert inst.id == "example001" - assert inst.identifier[0].system == "http://www.bmc.nl/portal/medstatements" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345689" - assert inst.informationSource.display == "Donald Duck" - assert inst.informationSource.reference == "Patient/pat1" - assert inst.medicationReference.reference == "#med0309" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "Patient indicates they miss the occasional dose" - assert inst.reasonCode[0].coding[0].code == "32914008" - assert inst.reasonCode[0].coding[0].display == "Restless Legs" - assert inst.reasonCode[0].coding[0].system == "http://snomed.info/sct" - assert inst.status == "active" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationstatement_5(base_settings): - """No. 5 tests collection for MedicationStatement. - Test File: medicationstatementexample1.json - """ - filename = base_settings["unittest_data_dir"] / "medicationstatementexample1.json" - inst = medicationstatement.MedicationStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationStatement" == inst.resource_type - - impl_medicationstatement_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationStatement" == data["resourceType"] - - inst2 = medicationstatement.MedicationStatement(**data) - impl_medicationstatement_5(inst2) - - -def impl_medicationstatement_6(inst): - assert inst.contained[0].id == "med0315" - assert inst.id == "example007" - assert inst.informationSource.display == "Donald Duck" - assert inst.informationSource.reference == "Patient/pat1" - assert inst.medicationReference.reference == "#med0315" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == ( - "patient plans to start using for seasonal allergies in the " - "Spring when pollen is in the air" - ) - assert inst.status == "active" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationstatement_6(base_settings): - """No. 6 tests collection for MedicationStatement. - Test File: medicationstatementexample7.json - """ - filename = base_settings["unittest_data_dir"] / "medicationstatementexample7.json" - inst = medicationstatement.MedicationStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationStatement" == inst.resource_type - - impl_medicationstatement_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationStatement" == data["resourceType"] - - inst2 = medicationstatement.MedicationStatement(**data) - impl_medicationstatement_6(inst2) - - -def impl_medicationstatement_7(inst): - assert inst.dateAsserted == fhirtypes.DateTime.validate("2014-02-22T11:15:33+10:00") - assert inst.dosage[0].asNeededBoolean is False - assert inst.dosage[0].doseAndRate[0].doseQuantity.code == "mL" - assert ( - inst.dosage[0].doseAndRate[0].doseQuantity.system == "http://unitsofmeasure.org" - ) - assert inst.dosage[0].doseAndRate[0].doseQuantity.unit == "mL" - assert float(inst.dosage[0].doseAndRate[0].doseQuantity.value) == float(5) - assert inst.dosage[0].doseAndRate[0].type.coding[0].code == "ordered" - assert inst.dosage[0].doseAndRate[0].type.coding[0].display == "Ordered" - assert ( - inst.dosage[0].doseAndRate[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/dose-rate-type" - ) - assert inst.dosage[0].maxDosePerPeriod.denominator.code == "d" - assert ( - inst.dosage[0].maxDosePerPeriod.denominator.system - == "http://unitsofmeasure.org" - ) - assert float(inst.dosage[0].maxDosePerPeriod.denominator.value) == float(1) - assert float(inst.dosage[0].maxDosePerPeriod.numerator.value) == float(3) - assert inst.dosage[0].route.coding[0].code == "260548002" - assert inst.dosage[0].route.coding[0].display == "Oral" - assert inst.dosage[0].route.coding[0].system == "http://snomed.info/sct" - assert inst.dosage[0].sequence == 1 - assert inst.dosage[0].text == "5ml three times daily" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2014-02-01T11:15:33+10:00" - ) - assert inst.id == "example006" - assert inst.informationSource.display == "Peter Chalmers" - assert inst.informationSource.reference == "RelatedPerson/peter" - assert inst.medicationCodeableConcept.coding[0].code == "27658006" - assert inst.medicationCodeableConcept.coding[0].display == "Amoxicillin (product)" - assert inst.medicationCodeableConcept.coding[0].system == "http://snomed.info/sct" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "Father indicates they miss the occasional dose" - assert inst.status == "active" - assert inst.subject.display == "Donald Duck" - assert inst.subject.reference == "Patient/pat1" - assert inst.text.status == "generated" - - -def test_medicationstatement_7(base_settings): - """No. 7 tests collection for MedicationStatement. - Test File: medicationstatementexample6.json - """ - filename = base_settings["unittest_data_dir"] / "medicationstatementexample6.json" - inst = medicationstatement.MedicationStatement.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicationStatement" == inst.resource_type - - impl_medicationstatement_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicationStatement" == data["resourceType"] - - inst2 = medicationstatement.MedicationStatement(**data) - impl_medicationstatement_7(inst2) diff --git a/fhir/resources/tests/test_medicinalproduct.py b/fhir/resources/tests/test_medicinalproduct.py deleted file mode 100644 index be4f0c29..00000000 --- a/fhir/resources/tests/test_medicinalproduct.py +++ /dev/null @@ -1,103 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProduct -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicinalproduct - - -def impl_medicinalproduct_1(inst): - assert inst.attachedDocument[0].reference == "DocumentReference/example" - assert inst.id == "example" - assert inst.identifier[0].system == "http://ema.europa.eu/example/MPID" - assert inst.identifier[0].value == "{mpid}" - assert inst.manufacturingBusinessOperation[ - 0 - ].authorisationReferenceNumber.system == ( - "http://ema.europa.eu/example/manufacturingAuthorisationRefer" "enceNumber" - ) - assert ( - inst.manufacturingBusinessOperation[0].authorisationReferenceNumber.value - == "1324TZ" - ) - assert inst.manufacturingBusinessOperation[ - 0 - ].effectiveDate == fhirtypes.DateTime.validate("2013-03-15T11:15:33+10:00") - assert ( - inst.manufacturingBusinessOperation[0].manufacturer[0].reference - == "Organization/example" - ) - assert ( - inst.manufacturingBusinessOperation[0].operationType.coding[0].code - == "Batchrelease" - ) - assert ( - inst.manufacturingBusinessOperation[0].operationType.coding[0].system - == "http://ema.europa.eu/example/manufacturingOperationType" - ) - assert ( - inst.manufacturingBusinessOperation[0].regulator.reference - == "Organization/example" - ) - assert inst.masterFile[0].reference == "DocumentReference/example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].countryLanguage[0].country.coding[0].code == "EU" - assert ( - inst.name[0].countryLanguage[0].country.coding[0].system - == "http://ema.europa.eu/example/countryCode" - ) - assert inst.name[0].countryLanguage[0].jurisdiction.coding[0].code == "EU" - assert ( - inst.name[0].countryLanguage[0].jurisdiction.coding[0].system - == "http://ema.europa.eu/example/jurisdictionCode" - ) - assert inst.name[0].countryLanguage[0].language.coding[0].code == "EN" - assert ( - inst.name[0].countryLanguage[0].language.coding[0].system - == "http://ema.europa.eu/example/languageCode" - ) - assert inst.name[0].namePart[0].part == "Equilidem" - assert inst.name[0].namePart[0].type.code == "INV" - assert inst.name[0].namePart[1].part == "2.5 mg" - assert inst.name[0].namePart[1].type.code == "STR" - assert inst.name[0].namePart[2].part == "film-coated tablets" - assert inst.name[0].namePart[2].type.code == "FRM" - assert inst.name[0].productName == "Equilidem 2.5 mg film-coated tablets" - assert inst.productClassification[0].coding[0].code == ( - "WHOAnatomicalTherapeuticChemicalATCClassificationSystem|B01A" "F02" - ) - assert inst.productClassification[0].coding[0].system == ( - "http://ema.europa.eu/example/WHOAnatomicalTherapeuticChemica" - "lATCClassificationSystem" - ) - assert inst.text.status == "generated" - - -def test_medicinalproduct_1(base_settings): - """No. 1 tests collection for MedicinalProduct. - Test File: medicinalproduct-example.json - """ - filename = base_settings["unittest_data_dir"] / "medicinalproduct-example.json" - inst = medicinalproduct.MedicinalProduct.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicinalProduct" == inst.resource_type - - impl_medicinalproduct_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicinalProduct" == data["resourceType"] - - inst2 = medicinalproduct.MedicinalProduct(**data) - impl_medicinalproduct_1(inst2) diff --git a/fhir/resources/tests/test_medicinalproductauthorization.py b/fhir/resources/tests/test_medicinalproductauthorization.py deleted file mode 100644 index adf9a0c3..00000000 --- a/fhir/resources/tests/test_medicinalproductauthorization.py +++ /dev/null @@ -1,130 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductAuthorization -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicinalproductauthorization - - -def impl_medicinalproductauthorization_1(inst): - assert inst.country[0].coding[0].code == "EU" - assert inst.country[0].coding[0].system == "http://ema.europa.eu/example/country" - assert inst.dataExclusivityPeriod.end == fhirtypes.DateTime.validate( - "2020-08-15T11:15:33+10:00" - ) - assert inst.dataExclusivityPeriod.start == fhirtypes.DateTime.validate( - "2010-08-15T11:15:33+10:00" - ) - assert inst.dateOfFirstAuthorization == fhirtypes.DateTime.validate( - "2010-08-15T11:15:33+10:00" - ) - assert inst.holder.reference == "Organization/example" - assert inst.id == "example" - assert ( - inst.identifier[0].system - == "http://ema.europa.eu/example/marketingAuthorisationNumber" - ) - assert inst.identifier[0].value == "EU/1/11/999/001" - assert inst.internationalBirthDate == fhirtypes.DateTime.validate( - "2010-08-15T11:15:33+10:00" - ) - assert inst.jurisdictionalAuthorization[0].country.coding[0].code == "NO" - assert ( - inst.jurisdictionalAuthorization[0].country.coding[0].system - == "http://ema.europa.eu/example/countryCode" - ) - assert inst.jurisdictionalAuthorization[0].id == "1" - assert ( - inst.jurisdictionalAuthorization[0].identifier[0].system - == "http://ema.europa.eu/example/marketingauthorisationnumber" - ) - assert inst.jurisdictionalAuthorization[0].identifier[0].value == "123-456-789" - assert inst.jurisdictionalAuthorization[1].country.coding[0].code == "NO" - assert ( - inst.jurisdictionalAuthorization[1].country.coding[0].system - == "http://ema.europa.eu/example/countryCode" - ) - assert inst.jurisdictionalAuthorization[1].id == "2" - assert ( - inst.jurisdictionalAuthorization[1].identifier[0].system - == "http://ema.europa.eu/example/marketingauthorisationnumber" - ) - assert inst.jurisdictionalAuthorization[1].identifier[0].value == "123-456-123" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.procedure.application[0].dateDateTime == fhirtypes.DateTime.validate( - "2015-08-01T11:15:33+10:00" - ) - assert ( - inst.procedure.application[0].identifier.system - == "http://ema.europa.eu/example/applicationidentifier-number" - ) - assert inst.procedure.application[0].identifier.value == "IA38G" - assert ( - inst.procedure.application[0].type.coding[0].code - == "GroupTypeIAVariationNotification" - ) - assert inst.procedure.application[0].type.coding[0].system == ( - "http://ema.europa.eu/example/marketingAuthorisationApplicati" "onType" - ) - assert inst.procedure.datePeriod.end == fhirtypes.DateTime.validate( - "2015-08-21T11:15:33+10:00" - ) - assert inst.procedure.datePeriod.start == fhirtypes.DateTime.validate( - "2015-08-02T11:15:33+10:00" - ) - assert ( - inst.procedure.identifier.system - == "http://ema.europa.eu/example/procedureidentifier-number" - ) - assert inst.procedure.identifier.value == "EMEA/H/C/009999/IA/0099/G" - assert inst.procedure.type.coding[0].code == "VariationTypeIA" - assert inst.procedure.type.coding[0].system == ( - "http://ema.europa.eu/example/marketingAuthorisationProcedure" "Type" - ) - assert inst.regulator.reference == "Organization/example" - assert inst.status.coding[0].code == "active" - assert ( - inst.status.coding[0].system - == "http://ema.europa.eu/example/authorisationstatus" - ) - assert inst.statusDate == fhirtypes.DateTime.validate("2015-01-14T11:15:33+10:00") - assert inst.text.status == "generated" - assert inst.validityPeriod.end == fhirtypes.DateTime.validate( - "2020-05-20T11:15:33+10:00" - ) - assert inst.validityPeriod.start == fhirtypes.DateTime.validate( - "2015-08-16T11:15:33+10:00" - ) - - -def test_medicinalproductauthorization_1(base_settings): - """No. 1 tests collection for MedicinalProductAuthorization. - Test File: medicinalproductauthorization-example.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "medicinalproductauthorization-example.json" - ) - inst = medicinalproductauthorization.MedicinalProductAuthorization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicinalProductAuthorization" == inst.resource_type - - impl_medicinalproductauthorization_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicinalProductAuthorization" == data["resourceType"] - - inst2 = medicinalproductauthorization.MedicinalProductAuthorization(**data) - impl_medicinalproductauthorization_1(inst2) diff --git a/fhir/resources/tests/test_medicinalproductcontraindication.py b/fhir/resources/tests/test_medicinalproductcontraindication.py deleted file mode 100644 index aec08eca..00000000 --- a/fhir/resources/tests/test_medicinalproductcontraindication.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductContraindication -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicinalproductcontraindication - - -def impl_medicinalproductcontraindication_1(inst): - assert inst.comorbidity[0].coding[0].code == "Hepaticdisease" - assert ( - inst.comorbidity[0].coding[0].system - == "http://ema.europa.eu/example/comorbidity" - ) - assert ( - inst.disease.coding[0].code - == "Coagulopathiesandbleedingdiatheses(exclthrombocytopenic)" - ) - assert inst.disease.coding[0].system == ( - "http://ema.europa.eu/example/contraindicationsasdisease-" "symptom-procedure" - ) - assert inst.disease.text == ( - "Hepatic disease associated with coagulopathy and clinically " - "relevant bleeding risk" - ) - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_medicinalproductcontraindication_1(base_settings): - """No. 1 tests collection for MedicinalProductContraindication. - Test File: medicinalproductcontraindication-example.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "medicinalproductcontraindication-example.json" - ) - inst = medicinalproductcontraindication.MedicinalProductContraindication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicinalProductContraindication" == inst.resource_type - - impl_medicinalproductcontraindication_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicinalProductContraindication" == data["resourceType"] - - inst2 = medicinalproductcontraindication.MedicinalProductContraindication(**data) - impl_medicinalproductcontraindication_1(inst2) diff --git a/fhir/resources/tests/test_medicinalproductindication.py b/fhir/resources/tests/test_medicinalproductindication.py deleted file mode 100644 index eb6efa99..00000000 --- a/fhir/resources/tests/test_medicinalproductindication.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductIndication -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicinalproductindication - - -def impl_medicinalproductindication_1(inst): - assert inst.comorbidity[0].coding[0].code == "Hipsurgery" - assert ( - inst.comorbidity[0].coding[0].system - == "http://ema.europa.eu/example/comorbidity" - ) - assert ( - inst.diseaseSymptomProcedure.coding[0].code - == "Venousthromboembolismprophylaxis" - ) - assert inst.diseaseSymptomProcedure.coding[0].system == ( - "http://ema.europa.eu/example/indicationasdisease-symptom-" "procedure" - ) - assert inst.id == "example" - assert inst.intendedEffect.coding[0].code == "PRYLX" - assert ( - inst.intendedEffect.coding[0].system - == "http://ema.europa.eu/example/intendedeffect" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.population[0].ageRange.low.unit == "a" - assert float(inst.population[0].ageRange.low.value) == float(18) - assert inst.text.status == "generated" - - -def test_medicinalproductindication_1(base_settings): - """No. 1 tests collection for MedicinalProductIndication. - Test File: medicinalproductindication-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "medicinalproductindication-example.json" - ) - inst = medicinalproductindication.MedicinalProductIndication.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicinalProductIndication" == inst.resource_type - - impl_medicinalproductindication_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicinalProductIndication" == data["resourceType"] - - inst2 = medicinalproductindication.MedicinalProductIndication(**data) - impl_medicinalproductindication_1(inst2) diff --git a/fhir/resources/tests/test_medicinalproductingredient.py b/fhir/resources/tests/test_medicinalproductingredient.py deleted file mode 100644 index 834b77e5..00000000 --- a/fhir/resources/tests/test_medicinalproductingredient.py +++ /dev/null @@ -1,67 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductIngredient -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicinalproductingredient - - -def impl_medicinalproductingredient_1(inst): - assert inst.id == "example" - assert inst.manufacturer[0].reference == "Organization/example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.role.coding[0].code == "ActiveBase" - assert inst.role.coding[0].system == "http://ema.europa.eu/example/ingredientRole" - assert ( - inst.specifiedSubstance[0].code.coding[0].code == "equixabanCompanyequixaban1" - ) - assert ( - inst.specifiedSubstance[0].code.coding[0].system - == "http://ema.europa.eu/example/specifiedSubstance" - ) - assert inst.specifiedSubstance[0].group.coding[0].code == "2" - assert ( - inst.specifiedSubstance[0].group.coding[0].system - == "http://ema.europa.eu/example/specifiedSubstanceGroup" - ) - assert inst.substance.code.coding[0].code == "EQUIXABAN" - assert ( - inst.substance.code.coding[0].system == "http://ema.europa.eu/example/substance" - ) - assert inst.substance.strength[0].presentation.denominator.unit == "{tablet}" - assert float(inst.substance.strength[0].presentation.denominator.value) == float(1) - assert inst.substance.strength[0].presentation.numerator.unit == "mg" - assert float(inst.substance.strength[0].presentation.numerator.value) == float(2.5) - assert inst.text.status == "generated" - - -def test_medicinalproductingredient_1(base_settings): - """No. 1 tests collection for MedicinalProductIngredient. - Test File: medicinalproductingredient-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "medicinalproductingredient-example.json" - ) - inst = medicinalproductingredient.MedicinalProductIngredient.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicinalProductIngredient" == inst.resource_type - - impl_medicinalproductingredient_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicinalProductIngredient" == data["resourceType"] - - inst2 = medicinalproductingredient.MedicinalProductIngredient(**data) - impl_medicinalproductingredient_1(inst2) diff --git a/fhir/resources/tests/test_medicinalproductinteraction.py b/fhir/resources/tests/test_medicinalproductinteraction.py deleted file mode 100644 index 62f8e15a..00000000 --- a/fhir/resources/tests/test_medicinalproductinteraction.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductInteraction -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicinalproductinteraction - - -def impl_medicinalproductinteraction_1(inst): - assert inst.effect.coding[0].code == "Increasedplasmaconcentrations" - assert ( - inst.effect.coding[0].system - == "http://ema.europa.eu/example/interactionseffect" - ) - assert inst.id == "example" - assert inst.interactant[0].itemCodeableConcept.coding[0].code == "ketoconazole" - assert ( - inst.interactant[0].itemCodeableConcept.coding[0].system - == "http://ema.europa.eu/example/interactant" - ) - assert inst.interactant[1].itemCodeableConcept.coding[0].code == "itraconazole" - assert ( - inst.interactant[1].itemCodeableConcept.coding[0].system - == "http://ema.europa.eu/example/interactant" - ) - assert inst.management.text == ( - "Coadministration not recommended in patients receiving " - "concomitant systemic treatment strong inhibitors of both " - "CYP3A4 and P-gp" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "StrongInhibitorofCYP3A4" - assert inst.type.coding[0].system == "http://ema.europa.eu/example/interactionsType" - - -def test_medicinalproductinteraction_1(base_settings): - """No. 1 tests collection for MedicinalProductInteraction. - Test File: medicinalproductinteraction-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "medicinalproductinteraction-example.json" - ) - inst = medicinalproductinteraction.MedicinalProductInteraction.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicinalProductInteraction" == inst.resource_type - - impl_medicinalproductinteraction_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicinalProductInteraction" == data["resourceType"] - - inst2 = medicinalproductinteraction.MedicinalProductInteraction(**data) - impl_medicinalproductinteraction_1(inst2) diff --git a/fhir/resources/tests/test_medicinalproductmanufactured.py b/fhir/resources/tests/test_medicinalproductmanufactured.py deleted file mode 100644 index c3ce3fe4..00000000 --- a/fhir/resources/tests/test_medicinalproductmanufactured.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductManufactured -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicinalproductmanufactured - - -def impl_medicinalproductmanufactured_1(inst): - assert inst.id == "example" - assert inst.ingredient[0].reference == "MedicinalProductIngredient/example" - assert inst.manufacturedDoseForm.coding[0].code == "Film-coatedtablet" - assert ( - inst.manufacturedDoseForm.coding[0].system - == "http://ema.europa.eu/example/manufactureddoseform" - ) - assert inst.manufacturer[0].reference == "Organization/example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.physicalCharacteristics.color[0] == "Pink" - assert inst.physicalCharacteristics.imprint[0] == "894" - assert inst.physicalCharacteristics.shape == "Oval" - assert inst.quantity.unit == "1" - assert float(inst.quantity.value) == float(10) - assert inst.text.status == "generated" - assert inst.unitOfPresentation.coding[0].code == "Tablet" - assert ( - inst.unitOfPresentation.coding[0].system - == "http://ema.europa.eu/example/unitofpresentation" - ) - - -def test_medicinalproductmanufactured_1(base_settings): - """No. 1 tests collection for MedicinalProductManufactured. - Test File: medicinalproductmanufactured-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "medicinalproductmanufactured-example.json" - ) - inst = medicinalproductmanufactured.MedicinalProductManufactured.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicinalProductManufactured" == inst.resource_type - - impl_medicinalproductmanufactured_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicinalProductManufactured" == data["resourceType"] - - inst2 = medicinalproductmanufactured.MedicinalProductManufactured(**data) - impl_medicinalproductmanufactured_1(inst2) diff --git a/fhir/resources/tests/test_medicinalproductpackaged.py b/fhir/resources/tests/test_medicinalproductpackaged.py deleted file mode 100644 index b428b4e7..00000000 --- a/fhir/resources/tests/test_medicinalproductpackaged.py +++ /dev/null @@ -1,144 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductPackaged -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicinalproductpackaged - - -def impl_medicinalproductpackaged_1(inst): - assert inst.batchIdentifier[ - 0 - ].outerPackaging.period.end == fhirtypes.DateTime.validate( - "2016-06-06T11:15:33+10:00" - ) - assert ( - inst.batchIdentifier[0].outerPackaging.system - == "http://ema.europa.eu/example/baid1" - ) - assert inst.batchIdentifier[0].outerPackaging.value == "AAF5699" - assert ( - inst.description == "ALU-PVC/PVDC BLISTERS. CARTONS OF 10 FILM-COATED TABLETS. " - ) - assert inst.id == "example" - assert inst.identifier[0].system == "http://ema.europa.eu/example/pcid" - assert inst.identifier[0].value == "{PCID}" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.packageItem[0].manufacturer[0].reference == "Organization/example" - assert inst.packageItem[0].material[0].coding[0].code == "PVC" - assert ( - inst.packageItem[0].material[0].coding[0].system - == "http://ema.europa.eu/example/packageItemContainerMaterial" - ) - assert inst.packageItem[0].material[1].coding[0].code == "PVDC" - assert ( - inst.packageItem[0].material[1].coding[0].system - == "http://ema.europa.eu/example/packageItemContainerMaterial" - ) - assert inst.packageItem[0].material[2].coding[0].code == "alu" - assert ( - inst.packageItem[0].material[2].coding[0].system - == "http://ema.europa.eu/example/packageItemContainerMaterial" - ) - assert ( - inst.packageItem[0].packageItem[0].manufacturedItem[0].reference - == "MedicinalProductManufactured/example" - ) - assert ( - inst.packageItem[0].packageItem[0].manufacturer[0].reference - == "Organization/example" - ) - assert inst.packageItem[0].packageItem[0].material[0].coding[0].code == "Paperboard" - assert ( - inst.packageItem[0].packageItem[0].material[0].coding[0].system - == "http://ema.europa.eu/example/packageItemContainerMaterial" - ) - assert ( - inst.packageItem[0].packageItem[0].physicalCharacteristics.height.unit == "mm" - ) - assert float( - inst.packageItem[0].packageItem[0].physicalCharacteristics.height.value - ) == float(125) - assert inst.packageItem[0].packageItem[0].physicalCharacteristics.width.unit == "mm" - assert float( - inst.packageItem[0].packageItem[0].physicalCharacteristics.width.value - ) == float(45) - assert inst.packageItem[0].packageItem[0].quantity.unit == "1" - assert float(inst.packageItem[0].packageItem[0].quantity.value) == float(1) - assert inst.packageItem[0].packageItem[0].shelfLifeStorage[0].period.unit == "a" - assert float( - inst.packageItem[0].packageItem[0].shelfLifeStorage[0].period.value - ) == float(3) - assert inst.packageItem[0].packageItem[0].shelfLifeStorage[ - 0 - ].specialPrecautionsForStorage[0].coding[0].code == ( - "Thismedicinalproductdoesnotrequireanyspecialstoragecondition" "." - ) - assert ( - inst.packageItem[0] - .packageItem[0] - .shelfLifeStorage[0] - .specialPrecautionsForStorage[0] - .coding[0] - .system - == "http://ema.europa.eu/example/specialprecautionsforstorage" - ) - assert ( - inst.packageItem[0].packageItem[0].shelfLifeStorage[0].type.coding[0].code - == "ShelfLifeofPackagedMedicinalProduct" - ) - assert ( - inst.packageItem[0].packageItem[0].shelfLifeStorage[0].type.coding[0].system - == "http://ema.europa.eu/example/shelfLifeTypePlaceHolder" - ) - assert inst.packageItem[0].packageItem[0].type.coding[0].code == "Blister" - assert ( - inst.packageItem[0].packageItem[0].type.coding[0].system - == "http://ema.europa.eu/example/packageitemcontainertype" - ) - assert inst.packageItem[0].physicalCharacteristics.depth.unit == "mm" - assert float(inst.packageItem[0].physicalCharacteristics.depth.value) == float(23.5) - assert inst.packageItem[0].physicalCharacteristics.height.unit == "mm" - assert float(inst.packageItem[0].physicalCharacteristics.height.value) == float(50) - assert inst.packageItem[0].physicalCharacteristics.width.unit == "mm" - assert float(inst.packageItem[0].physicalCharacteristics.width.value) == float(136) - assert inst.packageItem[0].quantity.unit == "1" - assert float(inst.packageItem[0].quantity.value) == float(1) - assert inst.packageItem[0].type.coding[0].code == "Carton" - assert ( - inst.packageItem[0].type.coding[0].system - == "http://ema.europa.eu/example/packageitemcontainertype" - ) - assert inst.text.status == "generated" - - -def test_medicinalproductpackaged_1(base_settings): - """No. 1 tests collection for MedicinalProductPackaged. - Test File: medicinalproductpackaged-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "medicinalproductpackaged-example.json" - ) - inst = medicinalproductpackaged.MedicinalProductPackaged.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicinalProductPackaged" == inst.resource_type - - impl_medicinalproductpackaged_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicinalProductPackaged" == data["resourceType"] - - inst2 = medicinalproductpackaged.MedicinalProductPackaged(**data) - impl_medicinalproductpackaged_1(inst2) diff --git a/fhir/resources/tests/test_medicinalproductpharmaceutical.py b/fhir/resources/tests/test_medicinalproductpharmaceutical.py deleted file mode 100644 index 73dd0ed6..00000000 --- a/fhir/resources/tests/test_medicinalproductpharmaceutical.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductPharmaceutical -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicinalproductpharmaceutical - - -def impl_medicinalproductpharmaceutical_1(inst): - assert inst.administrableDoseForm.coding[0].code == "Film-coatedtablet" - assert ( - inst.administrableDoseForm.coding[0].system - == "http://ema.europa.eu/example/administrabledoseform" - ) - assert inst.id == "example" - assert ( - inst.identifier[0].system == "http://ema.europa.eu/example/phpididentifiersets" - ) - assert inst.identifier[0].value == "{PhPID}" - assert inst.ingredient[0].reference == "MedicinalProductIngredient/example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.routeOfAdministration[0].code.coding[0].code == "OralUse" - assert ( - inst.routeOfAdministration[0].code.coding[0].system - == "http://ema.europa.eu/example/routeofadministration" - ) - assert inst.text.status == "generated" - assert inst.unitOfPresentation.coding[0].code == "Tablet" - assert ( - inst.unitOfPresentation.coding[0].system - == "http://ema.europa.eu/example/unitofpresentation" - ) - - -def test_medicinalproductpharmaceutical_1(base_settings): - """No. 1 tests collection for MedicinalProductPharmaceutical. - Test File: medicinalproductpharmaceutical-example.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "medicinalproductpharmaceutical-example.json" - ) - inst = medicinalproductpharmaceutical.MedicinalProductPharmaceutical.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MedicinalProductPharmaceutical" == inst.resource_type - - impl_medicinalproductpharmaceutical_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicinalProductPharmaceutical" == data["resourceType"] - - inst2 = medicinalproductpharmaceutical.MedicinalProductPharmaceutical(**data) - impl_medicinalproductpharmaceutical_1(inst2) diff --git a/fhir/resources/tests/test_medicinalproductundesirableeffect.py b/fhir/resources/tests/test_medicinalproductundesirableeffect.py deleted file mode 100644 index 3305049c..00000000 --- a/fhir/resources/tests/test_medicinalproductundesirableeffect.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MedicinalProductUndesirableEffect -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import medicinalproductundesirableeffect - - -def impl_medicinalproductundesirableeffect_1(inst): - assert inst.classification.coding[0].code == "Bloodandlymphaticsystemdisorders" - assert inst.classification.coding[0].system == ( - "http://ema.europa.eu/example/symptom-condition-" "effectclassification" - ) - assert inst.frequencyOfOccurrence.coding[0].code == "Common" - assert ( - inst.frequencyOfOccurrence.coding[0].system - == "http://ema.europa.eu/example/frequencyofoccurrence" - ) - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.symptomConditionEffect.coding[0].code == "Anaemia" - assert inst.symptomConditionEffect.coding[0].system == ( - "http://ema.europa.eu/example/undesirableeffectassymptom-" "condition-effect" - ) - assert inst.symptomConditionEffect.text == ( - "Prevention of\\nVTE in adult\\npatients who " - "have\\nundergone\\nelective hip or\\nknee " - "replacement\\nsurgery (VTEp)" - ) - assert inst.text.status == "generated" - - -def test_medicinalproductundesirableeffect_1(base_settings): - """No. 1 tests collection for MedicinalProductUndesirableEffect. - Test File: medicinalproductundesirableeffect-example.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "medicinalproductundesirableeffect-example.json" - ) - inst = ( - medicinalproductundesirableeffect.MedicinalProductUndesirableEffect.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - ) - assert "MedicinalProductUndesirableEffect" == inst.resource_type - - impl_medicinalproductundesirableeffect_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MedicinalProductUndesirableEffect" == data["resourceType"] - - inst2 = medicinalproductundesirableeffect.MedicinalProductUndesirableEffect(**data) - impl_medicinalproductundesirableeffect_1(inst2) diff --git a/fhir/resources/tests/test_messagedefinition.py b/fhir/resources/tests/test_messagedefinition.py deleted file mode 100644 index dd169544..00000000 --- a/fhir/resources/tests/test_messagedefinition.py +++ /dev/null @@ -1,205 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MessageDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import messagedefinition - - -def impl_messagedefinition_1(inst): - assert inst.category == "notification" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2016-11-09T11:15:33+10:00") - assert inst.eventCoding.code == "admin-notify" - assert inst.eventCoding.system == "http://example.org/fhir/message-events" - assert inst.experimental is True - assert inst.id == "example" - assert inst.name == "EXAMPLE" - assert inst.publisher == "Health Level Seven, Int'l" - assert inst.purpose == ( - "Defines a base example for other MessageDefinition " "instances." - ) - assert inst.status == "draft" - assert inst.text.div == ( - '
Message ' - "definition base example
" - ) - assert inst.text.status == "generated" - assert inst.title == "Message definition base example" - assert inst.url == "http://hl7.org/fhir/MessageDefinition/example" - - -def test_messagedefinition_1(base_settings): - """No. 1 tests collection for MessageDefinition. - Test File: messagedefinition-example.json - """ - filename = base_settings["unittest_data_dir"] / "messagedefinition-example.json" - inst = messagedefinition.MessageDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MessageDefinition" == inst.resource_type - - impl_messagedefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MessageDefinition" == data["resourceType"] - - inst2 = messagedefinition.MessageDefinition(**data) - impl_messagedefinition_1(inst2) - - -def impl_messagedefinition_2(inst): - assert inst.allowedResponse[0].message == "MessageDefinition/patient-link-response" - assert inst.allowedResponse[0].situation == ( - "Optional response message that may provide additional " "information" - ) - assert inst.base == "MessageDefinition/example" - assert inst.category == "notification" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org" - assert inst.copyright == "� HL7.org 2011+" - assert inst.date == fhirtypes.DateTime.validate("2017-02-03T11:15:33+10:00") - assert inst.description == ( - "Notification of two patient records that represent the same " - "individual that require an established linkage." - ) - assert inst.eventCoding.code == "admin-notify" - assert inst.eventCoding.system == "http://example.org/fhir/message-events" - assert inst.experimental is True - assert inst.focus[0].code == "Patient" - assert inst.focus[0].max == "2" - assert inst.focus[0].min == 2 - assert inst.focus[0].profile == "StructureDefinition/example" - assert inst.id == "patient-link-notification" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9878" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America (the)" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.name == "PATIENT-LINK-NOTIFICATION" - assert inst.publisher == "Health Level Seven, Int'l" - assert inst.purpose == ( - "Notifies recipient systems that two patients have been " - "'linked' - meaning they represent the same individual" - ) - assert inst.status == "draft" - assert inst.text.div == ( - '
Link Patients ' "Notification
" - ) - assert inst.text.status == "generated" - assert inst.title == "Link Patients Notification" - assert inst.url == ( - "http://hl7.org/fhir/MessageDefinition/patient-link-" "notification" - ) - assert inst.useContext[0].code.code == "focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "positive" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://terminology.hl7.org/CodeSystem/variant-state" - ) - assert inst.version == "1" - - -def test_messagedefinition_2(base_settings): - """No. 2 tests collection for MessageDefinition. - Test File: messagedefinition-patient-link-notification.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "messagedefinition-patient-link-notification.json" - ) - inst = messagedefinition.MessageDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MessageDefinition" == inst.resource_type - - impl_messagedefinition_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MessageDefinition" == data["resourceType"] - - inst2 = messagedefinition.MessageDefinition(**data) - impl_messagedefinition_2(inst2) - - -def impl_messagedefinition_3(inst): - assert inst.base == "MessageDefinition/example" - assert inst.category == "consequence" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org" - assert inst.copyright == "� HL7.org 2011+" - assert inst.date == fhirtypes.DateTime.validate("2017-02-03T11:15:33+10:00") - assert inst.description == "Optional response to a patient link notification." - assert inst.eventCoding.code == "admin-notify" - assert inst.eventCoding.system == "http://example.org/fhir/message-events" - assert inst.experimental is True - assert inst.focus[0].code == "Patient" - assert inst.focus[0].max == "2" - assert inst.focus[0].min == 2 - assert inst.focus[0].profile == "StructureDefinition/example" - assert inst.id == "patient-link-response" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9879" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America (the)" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.name == "PATIENT-LINK-RESPONSE" - assert inst.publisher == "Health Level Seven, Int'l" - assert inst.purpose == ( - "Optional response message that may provide additional " - "information on the outcome of the patient link operation." - ) - assert inst.status == "draft" - assert inst.text.div == ( - '
Link Patients ' "Response
" - ) - assert inst.text.status == "generated" - assert inst.title == "Link Patients Response" - assert inst.url == "http://hl7.org/fhir/MessageDefinition/patient-link-response" - assert inst.useContext[0].code.code == "focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "positive" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://terminology.hl7.org/CodeSystem/variant-state" - ) - assert inst.version == "1" - - -def test_messagedefinition_3(base_settings): - """No. 3 tests collection for MessageDefinition. - Test File: messagedefinition-patient-link-response.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "messagedefinition-patient-link-response.json" - ) - inst = messagedefinition.MessageDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MessageDefinition" == inst.resource_type - - impl_messagedefinition_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MessageDefinition" == data["resourceType"] - - inst2 = messagedefinition.MessageDefinition(**data) - impl_messagedefinition_3(inst2) diff --git a/fhir/resources/tests/test_messageheader.py b/fhir/resources/tests/test_messageheader.py deleted file mode 100644 index b707b0c9..00000000 --- a/fhir/resources/tests/test_messageheader.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MessageHeader -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import messageheader - - -def impl_messageheader_1(inst): - assert inst.author.reference == "Practitioner/example" - assert ( - inst.definition == "http:////acme.com/ehr/fhir/messagedefinition/patientrequest" - ) - assert inst.destination[0].endpoint == "llp:10.11.12.14:5432" - assert inst.destination[0].name == "Acme Message Gateway" - assert ( - inst.destination[0].receiver.reference - == "http://acme.com/ehr/fhir/Practitioner/2323-33-4" - ) - assert inst.destination[0].target.reference == "Device/example" - assert inst.enterer.reference == "Practitioner/example" - assert inst.eventCoding.code == "admin-notify" - assert inst.eventCoding.system == "http://example.org/fhir/message-events" - assert inst.focus[0].reference == "Patient/example" - assert inst.id == "1cbdfb97-5859-48a4-8301-d54eab818d68" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.reason.coding[0].code == "admit" - assert inst.reason.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/message-reasons-" "encounter" - ) - assert inst.response.code == "ok" - assert inst.response.identifier == "5015fe84-8e76-4526-89d8-44b322e8d4fb" - assert inst.sender.reference == "Organization/1" - assert inst.source.contact.system == "phone" - assert inst.source.contact.value == "+1 (555) 123 4567" - assert inst.source.endpoint == "llp:10.11.12.13:5432" - assert inst.source.name == "Acme Central Patient Registry" - assert inst.source.software == "FooBar Patient Manager" - assert inst.source.version == "3.1.45.AABB" - assert inst.text.status == "generated" - - -def test_messageheader_1(base_settings): - """No. 1 tests collection for MessageHeader. - Test File: messageheader-example.json - """ - filename = base_settings["unittest_data_dir"] / "messageheader-example.json" - inst = messageheader.MessageHeader.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MessageHeader" == inst.resource_type - - impl_messageheader_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MessageHeader" == data["resourceType"] - - inst2 = messageheader.MessageHeader(**data) - impl_messageheader_1(inst2) diff --git a/fhir/resources/tests/test_molecularsequence.py b/fhir/resources/tests/test_molecularsequence.py deleted file mode 100644 index 7d7c563c..00000000 --- a/fhir/resources/tests/test_molecularsequence.py +++ /dev/null @@ -1,568 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/MolecularSequence -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import molecularsequence - - -def impl_molecularsequence_1(inst): - assert inst.coordinateSystem == 0 - assert inst.id == "breastcancer" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/brcapat" - assert inst.referenceSeq.referenceSeqId.coding[0].code == "NM_000059.3" - assert ( - inst.referenceSeq.referenceSeqId.coding[0].display - == "Homo sapiens BRCA2, DNA repair associated (BRCA2), mRNA" - ) - assert ( - inst.referenceSeq.referenceSeqId.coding[0].system - == "http://www.ncbi.nlm.nih.gov/nuccore/" - ) - assert inst.referenceSeq.windowEnd == 101499444 - assert inst.referenceSeq.windowStart == 101488058 - assert inst.text.status == "generated" - assert inst.type == "rna" - assert inst.variant[0].end == 32316187 - assert inst.variant[0].observedAllele == "A" - assert inst.variant[0].referenceAllele == "C" - assert inst.variant[0].start == 32316186 - - -def test_molecularsequence_1(base_settings): - """No. 1 tests collection for MolecularSequence. - Test File: sequence-genetics-example-breastcancer.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "sequence-genetics-example-breastcancer.json" - ) - inst = molecularsequence.MolecularSequence.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MolecularSequence" == inst.resource_type - - impl_molecularsequence_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MolecularSequence" == data["resourceType"] - - inst2 = molecularsequence.MolecularSequence(**data) - impl_molecularsequence_1(inst2) - - -def impl_molecularsequence_2(inst): - assert inst.coordinateSystem == 0 - assert inst.id == "graphic-example-1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.pointer[0].reference == "MolecularSequence/graphic-example-2" - assert inst.referenceSeq.referenceSeqId.coding[0].code == "NC_000002.12" - assert ( - inst.referenceSeq.referenceSeqId.coding[0].system - == "http://www.ncbi.nlm.nih.gov/nuccore" - ) - assert inst.referenceSeq.strand == "watson" - assert inst.referenceSeq.windowEnd == 128273732 - assert inst.referenceSeq.windowStart == 128273724 - assert inst.text.status == "generated" - assert inst.type == "dna" - assert inst.variant[0].cigar == "1M" - assert inst.variant[0].end == 128273726 - assert inst.variant[0].observedAllele == "G" - assert inst.variant[0].referenceAllele == "T" - assert inst.variant[0].start == 128273725 - - -def test_molecularsequence_2(base_settings): - """No. 2 tests collection for MolecularSequence. - Test File: sequence-graphic-example-1.json - """ - filename = base_settings["unittest_data_dir"] / "sequence-graphic-example-1.json" - inst = molecularsequence.MolecularSequence.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MolecularSequence" == inst.resource_type - - impl_molecularsequence_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MolecularSequence" == data["resourceType"] - - inst2 = molecularsequence.MolecularSequence(**data) - impl_molecularsequence_2(inst2) - - -def impl_molecularsequence_3(inst): - assert inst.coordinateSystem == 1 - assert inst.id == "fda-vcfeval-comparison" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.quality[0].end == 101770080 - assert float(inst.quality[0].gtFP) == float(2186) - assert inst.quality[0].method.coding[0].code == "app-BxfGF8j02pBZzZxbzZxP725P" - assert inst.quality[0].method.coding[0].system == "https://precision.fda.gov/apps/" - assert inst.quality[0].method.text == "Vcfeval + Hap.py Comparison" - assert float(inst.quality[0].precision) == float(0.428005) - assert float(inst.quality[0].queryFP) == float(10670) - assert float(inst.quality[0].recall) == float(0.752111) - assert ( - inst.quality[0].standardSequence.coding[0].code - == "file-BkZxBZ00bpJVk2q6x43b1YBx" - ) - assert ( - inst.quality[0].standardSequence.coding[0].system - == "https://precision.fda.gov/files/" - ) - assert inst.quality[0].start == 10453 - assert float(inst.quality[0].truthFN) == float(2554) - assert float(inst.quality[0].truthTP) == float(7749) - assert inst.quality[0].type == "indel" - assert inst.quality[1].end == 101770080 - assert float(inst.quality[1].gtFP) == float(493) - assert inst.quality[1].method.coding[0].code == "app-BxfGF8j02pBZzZxbzZxP725P" - assert inst.quality[1].method.coding[0].system == "https://precision.fda.gov/apps/" - assert inst.quality[1].method.text == "Vcfeval + Hap.py Comparison" - assert float(inst.quality[1].precision) == float(0.808602) - assert float(inst.quality[1].queryFP) == float(21744) - assert float(inst.quality[1].recall) == float(0.986642) - assert ( - inst.quality[1].standardSequence.coding[0].code - == "file-BkZxBZ00bpJVk2q6x43b1YBx" - ) - assert ( - inst.quality[1].standardSequence.coding[0].system - == "https://precision.fda.gov/files/" - ) - assert inst.quality[1].start == 10453 - assert float(inst.quality[1].truthFN) == float(1247) - assert float(inst.quality[1].truthTP) == float(92106) - assert inst.quality[1].type == "snp" - assert inst.referenceSeq.referenceSeqId.coding[0].code == "NC_000001.11" - assert ( - inst.referenceSeq.referenceSeqId.coding[0].system - == "http://www.ncbi.nlm.nih.gov/nuccore" - ) - assert inst.referenceSeq.strand == "watson" - assert inst.referenceSeq.windowEnd == 101770080 - assert inst.referenceSeq.windowStart == 10453 - assert inst.repository[0].name == "FDA" - assert inst.repository[0].type == "login" - assert ( - inst.repository[0].url - == "https://precision.fda.gov/jobs/job-ByxYPx809jFVy21KJG74Jg3Y" - ) - assert inst.text.status == "generated" - assert inst.variant[0].end == 13117 - assert inst.variant[0].observedAllele == "T" - assert inst.variant[0].referenceAllele == "G" - assert inst.variant[0].start == 13116 - - -def test_molecularsequence_3(base_settings): - """No. 3 tests collection for MolecularSequence. - Test File: sequence-example-fda-vcfeval.json - """ - filename = base_settings["unittest_data_dir"] / "sequence-example-fda-vcfeval.json" - inst = molecularsequence.MolecularSequence.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MolecularSequence" == inst.resource_type - - impl_molecularsequence_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MolecularSequence" == data["resourceType"] - - inst2 = molecularsequence.MolecularSequence(**data) - impl_molecularsequence_3(inst2) - - -def impl_molecularsequence_4(inst): - assert inst.coordinateSystem == 1 - assert inst.device.display == "12 lead EKG Device Metric" - assert inst.id == "sequence-complex-variant" - assert inst.identifier[0].use == "official" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer.display == "HL7" - assert inst.performer.reference == "Organization/hl7" - assert float(inst.quantity.value) == float(25) - assert inst.readCoverage == 1 - assert inst.referenceSeq.referenceSeqId.coding[0].code == "NC_000002.12" - assert ( - inst.referenceSeq.referenceSeqId.coding[0].system - == "http://www.ncbi.nlm.nih.gov/nuccore" - ) - assert inst.referenceSeq.strand == "watson" - assert inst.referenceSeq.windowEnd == 128273754 - assert inst.referenceSeq.windowStart == 128273724 - assert inst.repository[0].datasetId == "Ensembl" - assert inst.repository[0].readsetId == "v1beta2" - assert inst.repository[0].type == "other" - assert inst.specimen.display == "Molecular Specimen ID: MLD45-Z4-1234" - assert inst.specimen.reference == "Specimen/genetics-example1-somatic" - assert inst.text.status == "generated" - assert inst.type == "dna" - assert inst.variant[0].cigar == "3M1D4M6N2M" - assert inst.variant[0].end == 128273736 - assert inst.variant[0].observedAllele == "CTCATTGT" - assert inst.variant[0].referenceAllele == "CTCCATTGCATGCGTT" - assert inst.variant[0].start == 128273724 - - -def test_molecularsequence_4(base_settings): - """No. 4 tests collection for MolecularSequence. - Test File: sequence-complex-variant.json - """ - filename = base_settings["unittest_data_dir"] / "sequence-complex-variant.json" - inst = molecularsequence.MolecularSequence.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MolecularSequence" == inst.resource_type - - impl_molecularsequence_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MolecularSequence" == data["resourceType"] - - inst2 = molecularsequence.MolecularSequence(**data) - impl_molecularsequence_4(inst2) - - -def impl_molecularsequence_5(inst): - assert inst.coordinateSystem == 1 - assert inst.id == "example-TPMT-one" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.observedSeq == "T-C-C-C-A-C-C-C" - assert inst.patient.reference == "Patient/example" - assert inst.referenceSeq.referenceSeqId.coding[0].code == "NT_007592.15" - assert ( - inst.referenceSeq.referenceSeqId.coding[0].system - == "http://www.ncbi.nlm.nih.gov/nuccore" - ) - assert inst.referenceSeq.strand == "watson" - assert inst.referenceSeq.windowEnd == 18143955 - assert inst.referenceSeq.windowStart == 18130918 - assert inst.text.status == "generated" - assert inst.type == "dna" - assert inst.variant[0].end == 18139214 - assert inst.variant[0].observedAllele == "A" - assert inst.variant[0].referenceAllele == "G" - assert inst.variant[0].start == 18139214 - - -def test_molecularsequence_5(base_settings): - """No. 5 tests collection for MolecularSequence. - Test File: sequence-example-TPMT-one.json - """ - filename = base_settings["unittest_data_dir"] / "sequence-example-TPMT-one.json" - inst = molecularsequence.MolecularSequence.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MolecularSequence" == inst.resource_type - - impl_molecularsequence_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MolecularSequence" == data["resourceType"] - - inst2 = molecularsequence.MolecularSequence(**data) - impl_molecularsequence_5(inst2) - - -def impl_molecularsequence_6(inst): - assert inst.coordinateSystem == 0 - assert inst.id == "example-pgx-2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.referenceSeq.orientation == "sense" - assert inst.referenceSeq.referenceSeqId.coding[0].code == "NG_007726.3" - assert ( - inst.referenceSeq.referenceSeqId.coding[0].system - == "http://www.ncbi.nlm.nih.gov/nuccore" - ) - assert inst.referenceSeq.strand == "watson" - assert inst.referenceSeq.windowEnd == 55227980 - assert inst.referenceSeq.windowStart == 55227970 - assert inst.text.status == "generated" - assert inst.type == "dna" - assert inst.variant[0].end == 55227979 - assert inst.variant[0].observedAllele == "G" - assert inst.variant[0].referenceAllele == "T" - assert inst.variant[0].start == 55227978 - assert inst.variant[0].variantPointer.display == "Target Haplotype Observation" - assert inst.variant[0].variantPointer.reference == "Observation/example-haplotype2" - - -def test_molecularsequence_6(base_settings): - """No. 6 tests collection for MolecularSequence. - Test File: sequence-example-pgx-2.json - """ - filename = base_settings["unittest_data_dir"] / "sequence-example-pgx-2.json" - inst = molecularsequence.MolecularSequence.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MolecularSequence" == inst.resource_type - - impl_molecularsequence_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MolecularSequence" == data["resourceType"] - - inst2 = molecularsequence.MolecularSequence(**data) - impl_molecularsequence_6(inst2) - - -def impl_molecularsequence_7(inst): - assert inst.coordinateSystem == 0 - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.referenceSeq.referenceSeqId.coding[0].code == "NC_000009.11" - assert ( - inst.referenceSeq.referenceSeqId.coding[0].system - == "http://www.ncbi.nlm.nih.gov/nuccore" - ) - assert inst.referenceSeq.strand == "watson" - assert inst.referenceSeq.windowEnd == 22125510 - assert inst.referenceSeq.windowStart == 22125500 - assert inst.repository[0].name == "GA4GH API" - assert inst.repository[0].type == "openapi" - assert inst.repository[0].url == ( - "http://grch37.rest.ensembl.org/ga4gh/variants/3:rs1333049?co" - "ntent-type=application/json" - ) - assert inst.repository[0].variantsetId == "3:rs1333049" - assert inst.text.status == "generated" - assert inst.type == "dna" - assert inst.variant[0].end == 22125504 - assert inst.variant[0].observedAllele == "C" - assert inst.variant[0].referenceAllele == "G" - assert inst.variant[0].start == 22125503 - - -def test_molecularsequence_7(base_settings): - """No. 7 tests collection for MolecularSequence. - Test File: molecularsequence-example.json - """ - filename = base_settings["unittest_data_dir"] / "molecularsequence-example.json" - inst = molecularsequence.MolecularSequence.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MolecularSequence" == inst.resource_type - - impl_molecularsequence_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MolecularSequence" == data["resourceType"] - - inst2 = molecularsequence.MolecularSequence(**data) - impl_molecularsequence_7(inst2) - - -def impl_molecularsequence_8(inst): - assert inst.coordinateSystem == 1 - assert inst.id == "fda-example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.quality[0].end == 101770080 - assert float(inst.quality[0].fScore) == float(0.545551) - assert float(inst.quality[0].gtFP) == float(2186) - assert inst.quality[0].method.coding[0].code == "job-ByxYPx809jFVy21KJG74Jg3Y" - assert inst.quality[0].method.coding[0].system == "https://precision.fda.gov/jobs/" - assert inst.quality[0].method.text == "Vcfeval + Hap.py Comparison" - assert float(inst.quality[0].precision) == float(0.428005) - assert float(inst.quality[0].queryFP) == float(10670) - assert float(inst.quality[0].queryTP) == float(7984) - assert float(inst.quality[0].recall) == float(0.752111) - assert ( - inst.quality[0].standardSequence.coding[0].code - == "file-Bk50V4Q0qVb65P0v2VPbfYPZ" - ) - assert ( - inst.quality[0].standardSequence.coding[0].system - == "https://precision.fda.gov/files/" - ) - assert inst.quality[0].start == 10453 - assert float(inst.quality[0].truthFN) == float(2554) - assert float(inst.quality[0].truthTP) == float(7749) - assert inst.quality[0].type == "snp" - assert inst.referenceSeq.referenceSeqId.coding[0].code == "NC_000001.11" - assert ( - inst.referenceSeq.referenceSeqId.coding[0].system - == "http://www.ncbi.nlm.nih.gov/nuccore" - ) - assert inst.referenceSeq.strand == "watson" - assert inst.referenceSeq.windowEnd == 101770080 - assert inst.referenceSeq.windowStart == 10453 - assert inst.repository[0].name == "FDA" - assert inst.repository[0].type == "login" - assert inst.repository[0].url == ( - "https://precision.fda.gov/files/file-" "Bx37ZK009P4bX5g3qjkFZV38" - ) - assert inst.repository[0].variantsetId == "file-Bx37ZK009P4bX5g3qjkFZV38" - assert inst.text.status == "generated" - assert inst.type == "dna" - assert inst.variant[0].end == 13117 - assert inst.variant[0].observedAllele == "T" - assert inst.variant[0].referenceAllele == "G" - assert inst.variant[0].start == 13116 - - -def test_molecularsequence_8(base_settings): - """No. 8 tests collection for MolecularSequence. - Test File: sequence-example-fda.json - """ - filename = base_settings["unittest_data_dir"] / "sequence-example-fda.json" - inst = molecularsequence.MolecularSequence.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MolecularSequence" == inst.resource_type - - impl_molecularsequence_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MolecularSequence" == data["resourceType"] - - inst2 = molecularsequence.MolecularSequence(**data) - impl_molecularsequence_8(inst2) - - -def impl_molecularsequence_9(inst): - assert inst.coordinateSystem == 1 - assert inst.id == "coord-1-base" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.observedSeq == "ACATGGTAGC" - assert inst.referenceSeq.referenceSeqString == "ACGTAGTC" - assert inst.referenceSeq.strand == "watson" - assert inst.referenceSeq.windowEnd == 8 - assert inst.referenceSeq.windowStart == 1 - assert inst.text.status == "generated" - assert inst.type == "dna" - assert inst.variant[0].cigar == "3I" - assert inst.variant[0].end == 3 - assert inst.variant[0].observedAllele == "ATG" - assert inst.variant[0].referenceAllele == "-" - assert inst.variant[0].start == 2 - assert inst.variant[1].cigar == "3I" - assert inst.variant[1].end == 5 - assert inst.variant[1].observedAllele == "T" - assert inst.variant[1].referenceAllele == "A" - assert inst.variant[1].start == 5 - assert inst.variant[2].cigar == "1D" - assert inst.variant[2].end == 7 - assert inst.variant[2].observedAllele == "-" - assert inst.variant[2].referenceAllele == "T" - assert inst.variant[2].start == 7 - - -def test_molecularsequence_9(base_settings): - """No. 9 tests collection for MolecularSequence. - Test File: coord-1base-example.json - """ - filename = base_settings["unittest_data_dir"] / "coord-1base-example.json" - inst = molecularsequence.MolecularSequence.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MolecularSequence" == inst.resource_type - - impl_molecularsequence_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MolecularSequence" == data["resourceType"] - - inst2 = molecularsequence.MolecularSequence(**data) - impl_molecularsequence_9(inst2) - - -def impl_molecularsequence_10(inst): - assert inst.coordinateSystem == 0 - assert inst.id == "graphic-example-4" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.referenceSeq.chromosome.coding[0].code == "2" - assert inst.referenceSeq.chromosome.coding[0].display == "chromosome 2" - assert ( - inst.referenceSeq.chromosome.coding[0].system - == "http://terminology.hl7.org/CodeSystem/chromosome-human" - ) - assert inst.referenceSeq.genomeBuild == "GRCh 38" - assert inst.referenceSeq.strand == "watson" - assert inst.referenceSeq.windowEnd == 128273740 - assert inst.referenceSeq.windowStart == 128273736 - assert inst.text.status == "generated" - assert inst.type == "dna" - - -def test_molecularsequence_10(base_settings): - """No. 10 tests collection for MolecularSequence. - Test File: sequence-graphic-example-4.json - """ - filename = base_settings["unittest_data_dir"] / "sequence-graphic-example-4.json" - inst = molecularsequence.MolecularSequence.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "MolecularSequence" == inst.resource_type - - impl_molecularsequence_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "MolecularSequence" == data["resourceType"] - - inst2 = molecularsequence.MolecularSequence(**data) - impl_molecularsequence_10(inst2) diff --git a/fhir/resources/tests/test_namingsystem.py b/fhir/resources/tests/test_namingsystem.py deleted file mode 100644 index 32bbfa56..00000000 --- a/fhir/resources/tests/test_namingsystem.py +++ /dev/null @@ -1,117 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/NamingSystem -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import namingsystem - - -def impl_namingsystem_1(inst): - assert inst.contact[0].name == "HL7 Australia FHIR Team" - assert inst.contact[0].telecom[0].system == "url" - assert ( - inst.contact[0].telecom[0].value - == "http://hl7-australia.wikispaces.com/FHIR+Australia" - ) - assert inst.date == fhirtypes.DateTime.validate("2015-08-31T11:15:33+10:00") - assert inst.description == ( - "Australian HI Identifier as established by relevant " "regulations etc." - ) - assert inst.id == "example-id" - assert inst.jurisdiction[0].coding[0].code == "AU" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.kind == "identifier" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Austalian Healthcare Identifier - Individual" - assert inst.publisher == "HL7 Australia on behalf of NEHTA" - assert inst.responsible == "HI Service Operator / NEHTA" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "NI" - assert inst.type.coding[0].display == "National unique individual identifier" - assert inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v2-0203" - assert inst.type.text == "IHI" - assert inst.uniqueId[0].comment == "This value is used in Australian CDA documents" - assert inst.uniqueId[0].type == "oid" - assert inst.uniqueId[0].value == "1.2.36.1.2001.1003.0" - assert inst.uniqueId[1].period.start == fhirtypes.DateTime.validate( - "2015-08-21T11:15:33+10:00" - ) - assert inst.uniqueId[1].preferred is True - assert inst.uniqueId[1].type == "uri" - assert inst.uniqueId[1].value == "http://ns.electronichealth.net.au/id/hi/ihi/1.0" - assert inst.usage == "Used in Australia for identifying patients" - - -def test_namingsystem_1(base_settings): - """No. 1 tests collection for NamingSystem. - Test File: namingsystem-example-id.json - """ - filename = base_settings["unittest_data_dir"] / "namingsystem-example-id.json" - inst = namingsystem.NamingSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NamingSystem" == inst.resource_type - - impl_namingsystem_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NamingSystem" == data["resourceType"] - - inst2 = namingsystem.NamingSystem(**data) - impl_namingsystem_1(inst2) - - -def impl_namingsystem_2(inst): - assert inst.contact[0].name == "FHIR project team" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2014-12-13T11:15:33+10:00") - assert inst.id == "example" - assert inst.kind == "codesystem" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "SNOMED CT" - assert inst.publisher == "HL7 International on behalf of IHTSDO" - assert inst.responsible == "IHTSDO & affiliates" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.uniqueId[0].type == "oid" - assert inst.uniqueId[0].value == "2.16.840.1.113883.6.96" - assert inst.uniqueId[1].preferred is True - assert inst.uniqueId[1].type == "uri" - assert inst.uniqueId[1].value == "http://snomed.info/sct" - - -def test_namingsystem_2(base_settings): - """No. 2 tests collection for NamingSystem. - Test File: namingsystem-example.json - """ - filename = base_settings["unittest_data_dir"] / "namingsystem-example.json" - inst = namingsystem.NamingSystem.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NamingSystem" == inst.resource_type - - impl_namingsystem_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NamingSystem" == data["resourceType"] - - inst2 = namingsystem.NamingSystem(**data) - impl_namingsystem_2(inst2) diff --git a/fhir/resources/tests/test_nutritionorder.py b/fhir/resources/tests/test_nutritionorder.py deleted file mode 100644 index 5fe8c81f..00000000 --- a/fhir/resources/tests/test_nutritionorder.py +++ /dev/null @@ -1,932 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/NutritionOrder -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import nutritionorder - - -def impl_nutritionorder_1(inst): - assert inst.allergyIntolerance[0].display == "Cashew Nuts" - assert inst.allergyIntolerance[0].reference == "AllergyIntolerance/example" - assert inst.dateTime == fhirtypes.DateTime.validate("2014-09-17T11:15:33+10:00") - assert inst.encounter.display == "Inpatient" - assert inst.encounter.reference == "Encounter/example" - assert inst.excludeFoodModifier[0].coding[0].code == "227493005" - assert inst.excludeFoodModifier[0].coding[0].display == "Cashew Nut" - assert inst.excludeFoodModifier[0].coding[0].system == "http://snomed.info/sct" - assert inst.excludeFoodModifier[0].coding[0].version == "20140730" - assert inst.foodPreferenceModifier[0].coding[0].code == "kosher" - assert ( - inst.foodPreferenceModifier[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/diet" - ) - assert inst.id == "diabeticsupplement" - assert ( - inst.identifier[0].system == "http://goodhealthhospital.org/nutrition-requests" - ) - assert inst.identifier[0].value == "123" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.orderer.display == "Dr Adam Careful" - assert inst.orderer.reference == "Practitioner/example" - assert inst.patient.display == "Peter Chalmers" - assert inst.patient.reference == "Patient/example" - assert inst.status == "active" - assert inst.supplement[0].productName == "Glucerna" - assert inst.supplement[0].quantity.unit == "8 oz bottle" - assert float(inst.supplement[0].quantity.value) == float(1) - assert inst.supplement[0].schedule[ - 0 - ].repeat.boundsPeriod.start == fhirtypes.DateTime.validate("2015-02-10T15:00:00Z") - assert inst.supplement[0].schedule[0].repeat.frequency == 1 - assert float(inst.supplement[0].schedule[0].repeat.period) == float(24) - assert inst.supplement[0].schedule[0].repeat.periodUnit == "h" - assert float(inst.supplement[0].schedule[1].repeat.duration) == float(1) - assert inst.supplement[0].schedule[1].repeat.durationUnit == "h" - assert inst.supplement[0].schedule[1].repeat.when[0] == "HS" - assert inst.supplement[0].type.coding[0].code == "443051000124104" - assert ( - inst.supplement[0].type.coding[0].display == "Adult diabetes specialty formula" - ) - assert inst.supplement[0].type.coding[0].system == "http://snomed.info/sct" - assert inst.supplement[0].type.coding[1].code == "1010" - assert inst.supplement[0].type.coding[1].display == "Adult diabetic formula" - assert ( - inst.supplement[0].type.coding[1].system - == "http://goodhealthhospital.org/supplement-type-codes" - ) - assert inst.supplement[0].type.text == "Adult diabetic formula" - assert inst.text.status == "generated" - - -def test_nutritionorder_1(base_settings): - """No. 1 tests collection for NutritionOrder. - Test File: nutritionorder-example-diabeticsupplement.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "nutritionorder-example-diabeticsupplement.json" - ) - inst = nutritionorder.NutritionOrder.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NutritionOrder" == inst.resource_type - - impl_nutritionorder_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NutritionOrder" == data["resourceType"] - - inst2 = nutritionorder.NutritionOrder(**data) - impl_nutritionorder_1(inst2) - - -def impl_nutritionorder_2(inst): - assert inst.allergyIntolerance[0].display == "Cashew Nuts" - assert inst.allergyIntolerance[0].reference == "AllergyIntolerance/example" - assert inst.dateTime == fhirtypes.DateTime.validate("2014-09-17T11:15:33+10:00") - assert inst.encounter.display == "Inpatient" - assert inst.encounter.reference == "Encounter/example" - assert inst.enteralFormula.additiveProductName == "Acme Lipid Additive" - assert inst.enteralFormula.additiveType.coding[0].code == "lipid" - assert inst.enteralFormula.additiveType.coding[0].display == "Lipid" - assert ( - inst.enteralFormula.additiveType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/entformula-additive" - ) - assert inst.enteralFormula.administrationInstruction == "240 mls every 4hrs " - assert inst.enteralFormula.administration[0].quantity.code == "mL" - assert ( - inst.enteralFormula.administration[0].quantity.system - == "http://unitsofmeasure.org" - ) - assert inst.enteralFormula.administration[0].quantity.unit == "milliliters" - assert float(inst.enteralFormula.administration[0].quantity.value) == float(240) - assert inst.enteralFormula.administration[ - 0 - ].schedule.repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2014-09-17T16:00:00Z" - ) - assert inst.enteralFormula.administration[0].schedule.repeat.frequency == 1 - assert float(inst.enteralFormula.administration[0].schedule.repeat.period) == float( - 4 - ) - assert inst.enteralFormula.administration[0].schedule.repeat.periodUnit == "h" - assert inst.enteralFormula.baseFormulaProductName == "Acme High Protein Formula" - assert inst.enteralFormula.baseFormulaType.coding[0].code == "442991000124104" - assert ( - inst.enteralFormula.baseFormulaType.coding[0].display - == "Adult high protein formula" - ) - assert ( - inst.enteralFormula.baseFormulaType.coding[0].system == "http://snomed.info/sct" - ) - assert inst.enteralFormula.caloricDensity.code == "cal/mL" - assert inst.enteralFormula.caloricDensity.system == "http://unitsofmeasure.org" - assert inst.enteralFormula.caloricDensity.unit == "calories per milliliter" - assert float(inst.enteralFormula.caloricDensity.value) == float(1.5) - assert inst.enteralFormula.maxVolumeToDeliver.code == "mL/d" - assert inst.enteralFormula.maxVolumeToDeliver.system == "http://unitsofmeasure.org" - assert inst.enteralFormula.maxVolumeToDeliver.unit == "milliliter/day" - assert float(inst.enteralFormula.maxVolumeToDeliver.value) == float(1440) - assert inst.enteralFormula.routeofAdministration.coding[0].code == "GT" - assert ( - inst.enteralFormula.routeofAdministration.coding[0].display - == "Instillation, gastrostomy tube" - ) - assert inst.enteralFormula.routeofAdministration.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/v3-RouteOfAdministrati" "on" - ) - assert inst.excludeFoodModifier[0].coding[0].code == "227493005" - assert inst.excludeFoodModifier[0].coding[0].display == "Cashew Nut" - assert inst.excludeFoodModifier[0].coding[0].system == "http://snomed.info/sct" - assert inst.excludeFoodModifier[0].coding[0].version == "20140730" - assert inst.foodPreferenceModifier[0].coding[0].code == "dairy-free" - assert ( - inst.foodPreferenceModifier[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/diet" - ) - assert inst.id == "enteralbolus" - assert inst.identifier[0].system == "http://www.acme.org/nutritionorders" - assert inst.identifier[0].value == "123" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.orderer.display == "Dr Adam Careful" - assert inst.orderer.reference == "Practitioner/example" - assert inst.patient.display == "Peter Chalmers" - assert inst.patient.reference == "Patient/example" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_nutritionorder_2(base_settings): - """No. 2 tests collection for NutritionOrder. - Test File: nutritionorder-example-enteralbolus.json - """ - filename = ( - base_settings["unittest_data_dir"] / "nutritionorder-example-enteralbolus.json" - ) - inst = nutritionorder.NutritionOrder.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NutritionOrder" == inst.resource_type - - impl_nutritionorder_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NutritionOrder" == data["resourceType"] - - inst2 = nutritionorder.NutritionOrder(**data) - impl_nutritionorder_2(inst2) - - -def impl_nutritionorder_3(inst): - assert inst.allergyIntolerance[0].display == "Cashew Nuts" - assert inst.allergyIntolerance[0].reference == "AllergyIntolerance/example" - assert inst.dateTime == fhirtypes.DateTime.validate("2014-09-17T11:15:33+10:00") - assert inst.encounter.display == "Inpatient" - assert inst.encounter.reference == "Encounter/example" - assert inst.excludeFoodModifier[0].coding[0].code == "227493005" - assert inst.excludeFoodModifier[0].coding[0].display == "Cashew Nut" - assert inst.excludeFoodModifier[0].coding[0].system == "http://snomed.info/sct" - assert inst.excludeFoodModifier[0].coding[0].version == "20140730" - assert inst.foodPreferenceModifier[0].coding[0].code == "dairy-free" - assert ( - inst.foodPreferenceModifier[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/diet" - ) - assert inst.id == "fiberrestricteddiet" - assert ( - inst.identifier[0].system == "http://goodhealthhospital.org/nutrition-requests" - ) - assert inst.identifier[0].value == "123" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.oralDiet.nutrient[0].amount.code == "g" - assert inst.oralDiet.nutrient[0].amount.system == "http://unitsofmeasure.org" - assert inst.oralDiet.nutrient[0].amount.unit == "grams" - assert float(inst.oralDiet.nutrient[0].amount.value) == float(50) - assert inst.oralDiet.nutrient[0].modifier.coding[0].code == "256674009" - assert inst.oralDiet.nutrient[0].modifier.coding[0].display == "Fat" - assert ( - inst.oralDiet.nutrient[0].modifier.coding[0].system == "http://snomed.info/sct" - ) - assert inst.oralDiet.schedule[ - 0 - ].repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2015-02-10T11:15:33+10:00" - ) - assert inst.oralDiet.schedule[0].repeat.frequency == 3 - assert float(inst.oralDiet.schedule[0].repeat.period) == float(1) - assert inst.oralDiet.schedule[0].repeat.periodUnit == "d" - assert inst.oralDiet.type[0].coding[0].code == "15108003" - assert inst.oralDiet.type[0].coding[0].display == "Restricted fiber diet" - assert inst.oralDiet.type[0].coding[0].system == "http://snomed.info/sct" - assert inst.oralDiet.type[0].coding[1].code == "1000" - assert inst.oralDiet.type[0].coding[1].display == "Fiber restricted" - assert ( - inst.oralDiet.type[0].coding[1].system - == "http://goodhealthhospital.org/diet-type-codes" - ) - assert inst.oralDiet.type[0].text == "Fiber restricted diet" - assert inst.oralDiet.type[1].coding[0].code == "16208003" - assert inst.oralDiet.type[1].coding[0].display == "Low fat diet" - assert inst.oralDiet.type[1].coding[0].system == "http://snomed.info/sct" - assert inst.oralDiet.type[1].coding[1].code == "1100" - assert inst.oralDiet.type[1].coding[1].display == "Low Fat" - assert ( - inst.oralDiet.type[1].coding[1].system - == "http://goodhealthhospital.org/diet-type-codes" - ) - assert inst.oralDiet.type[1].text == "Low fat diet" - assert inst.orderer.display == "Dr Adam Careful" - assert inst.orderer.reference == "Practitioner/example" - assert inst.patient.display == "Peter Chalmers" - assert inst.patient.reference == "Patient/example" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_nutritionorder_3(base_settings): - """No. 3 tests collection for NutritionOrder. - Test File: nutritionorder-example-fiberrestricteddiet.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "nutritionorder-example-fiberrestricteddiet.json" - ) - inst = nutritionorder.NutritionOrder.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NutritionOrder" == inst.resource_type - - impl_nutritionorder_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NutritionOrder" == data["resourceType"] - - inst2 = nutritionorder.NutritionOrder(**data) - impl_nutritionorder_3(inst2) - - -def impl_nutritionorder_4(inst): - assert inst.dateTime == fhirtypes.DateTime.validate("2014-09-17T11:15:33+10:00") - assert inst.id == "texturemodified" - assert ( - inst.identifier[0].system == "http://goodhealthhospital.org/nutrition-requests" - ) - assert inst.identifier[0].value == "123" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.oralDiet.schedule[ - 0 - ].repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2015-02-10T11:15:33+10:00" - ) - assert inst.oralDiet.schedule[0].repeat.frequency == 3 - assert float(inst.oralDiet.schedule[0].repeat.period) == float(1) - assert inst.oralDiet.schedule[0].repeat.periodUnit == "d" - assert inst.oralDiet.texture[0].foodType.coding[0].code == "28647000" - assert inst.oralDiet.texture[0].foodType.coding[0].display == "Meat" - assert ( - inst.oralDiet.texture[0].foodType.coding[0].system == "http://snomed.info/sct" - ) - assert inst.oralDiet.texture[0].foodType.text == "Regular, Chopped Meat" - assert inst.oralDiet.texture[0].modifier.coding[0].code == "228049004" - assert inst.oralDiet.texture[0].modifier.coding[0].display == "Chopped food" - assert ( - inst.oralDiet.texture[0].modifier.coding[0].system == "http://snomed.info/sct" - ) - assert inst.oralDiet.texture[0].modifier.text == "Regular, Chopped Meat" - assert inst.oralDiet.type[0].coding[0].code == "435801000124108" - assert inst.oralDiet.type[0].coding[0].display == "Texture modified diet" - assert inst.oralDiet.type[0].coding[0].system == "http://snomed.info/sct" - assert inst.oralDiet.type[0].coding[1].code == "1010" - assert inst.oralDiet.type[0].coding[1].display == "Texture modified diet" - assert ( - inst.oralDiet.type[0].coding[1].system - == "http://goodhealthhospital.org/diet-type-codes" - ) - assert inst.oralDiet.type[0].text == "Texture modified diet" - assert inst.orderer.display == "Dr Adam Careful" - assert inst.orderer.reference == "Practitioner/example" - assert inst.patient.display == "Peter Chalmers" - assert inst.patient.reference == "Patient/example" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_nutritionorder_4(base_settings): - """No. 4 tests collection for NutritionOrder. - Test File: nutritionorder-example-texture-modified.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "nutritionorder-example-texture-modified.json" - ) - inst = nutritionorder.NutritionOrder.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NutritionOrder" == inst.resource_type - - impl_nutritionorder_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NutritionOrder" == data["resourceType"] - - inst2 = nutritionorder.NutritionOrder(**data) - impl_nutritionorder_4(inst2) - - -def impl_nutritionorder_5(inst): - assert inst.dateTime == fhirtypes.DateTime.validate("2014-09-17T11:15:33+10:00") - assert inst.id == "pureeddiet-simple" - assert ( - inst.identifier[0].system == "http://goodhealthhospital.org/nutrition-requests" - ) - assert inst.identifier[0].value == "123" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.oralDiet.fluidConsistencyType[0].coding[0].code == "439021000124105" - assert ( - inst.oralDiet.fluidConsistencyType[0].coding[0].display - == "Dietary liquid consistency - nectar thick liquid" - ) - assert ( - inst.oralDiet.fluidConsistencyType[0].coding[0].system - == "http://snomed.info/sct" - ) - assert inst.oralDiet.fluidConsistencyType[0].text == "Nectar thick liquids" - assert inst.oralDiet.schedule[ - 0 - ].repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2015-02-10T11:15:33+10:00" - ) - assert inst.oralDiet.schedule[0].repeat.frequency == 3 - assert float(inst.oralDiet.schedule[0].repeat.period) == float(1) - assert inst.oralDiet.schedule[0].repeat.periodUnit == "d" - assert inst.oralDiet.texture[0].modifier.coding[0].code == "228055009" - assert inst.oralDiet.texture[0].modifier.coding[0].display == "Liquidized food" - assert ( - inst.oralDiet.texture[0].modifier.coding[0].system == "http://snomed.info/sct" - ) - assert inst.oralDiet.texture[0].modifier.text == "Pureed" - assert inst.oralDiet.type[0].coding[0].code == "226211001" - assert inst.oralDiet.type[0].coding[0].display == "Pureed diet" - assert inst.oralDiet.type[0].coding[0].system == "http://snomed.info/sct" - assert inst.oralDiet.type[0].coding[1].code == "1010" - assert inst.oralDiet.type[0].coding[1].display == "Pureed diet" - assert ( - inst.oralDiet.type[0].coding[1].system - == "http://goodhealthhospital.org/diet-type-codes" - ) - assert inst.oralDiet.type[0].text == "Pureed diet" - assert inst.orderer.display == "Dr Adam Careful" - assert inst.orderer.reference == "Practitioner/example" - assert inst.patient.display == "Peter Chalmers" - assert inst.patient.reference == "Patient/example" - assert inst.status == "active" - assert ( - inst.supplement[0].instruction == "Ensure Pudding at breakfast, lunch, supper" - ) - assert inst.supplement[0].productName == "Ensure Pudding 4 oz container" - assert inst.supplement[0].type.coding[0].code == "442971000124100" - assert inst.supplement[0].type.coding[0].display == "Adult high energy formula" - assert inst.supplement[0].type.coding[0].system == "http://snomed.info/sct" - assert inst.supplement[0].type.coding[1].code == "1040" - assert inst.supplement[0].type.coding[1].display == "Adult high energy pudding" - assert ( - inst.supplement[0].type.coding[1].system - == "http://goodhealthhospital.org/supplement-type-codes" - ) - assert inst.supplement[0].type.text == "Adult high energy pudding" - assert inst.text.status == "generated" - - -def test_nutritionorder_5(base_settings): - """No. 5 tests collection for NutritionOrder. - Test File: nutritionorder-example-pureeddiet-simple.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "nutritionorder-example-pureeddiet-simple.json" - ) - inst = nutritionorder.NutritionOrder.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NutritionOrder" == inst.resource_type - - impl_nutritionorder_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NutritionOrder" == data["resourceType"] - - inst2 = nutritionorder.NutritionOrder(**data) - impl_nutritionorder_5(inst2) - - -def impl_nutritionorder_6(inst): - assert inst.dateTime == fhirtypes.DateTime.validate("2014-09-17T11:15:33+10:00") - assert inst.encounter.display == "Inpatient" - assert inst.encounter.reference == "Encounter/example" - assert inst.enteralFormula.additiveProductName == "Acme High Carbohydrate Additive" - assert inst.enteralFormula.additiveType.coding[0].code == "carbohydrate" - assert inst.enteralFormula.additiveType.coding[0].display == "Carbohydrate" - assert ( - inst.enteralFormula.additiveType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/entformula-additive" - ) - assert inst.enteralFormula.administrationInstruction == ( - "Add high calorie high carbohydrate additive to increase " - "cal/oz from 24 cal/oz to 27 cal/oz." - ) - assert inst.enteralFormula.administration[0].quantity.code == "[foz_us]" - assert ( - inst.enteralFormula.administration[0].quantity.system - == "http://unitsofmeasure.org" - ) - assert inst.enteralFormula.administration[0].quantity.unit == "ounces" - assert float(inst.enteralFormula.administration[0].quantity.value) == float(4) - assert inst.enteralFormula.administration[ - 0 - ].schedule.repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2014-09-17T11:15:33+10:00" - ) - assert inst.enteralFormula.administration[0].schedule.repeat.frequency == 1 - assert float(inst.enteralFormula.administration[0].schedule.repeat.period) == float( - 3 - ) - assert inst.enteralFormula.administration[0].schedule.repeat.periodUnit == "h" - assert inst.enteralFormula.baseFormulaProductName == "Acme Infant Formula + Iron" - assert inst.enteralFormula.baseFormulaType.coding[0].code == "412414007" - assert ( - inst.enteralFormula.baseFormulaType.coding[0].display == "infant formula + iron" - ) - assert ( - inst.enteralFormula.baseFormulaType.coding[0].system == "http://snomed.info/sct" - ) - assert inst.enteralFormula.caloricDensity.code == "cal/[foz_us]" - assert inst.enteralFormula.caloricDensity.system == "http://unitsofmeasure.org" - assert inst.enteralFormula.caloricDensity.unit == "calories per ounce" - assert float(inst.enteralFormula.caloricDensity.value) == float(20) - assert inst.enteralFormula.maxVolumeToDeliver.code == "[foz_us]" - assert inst.enteralFormula.maxVolumeToDeliver.system == "http://unitsofmeasure.org" - assert inst.enteralFormula.maxVolumeToDeliver.unit == "ounces" - assert float(inst.enteralFormula.maxVolumeToDeliver.value) == float(32) - assert inst.enteralFormula.routeofAdministration.coding[0].code == "PO" - assert ( - inst.enteralFormula.routeofAdministration.coding[0].display == "Swallow, oral" - ) - assert inst.enteralFormula.routeofAdministration.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/v3-RouteOfAdministrati" "on" - ) - assert inst.enteralFormula.routeofAdministration.coding[0].userSelected is True - assert inst.id == "infantenteral" - assert inst.identifier[0].system == "http://www.acme.org/nutritionorders" - assert inst.identifier[0].value == "123" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.orderer.display == "Dr Adam Careful" - assert inst.orderer.reference == "Practitioner/example" - assert inst.patient.display == "Peter Chalmers" - assert inst.patient.reference == "Patient/example" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_nutritionorder_6(base_settings): - """No. 6 tests collection for NutritionOrder. - Test File: nutritionorder-example-infantenteral.json - """ - filename = ( - base_settings["unittest_data_dir"] / "nutritionorder-example-infantenteral.json" - ) - inst = nutritionorder.NutritionOrder.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NutritionOrder" == inst.resource_type - - impl_nutritionorder_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NutritionOrder" == data["resourceType"] - - inst2 = nutritionorder.NutritionOrder(**data) - impl_nutritionorder_6(inst2) - - -def impl_nutritionorder_7(inst): - assert inst.dateTime == fhirtypes.DateTime.validate("2014-09-17T11:15:33+10:00") - assert inst.encounter.display == "Inpatient" - assert inst.encounter.reference == "Encounter/example" - assert inst.enteralFormula.administrationInstruction == ( - "Hold feedings from 7 pm to 7 am. Add MCT oil to increase " - "calories from 1.0 cal/mL to 1.5 cal/mL" - ) - assert inst.enteralFormula.administration[0].rateQuantity.code == "mL/h" - assert ( - inst.enteralFormula.administration[0].rateQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.enteralFormula.administration[0].rateQuantity.unit == "ml/hr" - assert float(inst.enteralFormula.administration[0].rateQuantity.value) == float(60) - assert inst.enteralFormula.administration[ - 0 - ].schedule.repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2014-09-17T07:00:00Z" - ) - assert inst.enteralFormula.administration[1].rateQuantity.code == "mL/h" - assert ( - inst.enteralFormula.administration[1].rateQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.enteralFormula.administration[1].rateQuantity.unit == "ml/hr" - assert float(inst.enteralFormula.administration[1].rateQuantity.value) == float(80) - assert inst.enteralFormula.administration[ - 1 - ].schedule.repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2014-09-17T11:00:00Z" - ) - assert inst.enteralFormula.administration[2].rateQuantity.code == "mL/h" - assert ( - inst.enteralFormula.administration[2].rateQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.enteralFormula.administration[2].rateQuantity.unit == "ml/hr" - assert float(inst.enteralFormula.administration[2].rateQuantity.value) == float(100) - assert inst.enteralFormula.administration[ - 2 - ].schedule.repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2014-09-17T15:00:00Z" - ) - assert inst.enteralFormula.baseFormulaProductName == " Acme Diabetes Formula" - assert inst.enteralFormula.baseFormulaType.coding[0].code == "6547210000124112" - assert ( - inst.enteralFormula.baseFormulaType.coding[0].display - == "Diabetic specialty enteral formula" - ) - assert ( - inst.enteralFormula.baseFormulaType.coding[0].system == "http://snomed.info/sct" - ) - assert inst.enteralFormula.caloricDensity.code == "cal/mL" - assert inst.enteralFormula.caloricDensity.system == "http://unitsofmeasure.org" - assert inst.enteralFormula.caloricDensity.unit == "calories per milliliter" - assert float(inst.enteralFormula.caloricDensity.value) == float(1) - assert inst.enteralFormula.maxVolumeToDeliver.code == "mL/d" - assert inst.enteralFormula.maxVolumeToDeliver.system == "http://unitsofmeasure.org" - assert inst.enteralFormula.maxVolumeToDeliver.unit == "milliliter/day" - assert float(inst.enteralFormula.maxVolumeToDeliver.value) == float(880) - assert inst.enteralFormula.routeofAdministration.coding[0].code == "NGT" - assert ( - inst.enteralFormula.routeofAdministration.coding[0].display - == "Instillation, nasogastric tube" - ) - assert inst.enteralFormula.routeofAdministration.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/v3-RouteOfAdministrati" "on" - ) - assert inst.id == "enteralcontinuous" - assert inst.identifier[0].system == "http://www.acme.org/nutritionorders" - assert inst.identifier[0].value == "123" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.orderer.display == "Dr Adam Careful" - assert inst.orderer.reference == "Practitioner/example" - assert inst.patient.display == "Peter Chalmers" - assert inst.patient.reference == "Patient/example" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_nutritionorder_7(base_settings): - """No. 7 tests collection for NutritionOrder. - Test File: nutritionorder-example-enteralcontinuous.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "nutritionorder-example-enteralcontinuous.json" - ) - inst = nutritionorder.NutritionOrder.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NutritionOrder" == inst.resource_type - - impl_nutritionorder_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NutritionOrder" == data["resourceType"] - - inst2 = nutritionorder.NutritionOrder(**data) - impl_nutritionorder_7(inst2) - - -def impl_nutritionorder_8(inst): - assert inst.allergyIntolerance[0].display == "Cashew Nuts" - assert inst.allergyIntolerance[0].reference == "AllergyIntolerance/example" - assert inst.dateTime == fhirtypes.DateTime.validate("2014-09-17T11:15:33+10:00") - assert inst.encounter.display == "Inpatient" - assert inst.encounter.reference == "Encounter/example" - assert inst.excludeFoodModifier[0].coding[0].code == "227493005" - assert inst.excludeFoodModifier[0].coding[0].display == "Cashew Nut" - assert inst.excludeFoodModifier[0].coding[0].system == "http://snomed.info/sct" - assert inst.excludeFoodModifier[0].coding[0].version == "20140730" - assert inst.foodPreferenceModifier[0].coding[0].code == "dairy-free" - assert ( - inst.foodPreferenceModifier[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/diet" - ) - assert inst.id == "cardiacdiet" - assert ( - inst.identifier[0].system == "http://goodhealthhospital.org/nutrition-requests" - ) - assert inst.identifier[0].value == "123" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert ( - inst.oralDiet.instruction - == "Starting on 2/10 breakfast, maximum 400 ml fluids per meal" - ) - assert inst.oralDiet.nutrient[0].amount.code == "g" - assert inst.oralDiet.nutrient[0].amount.system == "http://unitsofmeasure.org" - assert inst.oralDiet.nutrient[0].amount.unit == "grams" - assert float(inst.oralDiet.nutrient[0].amount.value) == float(2) - assert inst.oralDiet.nutrient[0].modifier.coding[0].code == "39972003" - assert inst.oralDiet.nutrient[0].modifier.coding[0].display == "Sodium" - assert ( - inst.oralDiet.nutrient[0].modifier.coding[0].system == "http://snomed.info/sct" - ) - assert inst.oralDiet.nutrient[1].amount.code == "mL" - assert inst.oralDiet.nutrient[1].amount.system == "http://unitsofmeasure.org" - assert inst.oralDiet.nutrient[1].amount.unit == "milliliter" - assert float(inst.oralDiet.nutrient[1].amount.value) == float(1500) - assert inst.oralDiet.nutrient[1].modifier.coding[0].code == "33463005" - assert inst.oralDiet.nutrient[1].modifier.coding[0].display == "Fluid" - assert ( - inst.oralDiet.nutrient[1].modifier.coding[0].system == "http://snomed.info/sct" - ) - assert inst.oralDiet.type[0].coding[0].code == "386619000" - assert inst.oralDiet.type[0].coding[0].display == "Low sodium diet" - assert inst.oralDiet.type[0].coding[0].system == "http://snomed.info/sct" - assert inst.oralDiet.type[0].coding[1].code == "1040" - assert inst.oralDiet.type[0].coding[1].display == "Low Sodium Diet" - assert ( - inst.oralDiet.type[0].coding[1].system - == "http://goodhealthhospital.org/diet-type-codes" - ) - assert inst.oralDiet.type[0].text == "Low sodium diet" - assert inst.oralDiet.type[1].coding[0].code == "226208002" - assert inst.oralDiet.type[1].coding[0].display == "Fluid restricted diet" - assert inst.oralDiet.type[1].coding[0].system == "http://snomed.info/sct" - assert inst.oralDiet.type[1].coding[1].code == "1040" - assert inst.oralDiet.type[1].coding[1].display == "Fluid restricted diet" - assert ( - inst.oralDiet.type[1].coding[1].system - == "http://goodhealthhospital.org/diet-type-codes" - ) - assert inst.oralDiet.type[1].text == "Fluid restricted diet" - assert inst.orderer.display == "Dr Adam Careful" - assert inst.orderer.reference == "Practitioner/example" - assert inst.patient.display == "Peter Chalmers" - assert inst.patient.reference == "Patient/example" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_nutritionorder_8(base_settings): - """No. 8 tests collection for NutritionOrder. - Test File: nutritionorder-example-cardiacdiet.json - """ - filename = ( - base_settings["unittest_data_dir"] / "nutritionorder-example-cardiacdiet.json" - ) - inst = nutritionorder.NutritionOrder.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NutritionOrder" == inst.resource_type - - impl_nutritionorder_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NutritionOrder" == data["resourceType"] - - inst2 = nutritionorder.NutritionOrder(**data) - impl_nutritionorder_8(inst2) - - -def impl_nutritionorder_9(inst): - assert inst.allergyIntolerance[0].display == "Cashew Nuts" - assert inst.allergyIntolerance[0].reference == "AllergyIntolerance/example" - assert inst.dateTime == fhirtypes.DateTime.validate("2014-09-17T11:15:33+10:00") - assert inst.encounter.display == "Inpatient" - assert inst.encounter.reference == "Encounter/example" - assert inst.excludeFoodModifier[0].coding[0].code == "227493005" - assert inst.excludeFoodModifier[0].coding[0].display == "Cashew Nut" - assert inst.excludeFoodModifier[0].coding[0].system == "http://snomed.info/sct" - assert inst.excludeFoodModifier[0].coding[0].version == "20140730" - assert inst.foodPreferenceModifier[0].coding[0].code == "dairy-free" - assert ( - inst.foodPreferenceModifier[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/diet" - ) - assert inst.id == "pureeddiet" - assert ( - inst.identifier[0].system == "http://goodhealthhospital.org/nutrition-requests" - ) - assert inst.identifier[0].value == "123" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.oralDiet.fluidConsistencyType[0].coding[0].code == "439021000124105" - assert ( - inst.oralDiet.fluidConsistencyType[0].coding[0].display - == "Dietary liquid consistency - nectar thick liquid" - ) - assert ( - inst.oralDiet.fluidConsistencyType[0].coding[0].system - == "http://snomed.info/sct" - ) - assert inst.oralDiet.fluidConsistencyType[0].text == "Nectar thick liquids" - assert inst.oralDiet.schedule[ - 0 - ].repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2015-02-10T11:15:33+10:00" - ) - assert inst.oralDiet.schedule[0].repeat.frequency == 3 - assert float(inst.oralDiet.schedule[0].repeat.period) == float(1) - assert inst.oralDiet.schedule[0].repeat.periodUnit == "d" - assert inst.oralDiet.texture[0].modifier.coding[0].code == "228055009" - assert inst.oralDiet.texture[0].modifier.coding[0].display == "Liquidized food" - assert ( - inst.oralDiet.texture[0].modifier.coding[0].system == "http://snomed.info/sct" - ) - assert inst.oralDiet.texture[0].modifier.text == "Pureed" - assert inst.oralDiet.type[0].coding[0].code == "226211001" - assert inst.oralDiet.type[0].coding[0].display == "Pureed diet" - assert inst.oralDiet.type[0].coding[0].system == "http://snomed.info/sct" - assert inst.oralDiet.type[0].coding[1].code == "1010" - assert inst.oralDiet.type[0].coding[1].display == "Pureed diet" - assert ( - inst.oralDiet.type[0].coding[1].system - == "http://goodhealthhospital.org/diet-type-codes" - ) - assert inst.oralDiet.type[0].text == "Pureed diet" - assert inst.orderer.display == "Dr Adam Careful" - assert inst.orderer.reference == "Practitioner/example" - assert inst.patient.display == "Peter Chalmers" - assert inst.patient.reference == "Patient/example" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_nutritionorder_9(base_settings): - """No. 9 tests collection for NutritionOrder. - Test File: nutritionorder-example-pureeddiet.json - """ - filename = ( - base_settings["unittest_data_dir"] / "nutritionorder-example-pureeddiet.json" - ) - inst = nutritionorder.NutritionOrder.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NutritionOrder" == inst.resource_type - - impl_nutritionorder_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NutritionOrder" == data["resourceType"] - - inst2 = nutritionorder.NutritionOrder(**data) - impl_nutritionorder_9(inst2) - - -def impl_nutritionorder_10(inst): - assert inst.allergyIntolerance[0].display == "Cashew Nuts" - assert inst.allergyIntolerance[0].reference == "AllergyIntolerance/example" - assert inst.dateTime == fhirtypes.DateTime.validate("2014-09-17T11:15:33+10:00") - assert inst.encounter.display == "Inpatient" - assert inst.encounter.reference == "Encounter/example" - assert inst.excludeFoodModifier[0].coding[0].code == "227493005" - assert inst.excludeFoodModifier[0].coding[0].display == "Cashew Nut" - assert inst.excludeFoodModifier[0].coding[0].system == "http://snomed.info/sct" - assert inst.excludeFoodModifier[0].coding[0].version == "20140730" - assert inst.foodPreferenceModifier[0].coding[0].code == "dairy-free" - assert ( - inst.foodPreferenceModifier[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/diet" - ) - assert inst.id == "diabeticdiet" - assert ( - inst.identifier[0].system == "http://goodhealthhospital.org/nutrition-requests" - ) - assert inst.identifier[0].value == "123" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.oralDiet.nutrient[0].amount.code == "g" - assert inst.oralDiet.nutrient[0].amount.system == "http://unitsofmeasure.org" - assert inst.oralDiet.nutrient[0].amount.unit == "grams" - assert float(inst.oralDiet.nutrient[0].amount.value) == float(75) - assert inst.oralDiet.nutrient[0].modifier.coding[0].code == "2331003" - assert inst.oralDiet.nutrient[0].modifier.coding[0].display == "Carbohydrate" - assert ( - inst.oralDiet.nutrient[0].modifier.coding[0].system == "http://snomed.info/sct" - ) - assert inst.oralDiet.schedule[ - 0 - ].repeat.boundsPeriod.start == fhirtypes.DateTime.validate( - "2015-02-10T11:15:33+10:00" - ) - assert inst.oralDiet.schedule[0].repeat.frequency == 3 - assert float(inst.oralDiet.schedule[0].repeat.period) == float(1) - assert inst.oralDiet.schedule[0].repeat.periodUnit == "d" - assert inst.oralDiet.type[0].coding[0].code == "160670007" - assert inst.oralDiet.type[0].coding[0].display == "Diabetic diet" - assert inst.oralDiet.type[0].coding[0].system == "http://snomed.info/sct" - assert inst.oralDiet.type[0].coding[1].code == "1030" - assert inst.oralDiet.type[0].coding[1].display == "DD - Diabetic diet" - assert ( - inst.oralDiet.type[0].coding[1].system - == "http://goodhealthhospital.org/diet-type-codes" - ) - assert inst.oralDiet.type[0].text == "DD - Diabetic diet" - assert inst.orderer.display == "Dr Adam Careful" - assert inst.orderer.reference == "Practitioner/example" - assert inst.patient.display == "Peter Chalmers" - assert inst.patient.reference == "Patient/example" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_nutritionorder_10(base_settings): - """No. 10 tests collection for NutritionOrder. - Test File: nutritionorder-example-diabeticdiet.json - """ - filename = ( - base_settings["unittest_data_dir"] / "nutritionorder-example-diabeticdiet.json" - ) - inst = nutritionorder.NutritionOrder.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "NutritionOrder" == inst.resource_type - - impl_nutritionorder_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "NutritionOrder" == data["resourceType"] - - inst2 = nutritionorder.NutritionOrder(**data) - impl_nutritionorder_10(inst2) diff --git a/fhir/resources/tests/test_observation.py b/fhir/resources/tests/test_observation.py deleted file mode 100644 index 4084e275..00000000 --- a/fhir/resources/tests/test_observation.py +++ /dev/null @@ -1,553 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Observation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import observation - - -def impl_observation_1(inst): - assert inst.code.coding[0].code == "55233-1" - assert inst.code.coding[0].display == ( - "Genetic analysis master panel-- This is the parent OBR for " - "the panel holding all of the associated observations that " - "can be reported with a molecular genetics analysis result." - ) - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/observation-" "geneticsGene" - ) - assert inst.extension[0].valueCodeableConcept.coding[0].code == "3236" - assert inst.extension[0].valueCodeableConcept.coding[0].display == "EGFR" - assert ( - inst.extension[0].valueCodeableConcept.coding[0].system - == "http://www.genenames.org" - ) - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/observation-" "geneticsDNARegionName" - ) - assert inst.extension[1].valueString == "Exon 21" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/observation-" - "geneticsGenomicSourceClass" - ) - assert inst.extension[2].valueCodeableConcept.coding[0].code == "LA6684-0" - assert inst.extension[2].valueCodeableConcept.coding[0].display == "somatic" - assert inst.extension[2].valueCodeableConcept.coding[0].system == "http://loinc.org" - assert inst.id == "example-genetics-1" - assert inst.issued == fhirtypes.Instant.validate("2013-04-03T15:30:10+01:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].display == "Molecular Diagnostics Laboratory" - assert inst.performer[0].reference == "Practitioner/example" - assert inst.specimen.display == "Molecular Specimen ID: MLD45-Z4-1234" - assert inst.specimen.reference == "Specimen/genetics-example1-somatic" - assert inst.status == "final" - assert inst.subject.display == "Molecular Lab Patient ID: HOSP-23456" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - assert inst.valueCodeableConcept.coding[0].code == "10828004" - assert inst.valueCodeableConcept.coding[0].display == "Positive" - assert inst.valueCodeableConcept.coding[0].system == "http://snomed.info/sct" - - -def test_observation_1(base_settings): - """No. 1 tests collection for Observation. - Test File: observation-example-genetics-1.json - """ - filename = ( - base_settings["unittest_data_dir"] / "observation-example-genetics-1.json" - ) - inst = observation.Observation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Observation" == inst.resource_type - - impl_observation_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Observation" == data["resourceType"] - - inst2 = observation.Observation(**data) - impl_observation_1(inst2) - - -def impl_observation_2(inst): - assert inst.bodySite.coding[0].code == "71341001:272741003=7771000" - assert inst.bodySite.coding[0].system == "http://snomed.info/sct" - assert inst.bodySite.text == "Left Femur" - assert inst.code.coding[0].code == "24701-5" - assert inst.code.coding[0].display == "Femur DXA Bone density" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.code.text == "BMD - Left Femur" - assert inst.id == "bmd" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].display == "Acme Imaging Diagnostics" - assert ( - inst.performer[0].reference - == "Organization/1832473e-2fe0-452d-abe9-3cdb9879522f" - ) - assert inst.status == "final" - assert inst.subject.reference == "Patient/pat2" - assert inst.text.status == "generated" - assert inst.valueQuantity.code == "g/cm-2" - assert inst.valueQuantity.system == "http://unitsofmeasure.org" - assert inst.valueQuantity.unit == "g/cm²" - assert float(inst.valueQuantity.value) == float(0.887) - - -def test_observation_2(base_settings): - """No. 2 tests collection for Observation. - Test File: observation-example-bmd.json - """ - filename = base_settings["unittest_data_dir"] / "observation-example-bmd.json" - inst = observation.Observation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Observation" == inst.resource_type - - impl_observation_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Observation" == data["resourceType"] - - inst2 = observation.Observation(**data) - impl_observation_2(inst2) - - -def impl_observation_3(inst): - assert inst.category[0].coding[0].code == "vital-signs" - assert inst.category[0].coding[0].display == "Vital Signs" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/observation-category" - ) - assert inst.category[0].text == "Vital Signs" - assert inst.code.coding[0].code == "9279-1" - assert inst.code.coding[0].display == "Respiratory rate" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.code.text == "Respiratory rate" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "1999-07-02T11:15:33+10:00" - ) - assert inst.id == "respiratory-rate" - assert inst.meta.profile[0] == "http://hl7.org/fhir/StructureDefinition/vitalsigns" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "final" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - assert inst.valueQuantity.code == "/min" - assert inst.valueQuantity.system == "http://unitsofmeasure.org" - assert inst.valueQuantity.unit == "breaths/minute" - assert float(inst.valueQuantity.value) == float(26) - - -def test_observation_3(base_settings): - """No. 3 tests collection for Observation. - Test File: observation-example-respiratory-rate.json - """ - filename = ( - base_settings["unittest_data_dir"] / "observation-example-respiratory-rate.json" - ) - inst = observation.Observation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Observation" == inst.resource_type - - impl_observation_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Observation" == data["resourceType"] - - inst2 = observation.Observation(**data) - impl_observation_3(inst2) - - -def impl_observation_4(inst): - assert inst.category[0].coding[0].code == "vital-signs" - assert inst.category[0].coding[0].display == "Vital Signs" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/observation-category" - ) - assert inst.code.coding[0].code == "29463-7" - assert inst.code.coding[0].display == "Body Weight" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.code.coding[1].code == "3141-9" - assert inst.code.coding[1].display == "Body weight Measured" - assert inst.code.coding[1].system == "http://loinc.org" - assert inst.code.coding[2].code == "27113001" - assert inst.code.coding[2].display == "Body weight" - assert inst.code.coding[2].system == "http://snomed.info/sct" - assert inst.code.coding[3].code == "body-weight" - assert inst.code.coding[3].display == "Body Weight" - assert inst.code.coding[3].system == "http://acme.org/devices/clinical-codes" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2016-03-28T11:15:33+10:00" - ) - assert inst.encounter.reference == "Encounter/example" - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "final" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - assert inst.valueQuantity.code == "[lb_av]" - assert inst.valueQuantity.system == "http://unitsofmeasure.org" - assert inst.valueQuantity.unit == "lbs" - assert float(inst.valueQuantity.value) == float(185) - - -def test_observation_4(base_settings): - """No. 4 tests collection for Observation. - Test File: observation-example.json - """ - filename = base_settings["unittest_data_dir"] / "observation-example.json" - inst = observation.Observation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Observation" == inst.resource_type - - impl_observation_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Observation" == data["resourceType"] - - inst2 = observation.Observation(**data) - impl_observation_4(inst2) - - -def impl_observation_5(inst): - assert inst.code.coding[0].code == "55233-1" - assert inst.code.coding[0].display == ( - "Genetic analysis master panel-- This is the parent OBR for " - "the panel holding all of the associated observations that " - "can be reported with a molecular genetics analysis result." - ) - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.derivedFrom[0].reference == "MolecularSequence/example-pgx-1" - assert inst.derivedFrom[1].reference == "MolecularSequence/example-pgx-2" - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/observation-" "geneticsGene" - ) - assert inst.extension[0].valueCodeableConcept.coding[0].code == "2623" - assert inst.extension[0].valueCodeableConcept.coding[0].display == "CYP2C9" - assert ( - inst.extension[0].valueCodeableConcept.coding[0].system - == "http://www.genenames.org" - ) - assert inst.id == "example-haplotype2" - assert inst.issued == fhirtypes.Instant.validate("2013-04-03T15:30:10+01:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.specimen.display == "Molecular Specimen ID: MLD45-Z4-1234" - assert inst.specimen.reference == "Specimen/genetics-example1-somatic" - assert inst.status == "unknown" - assert inst.subject.display == "J*********** C***********" - assert inst.subject.reference == "Patient/727127" - assert inst.text.status == "generated" - assert inst.valueCodeableConcept.coding[0].code == "PA16581679" - assert inst.valueCodeableConcept.coding[0].display == "*4" - assert inst.valueCodeableConcept.coding[0].system == "http://pharmakb.org" - - -def test_observation_5(base_settings): - """No. 5 tests collection for Observation. - Test File: observation-example-haplotype2.json - """ - filename = ( - base_settings["unittest_data_dir"] / "observation-example-haplotype2.json" - ) - inst = observation.Observation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Observation" == inst.resource_type - - impl_observation_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Observation" == data["resourceType"] - - inst2 = observation.Observation(**data) - impl_observation_5(inst2) - - -def impl_observation_6(inst): - assert inst.category[0].coding[0].code == "vital-signs" - assert inst.category[0].coding[0].display == "Vital Signs" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/observation-category" - ) - assert inst.category[0].text == "Vital Signs" - assert inst.code.coding[0].code == "8478-0" - assert inst.code.coding[0].display == "Mean blood pressure" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.code.text == "Mean blood pressure" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "1999-07-02T11:15:33+10:00" - ) - assert inst.id == "mbp" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "final" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - assert inst.valueQuantity.code == "mm[Hg]" - assert inst.valueQuantity.system == "http://unitsofmeasure.org" - assert inst.valueQuantity.unit == "mm[Hg]" - assert float(inst.valueQuantity.value) == float(80) - - -def test_observation_6(base_settings): - """No. 6 tests collection for Observation. - Test File: observation-example-mbp.json - """ - filename = base_settings["unittest_data_dir"] / "observation-example-mbp.json" - inst = observation.Observation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Observation" == inst.resource_type - - impl_observation_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Observation" == data["resourceType"] - - inst2 = observation.Observation(**data) - impl_observation_6(inst2) - - -def impl_observation_7(inst): - assert inst.code.coding[0].code == "59041-4" - assert inst.code.coding[0].display == ( - "BRCA1+BRCA2 gene mutations tested for in Blood or Tissue by " - "Molecular genetics method Nominal" - ) - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/observation-" "geneticsGene" - ) - assert inst.extension[0].valueCodeableConcept.coding[0].code == "KX470182.1" - assert inst.extension[0].valueCodeableConcept.coding[0].display == "BRCA" - assert ( - inst.extension[0].valueCodeableConcept.coding[0].system - == "https://www.ncbi.nlm.nih.gov/nuccore" - ) - assert inst.extension[1].url == ( - "http://hl7.org/fhir/us/core/StructureDefinition/us-core-" "ethnicity" - ) - assert inst.extension[1].valueCodeableConcept.coding[0].code == "413581001" - assert ( - inst.extension[1].valueCodeableConcept.coding[0].display - == "Unknown racial group" - ) - assert ( - inst.extension[1].valueCodeableConcept.coding[0].system - == "http://browser.ihtsdotools.org/" - ) - assert inst.id == "example-genetics-brcapat" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "final" - assert inst.subject.display == "Patient1 with Breast Cancer FamilyHistory" - assert inst.subject.reference == "Patient/brcapat" - assert inst.text.status == "generated" - - -def test_observation_7(base_settings): - """No. 7 tests collection for Observation. - Test File: observation-example-genetics-brcapat.json - """ - filename = ( - base_settings["unittest_data_dir"] / "observation-example-genetics-brcapat.json" - ) - inst = observation.Observation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Observation" == inst.resource_type - - impl_observation_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Observation" == data["resourceType"] - - inst2 = observation.Observation(**data) - impl_observation_7(inst2) - - -def impl_observation_8(inst): - assert inst.category[0].coding[0].code == "vital-signs" - assert inst.category[0].coding[0].display == "Vital Signs" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/observation-category" - ) - assert inst.category[0].text == "Vital Signs" - assert inst.code.coding[0].code == "39156-5" - assert inst.code.coding[0].display == "Body mass index (BMI) [Ratio]" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.code.text == "BMI" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "1999-07-02T11:15:33+10:00" - ) - assert inst.id == "bmi" - assert inst.meta.profile[0] == "http://hl7.org/fhir/StructureDefinition/vitalsigns" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "final" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - assert inst.valueQuantity.code == "kg/m2" - assert inst.valueQuantity.system == "http://unitsofmeasure.org" - assert inst.valueQuantity.unit == "kg/m2" - assert float(inst.valueQuantity.value) == float(16.2) - - -def test_observation_8(base_settings): - """No. 8 tests collection for Observation. - Test File: observation-example-bmi.json - """ - filename = base_settings["unittest_data_dir"] / "observation-example-bmi.json" - inst = observation.Observation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Observation" == inst.resource_type - - impl_observation_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Observation" == data["resourceType"] - - inst2 = observation.Observation(**data) - impl_observation_8(inst2) - - -def impl_observation_9(inst): - assert inst.category[0].coding[0].code == "vital-signs" - assert inst.category[0].coding[0].display == "Vital Signs" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/observation-category" - ) - assert inst.category[0].text == "Vital Signs" - assert inst.code.coding[0].code == "8302-2" - assert inst.code.coding[0].display == "Body height" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.code.text == "Body height" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "1999-07-02T11:15:33+10:00" - ) - assert inst.id == "body-height" - assert inst.meta.profile[0] == "http://hl7.org/fhir/StructureDefinition/vitalsigns" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "final" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - assert inst.valueQuantity.code == "[in_i]" - assert inst.valueQuantity.system == "http://unitsofmeasure.org" - assert inst.valueQuantity.unit == "in" - assert float(inst.valueQuantity.value) == float(66.89999999999999) - - -def test_observation_9(base_settings): - """No. 9 tests collection for Observation. - Test File: observation-example-body-height.json - """ - filename = ( - base_settings["unittest_data_dir"] / "observation-example-body-height.json" - ) - inst = observation.Observation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Observation" == inst.resource_type - - impl_observation_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Observation" == data["resourceType"] - - inst2 = observation.Observation(**data) - impl_observation_9(inst2) - - -def impl_observation_10(inst): - assert inst.code.text == "eye color" - assert inst.effectiveDateTime == fhirtypes.DateTime.validate( - "2016-05-18T11:15:33+10:00" - ) - assert inst.id == "eye-color" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "final" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - assert inst.valueString == "blue" - - -def test_observation_10(base_settings): - """No. 10 tests collection for Observation. - Test File: observation-example-eye-color.json - """ - filename = base_settings["unittest_data_dir"] / "observation-example-eye-color.json" - inst = observation.Observation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Observation" == inst.resource_type - - impl_observation_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Observation" == data["resourceType"] - - inst2 = observation.Observation(**data) - impl_observation_10(inst2) diff --git a/fhir/resources/tests/test_observationdefinition.py b/fhir/resources/tests/test_observationdefinition.py deleted file mode 100644 index 498235d0..00000000 --- a/fhir/resources/tests/test_observationdefinition.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ObservationDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import observationdefinition - - -def impl_observationdefinition_1(inst): - assert inst.code.coding[0].code == "15074-8" - assert inst.code.coding[0].display == "Glucose [Moles/volume] in Blood" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_observationdefinition_1(base_settings): - """No. 1 tests collection for ObservationDefinition. - Test File: observationdefinition-example.json - """ - filename = base_settings["unittest_data_dir"] / "observationdefinition-example.json" - inst = observationdefinition.ObservationDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ObservationDefinition" == inst.resource_type - - impl_observationdefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ObservationDefinition" == data["resourceType"] - - inst2 = observationdefinition.ObservationDefinition(**data) - impl_observationdefinition_1(inst2) diff --git a/fhir/resources/tests/test_operationdefinition.py b/fhir/resources/tests/test_operationdefinition.py deleted file mode 100644 index e1e791b6..00000000 --- a/fhir/resources/tests/test_operationdefinition.py +++ /dev/null @@ -1,901 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/OperationDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import operationdefinition - - -def impl_operationdefinition_1(inst): - assert inst.code == "data-requirements" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - "The data-requirements operation aggregates and returns the " - "parameters and data requirements for the measure and all its" - " dependencies as a single module definition" - ) - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[0].valueInteger == 2 - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.id == "Measure-data-requirements" - assert inst.instance is True - assert inst.kind == "operation" - assert inst.name == "Data Requirements" - assert inst.parameter[0].max == "1" - assert inst.parameter[0].min == 1 - assert inst.parameter[0].name == "periodStart" - assert inst.parameter[0].type == "date" - assert inst.parameter[0].use == "in" - assert inst.parameter[1].documentation == ( - "The end of the measurement period. The period will end at " - "the end of the period implied by the supplied timestamp. " - "E.g. a value of 2014 would set the period end to be " - "2014-12-31T23:59:59 inclusive" - ) - assert inst.parameter[1].max == "1" - assert inst.parameter[1].min == 1 - assert inst.parameter[1].name == "periodEnd" - assert inst.parameter[1].type == "date" - assert inst.parameter[1].use == "in" - assert inst.parameter[2].documentation == ( - "The result of the requirements gathering is a module-" - "definition Library that describes the aggregate parameters, " - "data requirements, and dependencies of the measure" - ) - assert inst.parameter[2].max == "1" - assert inst.parameter[2].min == 1 - assert inst.parameter[2].name == "return" - assert inst.parameter[2].type == "Library" - assert inst.parameter[2].use == "out" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.resource[0] == "Measure" - assert inst.status == "draft" - assert inst.system is False - assert inst.text.status == "generated" - assert inst.type is False - assert inst.url == ( - "http://hl7.org/fhir/OperationDefinition/Measure-data-" "requirements" - ) - assert inst.version == "4.0.1" - - -def test_operationdefinition_1(base_settings): - """No. 1 tests collection for OperationDefinition. - Test File: operation-measure-data-requirements.json - """ - filename = ( - base_settings["unittest_data_dir"] / "operation-measure-data-requirements.json" - ) - inst = operationdefinition.OperationDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationDefinition" == inst.resource_type - - impl_operationdefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationDefinition" == data["resourceType"] - - inst2 = operationdefinition.OperationDefinition(**data) - impl_operationdefinition_1(inst2) - - -def impl_operationdefinition_2(inst): - assert inst.code == "translate" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[0].valueInteger == 3 - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.id == "ConceptMap-translate" - assert inst.instance is True - assert inst.kind == "operation" - assert inst.name == "Concept Translation" - assert inst.parameter[0].max == "1" - assert inst.parameter[0].min == 0 - assert inst.parameter[0].name == "url" - assert inst.parameter[0].type == "uri" - assert inst.parameter[0].use == "in" - assert inst.parameter[1].documentation == ( - "The concept map is provided directly as part of the request." - " Servers may choose not to accept concept maps in this " - "fashion." - ) - assert inst.parameter[1].max == "1" - assert inst.parameter[1].min == 0 - assert inst.parameter[1].name == "conceptMap" - assert inst.parameter[1].type == "ConceptMap" - assert inst.parameter[1].use == "in" - assert inst.parameter[2].max == "1" - assert inst.parameter[2].min == 0 - assert inst.parameter[2].name == "conceptMapVersion" - assert inst.parameter[2].type == "string" - assert inst.parameter[2].use == "in" - assert inst.parameter[3].documentation == ( - "The code that is to be translated. If a code is provided, a " - "system must be provided" - ) - assert inst.parameter[3].max == "1" - assert inst.parameter[3].min == 0 - assert inst.parameter[3].name == "code" - assert inst.parameter[3].type == "code" - assert inst.parameter[3].use == "in" - assert ( - inst.parameter[4].documentation - == "The system for the code that is to be translated" - ) - assert inst.parameter[4].max == "1" - assert inst.parameter[4].min == 0 - assert inst.parameter[4].name == "system" - assert inst.parameter[4].type == "uri" - assert inst.parameter[4].use == "in" - assert inst.parameter[5].documentation == ( - "The version of the system, if one was provided in the source" " data" - ) - assert inst.parameter[5].max == "1" - assert inst.parameter[5].min == 0 - assert inst.parameter[5].name == "version" - assert inst.parameter[5].type == "string" - assert inst.parameter[5].use == "in" - assert inst.parameter[6].max == "1" - assert inst.parameter[6].min == 0 - assert inst.parameter[6].name == "source" - assert inst.parameter[6].type == "uri" - assert inst.parameter[6].use == "in" - assert inst.parameter[7].documentation == "A coding to translate" - assert inst.parameter[7].max == "1" - assert inst.parameter[7].min == 0 - assert inst.parameter[7].name == "coding" - assert inst.parameter[7].type == "Coding" - assert inst.parameter[7].use == "in" - assert inst.parameter[8].documentation == ( - "A full codeableConcept to validate. The server can translate" - " any of the coding values (e.g. existing translations) as it" - " chooses" - ) - assert inst.parameter[8].max == "1" - assert inst.parameter[8].min == 0 - assert inst.parameter[8].name == "codeableConcept" - assert inst.parameter[8].type == "CodeableConcept" - assert inst.parameter[8].use == "in" - assert inst.parameter[9].max == "1" - assert inst.parameter[9].min == 0 - assert inst.parameter[9].name == "target" - assert inst.parameter[9].type == "uri" - assert inst.parameter[9].use == "in" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.resource[0] == "ConceptMap" - assert inst.status == "draft" - assert inst.system is False - assert inst.text.status == "generated" - assert inst.type is True - assert inst.url == "http://hl7.org/fhir/OperationDefinition/ConceptMap-translate" - assert inst.version == "4.0.1" - - -def test_operationdefinition_2(base_settings): - """No. 2 tests collection for OperationDefinition. - Test File: operation-conceptmap-translate.json - """ - filename = ( - base_settings["unittest_data_dir"] / "operation-conceptmap-translate.json" - ) - inst = operationdefinition.OperationDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationDefinition" == inst.resource_type - - impl_operationdefinition_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationDefinition" == data["resourceType"] - - inst2 = operationdefinition.OperationDefinition(**data) - impl_operationdefinition_2(inst2) - - -def impl_operationdefinition_3(inst): - assert inst.code == "expand" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[0].valueInteger == 5 - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "normative" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "normative-version" - ) - assert inst.extension[2].valueCode == "4.0.1" - assert inst.id == "ValueSet-expand" - assert inst.instance is True - assert inst.kind == "operation" - assert inst.name == "Value Set Expansion" - assert inst.parameter[0].documentation == ( - "A canonical reference to a value set. The server must know " - "the value set (e.g. it is defined explicitly in the server's" - " value sets, or it is defined implicitly by some code system" - " known to the server" - ) - assert inst.parameter[0].max == "1" - assert inst.parameter[0].min == 0 - assert inst.parameter[0].name == "url" - assert inst.parameter[0].type == "uri" - assert inst.parameter[0].use == "in" - assert inst.parameter[1].documentation == ( - "The value set is provided directly as part of the request. " - "Servers may choose not to accept value sets in this fashion" - ) - assert inst.parameter[1].max == "1" - assert inst.parameter[1].min == 0 - assert inst.parameter[1].name == "valueSet" - assert inst.parameter[1].type == "ValueSet" - assert inst.parameter[1].use == "in" - assert inst.parameter[2].max == "1" - assert inst.parameter[2].min == 0 - assert inst.parameter[2].name == "valueSetVersion" - assert inst.parameter[2].type == "string" - assert inst.parameter[2].use == "in" - assert inst.parameter[3].max == "1" - assert inst.parameter[3].min == 0 - assert inst.parameter[3].name == "context" - assert inst.parameter[3].type == "uri" - assert inst.parameter[3].use == "in" - assert inst.parameter[4].max == "1" - assert inst.parameter[4].min == 0 - assert inst.parameter[4].name == "contextDirection" - assert inst.parameter[4].type == "code" - assert inst.parameter[4].use == "in" - assert inst.parameter[5].max == "1" - assert inst.parameter[5].min == 0 - assert inst.parameter[5].name == "filter" - assert inst.parameter[5].type == "string" - assert inst.parameter[5].use == "in" - assert inst.parameter[6].max == "1" - assert inst.parameter[6].min == 0 - assert inst.parameter[6].name == "date" - assert inst.parameter[6].type == "dateTime" - assert inst.parameter[6].use == "in" - assert inst.parameter[7].documentation == ( - "Paging support - where to start if a subset is desired " - "(default = 0). Offset is number of records (not number of " - "pages)" - ) - assert inst.parameter[7].max == "1" - assert inst.parameter[7].min == 0 - assert inst.parameter[7].name == "offset" - assert inst.parameter[7].type == "integer" - assert inst.parameter[7].use == "in" - assert inst.parameter[8].max == "1" - assert inst.parameter[8].min == 0 - assert inst.parameter[8].name == "count" - assert inst.parameter[8].type == "integer" - assert inst.parameter[8].use == "in" - assert inst.parameter[9].documentation == ( - "Controls whether concept designations are to be included or " - "excluded in value set expansions" - ) - assert inst.parameter[9].max == "1" - assert inst.parameter[9].min == 0 - assert inst.parameter[9].name == "includeDesignations" - assert inst.parameter[9].type == "boolean" - assert inst.parameter[9].use == "in" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.resource[0] == "ValueSet" - assert inst.status == "draft" - assert inst.system is False - assert inst.text.status == "generated" - assert inst.type is True - assert inst.url == "http://hl7.org/fhir/OperationDefinition/ValueSet-expand" - assert inst.version == "4.0.1" - - -def test_operationdefinition_3(base_settings): - """No. 3 tests collection for OperationDefinition. - Test File: operation-valueset-expand.json - """ - filename = base_settings["unittest_data_dir"] / "operation-valueset-expand.json" - inst = operationdefinition.OperationDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationDefinition" == inst.resource_type - - impl_operationdefinition_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationDefinition" == data["resourceType"] - - inst2 = operationdefinition.OperationDefinition(**data) - impl_operationdefinition_3(inst2) - - -def impl_operationdefinition_4(inst): - assert inst.code == "meta-add" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - "This operation takes a meta, and adds the profiles, tags, " - "and security labels found in it to the nominated resource" - ) - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[0].valueInteger == 3 - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.id == "Resource-meta-add" - assert inst.instance is True - assert inst.kind == "operation" - assert inst.name == "Add profiles, tags, and security labels to a resource" - assert inst.parameter[0].max == "1" - assert inst.parameter[0].min == 1 - assert inst.parameter[0].name == "meta" - assert inst.parameter[0].type == "Meta" - assert inst.parameter[0].use == "in" - assert inst.parameter[1].documentation == "Resulting meta for the resource" - assert inst.parameter[1].max == "1" - assert inst.parameter[1].min == 1 - assert inst.parameter[1].name == "return" - assert inst.parameter[1].type == "Meta" - assert inst.parameter[1].use == "out" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.resource[0] == "Resource" - assert inst.status == "draft" - assert inst.system is False - assert inst.text.status == "generated" - assert inst.type is False - assert inst.url == "http://hl7.org/fhir/OperationDefinition/Resource-meta-add" - assert inst.version == "4.0.1" - - -def test_operationdefinition_4(base_settings): - """No. 4 tests collection for OperationDefinition. - Test File: operation-resource-meta-add.json - """ - filename = base_settings["unittest_data_dir"] / "operation-resource-meta-add.json" - inst = operationdefinition.OperationDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationDefinition" == inst.resource_type - - impl_operationdefinition_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationDefinition" == data["resourceType"] - - inst2 = operationdefinition.OperationDefinition(**data) - impl_operationdefinition_4(inst2) - - -def impl_operationdefinition_5(inst): - assert inst.code == "everything" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[0].valueInteger == 2 - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.id == "Encounter-everything" - assert inst.instance is True - assert inst.kind == "operation" - assert inst.name == "Fetch Encounter Record" - assert inst.parameter[0].max == "1" - assert inst.parameter[0].min == 0 - assert inst.parameter[0].name == "_since" - assert inst.parameter[0].type == "instant" - assert inst.parameter[0].use == "in" - assert inst.parameter[1].documentation == ( - "One or more parameters, each containing one or more comma-" - "delimited FHIR resource types to include in the return " - "resources. In the absense of any specified types, the server" - " returns all resource types" - ) - assert inst.parameter[1].max == "*" - assert inst.parameter[1].min == 0 - assert inst.parameter[1].name == "_type" - assert inst.parameter[1].type == "code" - assert inst.parameter[1].use == "in" - assert inst.parameter[2].documentation == ( - "See discussion below on the utility of paging through the " - "results of the $everything operation" - ) - assert inst.parameter[2].max == "1" - assert inst.parameter[2].min == 0 - assert inst.parameter[2].name == "_count" - assert inst.parameter[2].type == "integer" - assert inst.parameter[2].use == "in" - assert inst.parameter[3].documentation == 'The bundle type is "searchset"' - assert inst.parameter[3].max == "1" - assert inst.parameter[3].min == 1 - assert inst.parameter[3].name == "return" - assert inst.parameter[3].type == "Bundle" - assert inst.parameter[3].use == "out" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.resource[0] == "Encounter" - assert inst.status == "draft" - assert inst.system is False - assert inst.text.status == "generated" - assert inst.type is False - assert inst.url == "http://hl7.org/fhir/OperationDefinition/Encounter-everything" - assert inst.version == "4.0.1" - - -def test_operationdefinition_5(base_settings): - """No. 5 tests collection for OperationDefinition. - Test File: operation-encounter-everything.json - """ - filename = ( - base_settings["unittest_data_dir"] / "operation-encounter-everything.json" - ) - inst = operationdefinition.OperationDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationDefinition" == inst.resource_type - - impl_operationdefinition_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationDefinition" == data["resourceType"] - - inst2 = operationdefinition.OperationDefinition(**data) - impl_operationdefinition_5(inst2) - - -def impl_operationdefinition_6(inst): - assert inst.code == "graph" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[0].valueInteger == 1 - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.id == "Resource-graph" - assert inst.instance is True - assert inst.kind == "operation" - assert inst.name == "Return a graph of resources" - assert inst.parameter[0].max == "1" - assert inst.parameter[0].min == 1 - assert inst.parameter[0].name == "graph" - assert inst.parameter[0].type == "uri" - assert inst.parameter[0].use == "in" - assert inst.parameter[1].documentation == ( - "The set of resources that were in the graph based on the " - "provided definition" - ) - assert inst.parameter[1].max == "1" - assert inst.parameter[1].min == 1 - assert inst.parameter[1].name == "result" - assert inst.parameter[1].type == "Bundle" - assert inst.parameter[1].use == "out" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.resource[0] == "Resource" - assert inst.status == "draft" - assert inst.system is False - assert inst.text.status == "generated" - assert inst.type is False - assert inst.url == "http://hl7.org/fhir/OperationDefinition/Resource-graph" - assert inst.version == "4.0.1" - - -def test_operationdefinition_6(base_settings): - """No. 6 tests collection for OperationDefinition. - Test File: operation-resource-graph.json - """ - filename = base_settings["unittest_data_dir"] / "operation-resource-graph.json" - inst = operationdefinition.OperationDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationDefinition" == inst.resource_type - - impl_operationdefinition_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationDefinition" == data["resourceType"] - - inst2 = operationdefinition.OperationDefinition(**data) - impl_operationdefinition_6(inst2) - - -def impl_operationdefinition_7(inst): - assert inst.code == "meta" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[0].valueInteger == 3 - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.id == "Resource-meta" - assert inst.instance is True - assert inst.kind == "operation" - assert inst.name == "Access a list of profiles, tags, and security labels" - assert inst.parameter[0].documentation == "The meta returned by the operation" - assert inst.parameter[0].max == "1" - assert inst.parameter[0].min == 1 - assert inst.parameter[0].name == "return" - assert inst.parameter[0].type == "Meta" - assert inst.parameter[0].use == "out" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.resource[0] == "Resource" - assert inst.status == "draft" - assert inst.system is True - assert inst.text.status == "generated" - assert inst.type is True - assert inst.url == "http://hl7.org/fhir/OperationDefinition/Resource-meta" - assert inst.version == "4.0.1" - - -def test_operationdefinition_7(base_settings): - """No. 7 tests collection for OperationDefinition. - Test File: operation-resource-meta.json - """ - filename = base_settings["unittest_data_dir"] / "operation-resource-meta.json" - inst = operationdefinition.OperationDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationDefinition" == inst.resource_type - - impl_operationdefinition_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationDefinition" == data["resourceType"] - - inst2 = operationdefinition.OperationDefinition(**data) - impl_operationdefinition_7(inst2) - - -def impl_operationdefinition_8(inst): - assert inst.code == "care-gaps" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - "The care-gaps operation is used to determine gaps-in-care " - "based on the results of quality measures" - ) - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[0].valueInteger == 2 - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.id == "Measure-care-gaps" - assert inst.instance is False - assert inst.kind == "operation" - assert inst.name == "Care Gaps" - assert inst.parameter[0].max == "1" - assert inst.parameter[0].min == 1 - assert inst.parameter[0].name == "periodStart" - assert inst.parameter[0].type == "date" - assert inst.parameter[0].use == "in" - assert inst.parameter[1].documentation == ( - "The end of the measurement period. The period will end at " - "the end of the period implied by the supplied timestamp. " - "E.g. a value of 2014 would set the period end to be " - "2014-12-31T23:59:59 inclusive" - ) - assert inst.parameter[1].max == "1" - assert inst.parameter[1].min == 1 - assert inst.parameter[1].name == "periodEnd" - assert inst.parameter[1].type == "date" - assert inst.parameter[1].use == "in" - assert inst.parameter[2].documentation == ( - "The topic to be used to determine which measures are " - "considered for the care gaps report. Any measure with the " - "given topic will be included in the report" - ) - assert inst.parameter[2].max == "1" - assert inst.parameter[2].min == 1 - assert inst.parameter[2].name == "topic" - assert inst.parameter[2].type == "string" - assert inst.parameter[2].use == "in" - assert ( - inst.parameter[3].documentation - == "Subject for which the care gaps report will be produced" - ) - assert inst.parameter[3].max == "1" - assert inst.parameter[3].min == 1 - assert inst.parameter[3].name == "subject" - assert inst.parameter[3].searchType == "reference" - assert inst.parameter[3].type == "string" - assert inst.parameter[3].use == "in" - assert inst.parameter[4].documentation == ( - "The result of the care gaps report will be returned as a " - "document bundle with a MeasureReport entry for each included" - " measure" - ) - assert inst.parameter[4].max == "1" - assert inst.parameter[4].min == 1 - assert inst.parameter[4].name == "return" - assert inst.parameter[4].type == "Bundle" - assert inst.parameter[4].use == "out" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.resource[0] == "Measure" - assert inst.status == "draft" - assert inst.system is False - assert inst.text.status == "generated" - assert inst.type is True - assert inst.url == "http://hl7.org/fhir/OperationDefinition/Measure-care-gaps" - assert inst.version == "4.0.1" - - -def test_operationdefinition_8(base_settings): - """No. 8 tests collection for OperationDefinition. - Test File: operation-measure-care-gaps.json - """ - filename = base_settings["unittest_data_dir"] / "operation-measure-care-gaps.json" - inst = operationdefinition.OperationDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationDefinition" == inst.resource_type - - impl_operationdefinition_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationDefinition" == data["resourceType"] - - inst2 = operationdefinition.OperationDefinition(**data) - impl_operationdefinition_8(inst2) - - -def impl_operationdefinition_9(inst): - assert inst.code == "submit-data" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[0].valueInteger == 2 - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.id == "Measure-submit-data" - assert inst.instance is True - assert inst.kind == "operation" - assert inst.name == "Submit Data" - assert inst.parameter[0].documentation == "The measure report being submitted" - assert inst.parameter[0].max == "1" - assert inst.parameter[0].min == 1 - assert inst.parameter[0].name == "measureReport" - assert inst.parameter[0].type == "MeasureReport" - assert inst.parameter[0].use == "in" - assert inst.parameter[1].documentation == ( - "The individual resources that make up the data-of-interest " "being submitted" - ) - assert inst.parameter[1].max == "*" - assert inst.parameter[1].min == 0 - assert inst.parameter[1].name == "resource" - assert inst.parameter[1].type == "Resource" - assert inst.parameter[1].use == "in" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.resource[0] == "Measure" - assert inst.status == "draft" - assert inst.system is False - assert inst.text.status == "generated" - assert inst.type is True - assert inst.url == "http://hl7.org/fhir/OperationDefinition/Measure-submit-data" - assert inst.version == "4.0.1" - - -def test_operationdefinition_9(base_settings): - """No. 9 tests collection for OperationDefinition. - Test File: operation-measure-submit-data.json - """ - filename = base_settings["unittest_data_dir"] / "operation-measure-submit-data.json" - inst = operationdefinition.OperationDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationDefinition" == inst.resource_type - - impl_operationdefinition_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationDefinition" == data["resourceType"] - - inst2 = operationdefinition.OperationDefinition(**data) - impl_operationdefinition_9(inst2) - - -def impl_operationdefinition_10(inst): - assert inst.code == "evaluate-measure" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - "The evaluate-measure operation is used to calculate an " - "eMeasure and obtain the results" - ) - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[0].valueInteger == 2 - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.id == "Measure-evaluate-measure" - assert inst.instance is True - assert inst.kind == "operation" - assert inst.name == "Evaluate Measure" - assert inst.parameter[0].max == "1" - assert inst.parameter[0].min == 1 - assert inst.parameter[0].name == "periodStart" - assert inst.parameter[0].type == "date" - assert inst.parameter[0].use == "in" - assert inst.parameter[1].documentation == ( - "The end of the measurement period. The period will end at " - "the end of the period implied by the supplied timestamp. " - "E.g. a value of 2014 would set the period end to be " - "2014-12-31T23:59:59 inclusive" - ) - assert inst.parameter[1].max == "1" - assert inst.parameter[1].min == 1 - assert inst.parameter[1].name == "periodEnd" - assert inst.parameter[1].type == "date" - assert inst.parameter[1].use == "in" - assert inst.parameter[2].documentation == ( - "The measure to evaluate. This parameter is only required " - "when the operation is invoked on the resource type, it is " - "not used when invoking the operation on a Measure instance" - ) - assert inst.parameter[2].max == "1" - assert inst.parameter[2].min == 0 - assert inst.parameter[2].name == "measure" - assert inst.parameter[2].searchType == "reference" - assert inst.parameter[2].type == "string" - assert inst.parameter[2].use == "in" - assert inst.parameter[3].documentation == ( - "The type of measure report: subject, subject-list, or " - "population. If not specified, a default value of subject " - "will be used if the subject parameter is supplied, " - "otherwise, population will be used" - ) - assert inst.parameter[3].max == "1" - assert inst.parameter[3].min == 0 - assert inst.parameter[3].name == "reportType" - assert inst.parameter[3].type == "code" - assert inst.parameter[3].use == "in" - assert inst.parameter[4].max == "1" - assert inst.parameter[4].min == 0 - assert inst.parameter[4].name == "subject" - assert inst.parameter[4].searchType == "reference" - assert inst.parameter[4].type == "string" - assert inst.parameter[4].use == "in" - assert inst.parameter[5].documentation == ( - "Practitioner for which the measure will be calculated. If " - "specified, the measure will be calculated only for subjects " - "that have a primary relationship to the identified " - "practitioner" - ) - assert inst.parameter[5].max == "1" - assert inst.parameter[5].min == 0 - assert inst.parameter[5].name == "practitioner" - assert inst.parameter[5].searchType == "reference" - assert inst.parameter[5].type == "string" - assert inst.parameter[5].use == "in" - assert inst.parameter[6].max == "1" - assert inst.parameter[6].min == 0 - assert inst.parameter[6].name == "lastReceivedOn" - assert inst.parameter[6].type == "dateTime" - assert inst.parameter[6].use == "in" - assert inst.parameter[7].max == "1" - assert inst.parameter[7].min == 1 - assert inst.parameter[7].name == "return" - assert inst.parameter[7].type == "MeasureReport" - assert inst.parameter[7].use == "out" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.resource[0] == "Measure" - assert inst.status == "draft" - assert inst.system is False - assert inst.text.status == "generated" - assert inst.type is True - assert inst.url == ( - "http://hl7.org/fhir/OperationDefinition/Measure-evaluate-" "measure" - ) - assert inst.version == "4.0.1" - - -def test_operationdefinition_10(base_settings): - """No. 10 tests collection for OperationDefinition. - Test File: operation-measure-evaluate-measure.json - """ - filename = ( - base_settings["unittest_data_dir"] / "operation-measure-evaluate-measure.json" - ) - inst = operationdefinition.OperationDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationDefinition" == inst.resource_type - - impl_operationdefinition_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationDefinition" == data["resourceType"] - - inst2 = operationdefinition.OperationDefinition(**data) - impl_operationdefinition_10(inst2) diff --git a/fhir/resources/tests/test_operationoutcome.py b/fhir/resources/tests/test_operationoutcome.py deleted file mode 100644 index 8b9238da..00000000 --- a/fhir/resources/tests/test_operationoutcome.py +++ /dev/null @@ -1,248 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/OperationOutcome -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import operationoutcome - - -def impl_operationoutcome_1(inst): - assert inst.id == "validationfail" - assert inst.issue[0].code == "structure" - assert ( - inst.issue[0].details.text - == 'Error parsing resource XML (Unknown Content "label"' - ) - assert inst.issue[0].expression[0] == "Patient.identifier" - assert inst.issue[0].location[0] == "/f:Patient/f:identifier" - assert inst.issue[0].severity == "error" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_operationoutcome_1(base_settings): - """No. 1 tests collection for OperationOutcome. - Test File: operationoutcome-example-validationfail.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "operationoutcome-example-validationfail.json" - ) - inst = operationoutcome.OperationOutcome.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationOutcome" == inst.resource_type - - impl_operationoutcome_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationOutcome" == data["resourceType"] - - inst2 = operationoutcome.OperationOutcome(**data) - impl_operationoutcome_1(inst2) - - -def impl_operationoutcome_2(inst): - assert inst.id == "break-the-glass" - assert inst.issue[0].code == "suppressed" - assert inst.issue[0].details.coding[0].code == "ETREAT" - assert inst.issue[0].details.coding[0].display == "Emergency Treatment" - assert ( - inst.issue[0].details.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.issue[0].details.text == ( - "Additional information may be available using the Break-The-" "Glass Protocol" - ) - assert inst.issue[0].severity == "information" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_operationoutcome_2(base_settings): - """No. 2 tests collection for OperationOutcome. - Test File: operationoutcome-example-break-the-glass.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "operationoutcome-example-break-the-glass.json" - ) - inst = operationoutcome.OperationOutcome.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationOutcome" == inst.resource_type - - impl_operationoutcome_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationOutcome" == data["resourceType"] - - inst2 = operationoutcome.OperationOutcome(**data) - impl_operationoutcome_2(inst2) - - -def impl_operationoutcome_3(inst): - assert inst.id == "searchfail" - assert inst.issue[0].code == "code-invalid" - assert inst.issue[0].details.text == ( - 'The "name" parameter has the modifier "exact" which is ' - "not supported by this server" - ) - assert inst.issue[0].location[0] == "http.name:exact" - assert inst.issue[0].severity == "fatal" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_operationoutcome_3(base_settings): - """No. 3 tests collection for OperationOutcome. - Test File: operationoutcome-example-searchfail.json - """ - filename = ( - base_settings["unittest_data_dir"] / "operationoutcome-example-searchfail.json" - ) - inst = operationoutcome.OperationOutcome.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationOutcome" == inst.resource_type - - impl_operationoutcome_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationOutcome" == data["resourceType"] - - inst2 = operationoutcome.OperationOutcome(**data) - impl_operationoutcome_3(inst2) - - -def impl_operationoutcome_4(inst): - assert inst.id == "exception" - assert inst.issue[0].code == "exception" - assert inst.issue[0].details.text == "SQL Link Communication Error (dbx = 34234)" - assert inst.issue[0].severity == "error" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_operationoutcome_4(base_settings): - """No. 4 tests collection for OperationOutcome. - Test File: operationoutcome-example-exception.json - """ - filename = ( - base_settings["unittest_data_dir"] / "operationoutcome-example-exception.json" - ) - inst = operationoutcome.OperationOutcome.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationOutcome" == inst.resource_type - - impl_operationoutcome_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationOutcome" == data["resourceType"] - - inst2 = operationoutcome.OperationOutcome(**data) - impl_operationoutcome_4(inst2) - - -def impl_operationoutcome_5(inst): - assert inst.id == "101" - assert inst.issue[0].code == "code-invalid" - assert ( - inst.issue[0].details.text - == 'The code "W" is not known and not legal in this context' - ) - assert ( - inst.issue[0].diagnostics - == "Acme.Interop.FHIRProcessors.Patient.processGender line 2453" - ) - assert inst.issue[0].expression[0] == "Patient.gender" - assert inst.issue[0].location[0] == "/f:Patient/f:gender" - assert inst.issue[0].severity == "error" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_operationoutcome_5(base_settings): - """No. 5 tests collection for OperationOutcome. - Test File: operationoutcome-example.json - """ - filename = base_settings["unittest_data_dir"] / "operationoutcome-example.json" - inst = operationoutcome.OperationOutcome.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationOutcome" == inst.resource_type - - impl_operationoutcome_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationOutcome" == data["resourceType"] - - inst2 = operationoutcome.OperationOutcome(**data) - impl_operationoutcome_5(inst2) - - -def impl_operationoutcome_6(inst): - assert inst.id == "allok" - assert inst.issue[0].code == "informational" - assert inst.issue[0].details.text == "All OK" - assert inst.issue[0].severity == "information" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_operationoutcome_6(base_settings): - """No. 6 tests collection for OperationOutcome. - Test File: operationoutcome-example-allok.json - """ - filename = ( - base_settings["unittest_data_dir"] / "operationoutcome-example-allok.json" - ) - inst = operationoutcome.OperationOutcome.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OperationOutcome" == inst.resource_type - - impl_operationoutcome_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OperationOutcome" == data["resourceType"] - - inst2 = operationoutcome.OperationOutcome(**data) - impl_operationoutcome_6(inst2) diff --git a/fhir/resources/tests/test_organization.py b/fhir/resources/tests/test_organization.py deleted file mode 100644 index 737374bf..00000000 --- a/fhir/resources/tests/test_organization.py +++ /dev/null @@ -1,474 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Organization -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import organization - - -def impl_organization_1(inst): - assert inst.address[0].city == "Ann Arbor" - assert inst.address[0].country == "USA" - assert inst.address[0].line[0] == "3300 Washtenaw Avenue, Suite 227" - assert inst.address[0].postalCode == "48104" - assert inst.address[0].state == "MI" - assert inst.alias[0] == "HL7 International" - assert inst.endpoint[0].reference == "Endpoint/example" - assert inst.id == "hl7" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Health Level Seven International" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].value == "(+1) 734-677-7777" - assert inst.telecom[1].system == "fax" - assert inst.telecom[1].value == "(+1) 734-677-6622" - assert inst.telecom[2].system == "email" - assert inst.telecom[2].value == "hq@HL7.org" - assert inst.text.status == "generated" - - -def test_organization_1(base_settings): - """No. 1 tests collection for Organization. - Test File: organization-example.json - """ - filename = base_settings["unittest_data_dir"] / "organization-example.json" - inst = organization.Organization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Organization" == inst.resource_type - - impl_organization_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Organization" == data["resourceType"] - - inst2 = organization.Organization(**data) - impl_organization_1(inst2) - - -def impl_organization_2(inst): - assert inst.active is True - assert inst.address[0].country == "Swizterland" - assert inst.id == "mmanu" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Acme Corporation" - assert inst.text.status == "generated" - - -def test_organization_2(base_settings): - """No. 2 tests collection for Organization. - Test File: organization-example-mmanu.json - """ - filename = base_settings["unittest_data_dir"] / "organization-example-mmanu.json" - inst = organization.Organization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Organization" == inst.resource_type - - impl_organization_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Organization" == data["resourceType"] - - inst2 = organization.Organization(**data) - impl_organization_2(inst2) - - -def impl_organization_3(inst): - assert inst.id == "1" - assert inst.identifier[0].system == "http://www.acme.org.au/units" - assert inst.identifier[0].value == "Gastro" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Gastroenterology" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "mobile" - assert inst.telecom[0].value == "+1 555 234 3523" - assert inst.telecom[1].system == "email" - assert inst.telecom[1].use == "work" - assert inst.telecom[1].value == "gastro@acme.org" - assert inst.text.status == "generated" - - -def test_organization_3(base_settings): - """No. 3 tests collection for Organization. - Test File: organization-example-gastro.json - """ - filename = base_settings["unittest_data_dir"] / "organization-example-gastro.json" - inst = organization.Organization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Organization" == inst.resource_type - - impl_organization_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Organization" == data["resourceType"] - - inst2 = organization.Organization(**data) - impl_organization_3(inst2) - - -def impl_organization_4(inst): - assert inst.alias[0] == "Michigan State Department of Health" - assert inst.id == "3" - assert inst.identifier[0].system == "http://michigan.gov/state-dept-ids" - assert inst.identifier[0].value == "25" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Michigan Health" - assert inst.text.status == "generated" - - -def test_organization_4(base_settings): - """No. 4 tests collection for Organization. - Test File: organization-example-mihealth.json - """ - filename = base_settings["unittest_data_dir"] / "organization-example-mihealth.json" - inst = organization.Organization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Organization" == inst.resource_type - - impl_organization_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Organization" == data["resourceType"] - - inst2 = organization.Organization(**data) - impl_organization_4(inst2) - - -def impl_organization_5(inst): - assert inst.id == "1832473e-2fe0-452d-abe9-3cdb9879522f" - assert inst.identifier[0].system == "http://www.acme.org.au/units" - assert inst.identifier[0].value == "ClinLab" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Clinical Lab" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "+1 555 234 1234" - assert inst.telecom[1].system == "email" - assert inst.telecom[1].use == "work" - assert inst.telecom[1].value == "contact@labs.acme.org" - assert inst.text.status == "generated" - - -def test_organization_5(base_settings): - """No. 5 tests collection for Organization. - Test File: organization-example-lab.json - """ - filename = base_settings["unittest_data_dir"] / "organization-example-lab.json" - inst = organization.Organization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Organization" == inst.resource_type - - impl_organization_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Organization" == data["resourceType"] - - inst2 = organization.Organization(**data) - impl_organization_5(inst2) - - -def impl_organization_6(inst): - assert inst.active is True - assert inst.address[0].line[0] == "South Wing, floor 2" - assert inst.contact[0].address.line[0] == "South Wing, floor 2" - assert inst.contact[0].name.text == "mevr. D. de Haan" - assert inst.contact[0].purpose.coding[0].code == "ADMIN" - assert ( - inst.contact[0].purpose.coding[0].system - == "http://terminology.hl7.org/CodeSystem/contactentity-type" - ) - assert inst.contact[0].telecom[0].system == "phone" - assert inst.contact[0].telecom[0].value == "022-655 2321" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "cardio@burgersumc.nl" - assert inst.contact[0].telecom[2].system == "fax" - assert inst.contact[0].telecom[2].value == "022-655 2322" - assert inst.id == "f002" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Burgers UMC Cardiology unit" - assert inst.partOf.reference == "Organization/f001" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].value == "022-655 2320" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "dept" - assert inst.type[0].coding[0].display == "Hospital Department" - assert ( - inst.type[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/organization-type" - ) - - -def test_organization_6(base_settings): - """No. 6 tests collection for Organization. - Test File: organization-example-f002-burgers-card.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "organization-example-f002-burgers-card.json" - ) - inst = organization.Organization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Organization" == inst.resource_type - - impl_organization_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Organization" == data["resourceType"] - - inst2 = organization.Organization(**data) - impl_organization_6(inst2) - - -def impl_organization_7(inst): - assert inst.active is True - assert inst.address[0].city == "Den Helder" - assert inst.address[0].country == "NLD" - assert inst.address[0].line[0] == "Walvisbaai 3" - assert inst.address[0].postalCode == "2333ZA" - assert inst.address[0].use == "work" - assert inst.contact[0].address.city == "Den helder" - assert inst.contact[0].address.country == "NLD" - assert inst.contact[0].address.line[0] == "Walvisbaai 3" - assert inst.contact[0].address.line[1] == "Gebouw 2" - assert inst.contact[0].address.postalCode == "2333ZA" - assert inst.contact[0].name.family == "Brand" - assert inst.contact[0].name.given[0] == "Ronald" - assert inst.contact[0].name.prefix[0] == "Prof.Dr." - assert inst.contact[0].name.text == "Professor Brand" - assert inst.contact[0].name.use == "official" - assert inst.contact[0].telecom[0].system == "phone" - assert inst.contact[0].telecom[0].use == "work" - assert inst.contact[0].telecom[0].value == "+31715269702" - assert inst.id == "f201" - assert inst.identifier[0].system == "http://www.zorgkaartnederland.nl/" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "Artis University Medical Center" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Artis University Medical Center (AUMC)" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "+31715269111" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "405608006" - assert inst.type[0].coding[0].display == "Academic Medical Center" - assert inst.type[0].coding[0].system == "http://snomed.info/sct" - assert inst.type[0].coding[1].code == "V6" - assert inst.type[0].coding[1].display == "University Medical Hospital" - assert inst.type[0].coding[1].system == "urn:oid:2.16.840.1.113883.2.4.15.1060" - assert inst.type[0].coding[2].code == "prov" - assert inst.type[0].coding[2].display == "Healthcare Provider" - assert ( - inst.type[0].coding[2].system - == "http://terminology.hl7.org/CodeSystem/organization-type" - ) - - -def test_organization_7(base_settings): - """No. 7 tests collection for Organization. - Test File: organization-example-f201-aumc.json - """ - filename = ( - base_settings["unittest_data_dir"] / "organization-example-f201-aumc.json" - ) - inst = organization.Organization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Organization" == inst.resource_type - - impl_organization_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Organization" == data["resourceType"] - - inst2 = organization.Organization(**data) - impl_organization_7(inst2) - - -def impl_organization_8(inst): - assert inst.id == "2.16.840.1.113883.19.5" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "2.16.840.1.113883.19.5" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Good Health Clinic" - assert inst.text.status == "generated" - - -def test_organization_8(base_settings): - """No. 8 tests collection for Organization. - Test File: organization-example-good-health-care.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "organization-example-good-health-care.json" - ) - inst = organization.Organization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Organization" == inst.resource_type - - impl_organization_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Organization" == data["resourceType"] - - inst2 = organization.Organization(**data) - impl_organization_8(inst2) - - -def impl_organization_9(inst): - assert inst.address[0].city == "Den Burg" - assert inst.address[0].country == "NLD" - assert inst.address[0].line[0] == "Galapagosweg 91" - assert inst.address[0].postalCode == "9105 PZ" - assert inst.address[0].use == "work" - assert inst.address[1].city == "Den Burg" - assert inst.address[1].country == "NLD" - assert inst.address[1].line[0] == "PO Box 2311" - assert inst.address[1].postalCode == "9100 AA" - assert inst.address[1].use == "work" - assert inst.contact[0].purpose.coding[0].code == "PRESS" - assert ( - inst.contact[0].purpose.coding[0].system - == "http://terminology.hl7.org/CodeSystem/contactentity-type" - ) - assert inst.contact[0].telecom[0].system == "phone" - assert inst.contact[0].telecom[0].value == "022-655 2334" - assert inst.contact[1].purpose.coding[0].code == "PATINF" - assert ( - inst.contact[1].purpose.coding[0].system - == "http://terminology.hl7.org/CodeSystem/contactentity-type" - ) - assert inst.contact[1].telecom[0].system == "phone" - assert inst.contact[1].telecom[0].value == "022-655 2335" - assert inst.id == "f001" - assert inst.identifier[0].system == "urn:oid:2.16.528.1" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "91654" - assert inst.identifier[1].system == "urn:oid:2.16.840.1.113883.2.4.6.1" - assert inst.identifier[1].use == "usual" - assert inst.identifier[1].value == "17-0112278" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "Burgers University Medical Center" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "022-655 2300" - assert inst.text.status == "generated" - assert inst.type[0].coding[0].code == "V6" - assert inst.type[0].coding[0].display == "University Medical Hospital" - assert inst.type[0].coding[0].system == "urn:oid:2.16.840.1.113883.2.4.15.1060" - assert inst.type[0].coding[1].code == "prov" - assert inst.type[0].coding[1].display == "Healthcare Provider" - assert ( - inst.type[0].coding[1].system - == "http://terminology.hl7.org/CodeSystem/organization-type" - ) - - -def test_organization_9(base_settings): - """No. 9 tests collection for Organization. - Test File: organization-example-f001-burgers.json - """ - filename = ( - base_settings["unittest_data_dir"] / "organization-example-f001-burgers.json" - ) - inst = organization.Organization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Organization" == inst.resource_type - - impl_organization_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Organization" == data["resourceType"] - - inst2 = organization.Organization(**data) - impl_organization_9(inst2) - - -def impl_organization_10(inst): - assert inst.alias[0] == "ABC Insurance" - assert inst.id == "2" - assert inst.identifier[0].system == "urn:oid:2.16.840.1.113883.3.19.2.3" - assert inst.identifier[0].value == "666666" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "XYZ Insurance" - assert inst.text.status == "generated" - - -def test_organization_10(base_settings): - """No. 10 tests collection for Organization. - Test File: organization-example-insurer.json - """ - filename = base_settings["unittest_data_dir"] / "organization-example-insurer.json" - inst = organization.Organization.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Organization" == inst.resource_type - - impl_organization_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Organization" == data["resourceType"] - - inst2 = organization.Organization(**data) - impl_organization_10(inst2) diff --git a/fhir/resources/tests/test_organizationaffiliation.py b/fhir/resources/tests/test_organizationaffiliation.py deleted file mode 100644 index 91312fc8..00000000 --- a/fhir/resources/tests/test_organizationaffiliation.py +++ /dev/null @@ -1,215 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/OrganizationAffiliation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import organizationaffiliation - - -def impl_organizationaffiliation_1(inst): - assert inst.active is True - assert inst.code[0].coding[0].code == "provider" - assert ( - inst.code[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/organization-role" - ) - assert inst.endpoint[0].reference == "Endpoint/example" - assert inst.healthcareService[0].reference == "HealthcareService/example" - assert inst.id == "example" - assert inst.identifier[0].system == "http://www.acme.org/practitioners" - assert inst.identifier[0].value == "23" - assert inst.location[0].display == "South Wing, second floor" - assert inst.location[0].reference == "Location/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.network[0].display == "HL7 Payer Network" - assert inst.network[0].reference == "Organization/hl7pay" - assert inst.organization.reference == "Organization/hl7pay" - assert inst.participatingOrganization.reference == "Organization/f001" - assert inst.period.end == fhirtypes.DateTime.validate("2012-03-31T11:15:33+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2012-01-01T11:15:33+10:00") - assert inst.specialty[0].coding[0].code == "408443003" - assert inst.specialty[0].coding[0].display == "General medical practice" - assert inst.specialty[0].coding[0].system == "http://snomed.info/sct" - assert inst.telecom[0].system == "email" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "general.practice@example.org" - assert inst.text.status == "generated" - - -def test_organizationaffiliation_1(base_settings): - """No. 1 tests collection for OrganizationAffiliation. - Test File: organizationaffiliation-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "organizationaffiliation-example.json" - ) - inst = organizationaffiliation.OrganizationAffiliation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OrganizationAffiliation" == inst.resource_type - - impl_organizationaffiliation_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OrganizationAffiliation" == data["resourceType"] - - inst2 = organizationaffiliation.OrganizationAffiliation(**data) - impl_organizationaffiliation_1(inst2) - - -def impl_organizationaffiliation_2(inst): - assert inst.active is True - assert inst.code[0].coding[0].code == "member" - assert inst.code[0].coding[0].display == "Member" - assert inst.code[0].coding[0].system == "http://hl7.org/fhir/organization-role" - assert inst.code[0].text == "Hospital member" - assert inst.endpoint[0].display == "Founding Fathers Memorial Hospital HIE endpoint" - assert ( - inst.endpoint[0].reference - == "http://hl7.org/fhir/ig/vhdir/Endpoint/foundingfathersHIE" - ) - assert inst.id == "orgrole2" - assert inst.identifier[0].assigner.display == "Monument Health Information Exchange" - assert ( - inst.identifier[0].assigner.reference - == "http://hl7.org/fhir/ig/vhdir/Organization/monumentHIE" - ) - assert inst.identifier[0].system == "http://example.org/www.monumentHIE.com" - assert inst.identifier[0].type.text == "member hospital" - assert inst.identifier[0].use == "secondary" - assert inst.identifier[0].value == "hosp32" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.organization.display == "Monument Health Information Exchange" - assert ( - inst.organization.reference - == "http://hl7.org/fhir/ig/vhdir/Organization/monumentHIE" - ) - assert ( - inst.participatingOrganization.display == "Founding Fathers Memorial Hospital" - ) - assert ( - inst.participatingOrganization.reference - == "http://hl7.org/fhir/ig/vhdir/Organization/foundingfathers" - ) - assert inst.text.status == "generated" - - -def test_organizationaffiliation_2(base_settings): - """No. 2 tests collection for OrganizationAffiliation. - Test File: orgrole-example-hie.json - """ - filename = base_settings["unittest_data_dir"] / "orgrole-example-hie.json" - inst = organizationaffiliation.OrganizationAffiliation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OrganizationAffiliation" == inst.resource_type - - impl_organizationaffiliation_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OrganizationAffiliation" == data["resourceType"] - - inst2 = organizationaffiliation.OrganizationAffiliation(**data) - impl_organizationaffiliation_2(inst2) - - -def impl_organizationaffiliation_3(inst): - assert inst.active is True - assert inst.code[0].coding[0].code == "provider" - assert inst.code[0].coding[0].display == "Provider" - assert inst.code[0].coding[0].system == "http://hl7.org/fhir/organization-role" - assert inst.code[0].coding[0].userSelected is True - assert inst.code[0].text == "Provider of rehabilitation services" - assert inst.healthcareService[0].display == "Inpatient rehabilitation services" - assert inst.healthcareService[0].reference == ( - "http://hl7.org/fhir/ig/vhdir/HealthcareService/independencer" "ehab1" - ) - assert inst.healthcareService[1].display == "Outpatient rehabilitation services" - assert inst.healthcareService[1].reference == ( - "http://hl7.org/fhir/ig/vhdir/HealthcareService/independencer" "ehab2" - ) - assert inst.id == "orgrole1" - assert inst.identifier[0].assigner.display == "Founding Fathers Memorial Hospital" - assert ( - inst.identifier[0].assigner.reference - == "http://hl7.org/fhir/ig/vhdir/Organization/foundingfathers" - ) - assert ( - inst.identifier[0].system - == "http://example.org/www.foundingfathersmemorial.com" - ) - assert inst.identifier[0].use == "secondary" - assert inst.identifier[0].value == "service002" - assert inst.location[0].display == "Founding Fathers Memorial Hospital" - assert ( - inst.location[0].reference - == "http://hl7.org/fhir/ig/vhdir/Location/foundingfathers1" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.network[0].display == "Patriot Preferred Provider Network" - assert ( - inst.network[0].reference == "http://hl7.org/fhir/ig/vhdir/Network/patriotppo" - ) - assert inst.organization.display == "Founding Fathers Memorial Hospital" - assert ( - inst.organization.reference - == "http://hl7.org/fhir/ig/vhdir/Organization/foundingfathers" - ) - assert ( - inst.participatingOrganization.display - == "Independence Rehabilitation Services, Inc." - ) - assert ( - inst.participatingOrganization.reference - == "http://hl7.org/fhir/ig/vhdir/Organization/independencerehab" - ) - assert inst.period.end == fhirtypes.DateTime.validate("2022-02-01T11:15:33+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2018-02-09T11:15:33+10:00") - assert inst.specialty[0].coding[0].code == "394602003" - assert inst.specialty[0].coding[0].display == "Rehabilitation - specialty" - assert inst.specialty[0].coding[0].system == "http://snomed.info/sct" - assert inst.specialty[0].text == "Rehabilitation" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "202-109-8765" - assert inst.text.status == "generated" - - -def test_organizationaffiliation_3(base_settings): - """No. 3 tests collection for OrganizationAffiliation. - Test File: orgrole-example-services.json - """ - filename = base_settings["unittest_data_dir"] / "orgrole-example-services.json" - inst = organizationaffiliation.OrganizationAffiliation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "OrganizationAffiliation" == inst.resource_type - - impl_organizationaffiliation_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "OrganizationAffiliation" == data["resourceType"] - - inst2 = organizationaffiliation.OrganizationAffiliation(**data) - impl_organizationaffiliation_3(inst2) diff --git a/fhir/resources/tests/test_parameters.py b/fhir/resources/tests/test_parameters.py deleted file mode 100644 index 1eff2165..00000000 --- a/fhir/resources/tests/test_parameters.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Parameters -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import parameters - - -def impl_parameters_1(inst): - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.parameter[0].name == "exact" - assert inst.parameter[0].valueBoolean is True - assert inst.parameter[1].name == "property" - assert inst.parameter[1].part[0].name == "code" - assert inst.parameter[1].part[0].valueCode == "focus" - assert inst.parameter[1].part[1].name == "value" - assert inst.parameter[1].part[1].valueCode == "top" - assert inst.parameter[2].name == "patient" - assert inst.parameter[2].resource.id == "example" - - -def test_parameters_1(base_settings): - """No. 1 tests collection for Parameters. - Test File: parameters-example.json - """ - filename = base_settings["unittest_data_dir"] / "parameters-example.json" - inst = parameters.Parameters.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Parameters" == inst.resource_type - - impl_parameters_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Parameters" == data["resourceType"] - - inst2 = parameters.Parameters(**data) - impl_parameters_1(inst2) diff --git a/fhir/resources/tests/test_patient.py b/fhir/resources/tests/test_patient.py deleted file mode 100644 index 6c2a38ec..00000000 --- a/fhir/resources/tests/test_patient.py +++ /dev/null @@ -1,557 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Patient -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import patient - - -def impl_patient_1(inst): - assert inst.active is True - assert inst.address[0].city == "Metropolis" - assert inst.address[0].country == "USA" - assert inst.address[0].line[0] == "100 Main St" - assert inst.address[0].postalCode == "44130" - assert inst.address[0].state == "Il" - assert inst.birthDate == fhirtypes.Date.validate("1956-05-27") - assert inst.gender == "male" - assert inst.id == "xds" - assert inst.identifier[0].system == "urn:oid:1.2.3.4.5" - assert inst.identifier[0].type.coding[0].code == "MR" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].use == "usual" - assert inst.identifier[0].value == "89765a87b" - assert inst.managingOrganization.reference == "Organization/2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Doe" - assert inst.name[0].given[0] == "John" - assert inst.text.status == "generated" - - -def test_patient_1(base_settings): - """No. 1 tests collection for Patient. - Test File: patient-example-xds.json - """ - filename = base_settings["unittest_data_dir"] / "patient-example-xds.json" - inst = patient.Patient.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Patient" == inst.resource_type - - impl_patient_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Patient" == data["resourceType"] - - inst2 = patient.Patient(**data) - impl_patient_1(inst2) - - -def impl_patient_2(inst): - assert inst.active is True - assert inst.address[0].city == "Amsterdam" - assert inst.address[0].country == "NLD" - assert inst.address[0].line[0] == "Van Egmondkade 23" - assert inst.address[0].postalCode == "1024 RJ" - assert inst.address[0].use == "home" - assert inst.birthDate == fhirtypes.Date.validate("1944-11-17") - assert inst.communication[0].language.coding[0].code == "nl" - assert inst.communication[0].language.coding[0].display == "Dutch" - assert inst.communication[0].language.coding[0].system == "urn:ietf:bcp:47" - assert inst.communication[0].language.text == "Nederlands" - assert inst.communication[0].preferred is True - assert inst.contact[0].name.family == "Abels" - assert inst.contact[0].name.given[0] == "Sarah" - assert inst.contact[0].name.use == "usual" - assert inst.contact[0].relationship[0].coding[0].code == "C" - assert ( - inst.contact[0].relationship[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0131" - ) - assert inst.contact[0].telecom[0].system == "phone" - assert inst.contact[0].telecom[0].use == "mobile" - assert inst.contact[0].telecom[0].value == "0690383372" - assert inst.deceasedBoolean is False - assert inst.gender == "male" - assert inst.id == "f001" - assert inst.identifier[0].system == "urn:oid:2.16.840.1.113883.2.4.6.3" - assert inst.identifier[0].use == "usual" - assert inst.identifier[0].value == "738472983" - assert inst.identifier[1].system == "urn:oid:2.16.840.1.113883.2.4.6.3" - assert inst.identifier[1].use == "usual" - assert inst.managingOrganization.display == "Burgers University Medical Centre" - assert inst.managingOrganization.reference == "Organization/f001" - assert inst.maritalStatus.coding[0].code == "M" - assert inst.maritalStatus.coding[0].display == "Married" - assert ( - inst.maritalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus" - ) - assert inst.maritalStatus.text == "Getrouwd" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.multipleBirthBoolean is True - assert inst.name[0].family == "van de Heuvel" - assert inst.name[0].given[0] == "Pieter" - assert inst.name[0].suffix[0] == "MSc" - assert inst.name[0].use == "usual" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "mobile" - assert inst.telecom[0].value == "0648352638" - assert inst.telecom[1].system == "email" - assert inst.telecom[1].use == "home" - assert inst.telecom[1].value == "p.heuvel@gmail.com" - assert inst.text.status == "generated" - - -def test_patient_2(base_settings): - """No. 2 tests collection for Patient. - Test File: patient-example-f001-pieter.json - """ - filename = base_settings["unittest_data_dir"] / "patient-example-f001-pieter.json" - inst = patient.Patient.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Patient" == inst.resource_type - - impl_patient_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Patient" == data["resourceType"] - - inst2 = patient.Patient(**data) - impl_patient_2(inst2) - - -def impl_patient_3(inst): - assert inst.active is True - assert inst.birthDate == fhirtypes.Date.validate("1982-08-02") - assert inst.deceasedBoolean is True - assert inst.gender == "female" - assert inst.id == "pat4" - assert inst.identifier[0].system == "urn:oid:0.1.2.3.4.5.6.7" - assert inst.identifier[0].type.coding[0].code == "MR" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].use == "usual" - assert inst.identifier[0].value == "123458" - assert inst.managingOrganization.display == "ACME Healthcare, Inc" - assert inst.managingOrganization.reference == "Organization/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Notsowell" - assert inst.name[0].given[0] == "Sandy" - assert inst.name[0].use == "official" - assert inst.text.status == "generated" - - -def test_patient_3(base_settings): - """No. 3 tests collection for Patient. - Test File: patient-example-d.json - """ - filename = base_settings["unittest_data_dir"] / "patient-example-d.json" - inst = patient.Patient.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Patient" == inst.resource_type - - impl_patient_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Patient" == data["resourceType"] - - inst2 = patient.Patient(**data) - impl_patient_3(inst2) - - -def impl_patient_4(inst): - assert inst.birthDate == fhirtypes.Date.validate("2017-05-15") - assert inst.contact[0].name.family == "Organa" - assert inst.contact[0].name.given[0] == "Leia" - assert inst.contact[0].name.use == "maiden" - assert inst.contact[0].relationship[0].coding[0].code == "72705000" - assert inst.contact[0].relationship[0].coding[0].display == "Mother" - assert inst.contact[0].relationship[0].coding[0].system == "http://snomed.info/sct" - assert inst.contact[0].relationship[0].coding[1].code == "N" - assert ( - inst.contact[0].relationship[0].coding[1].system - == "http://terminology.hl7.org/CodeSystem/v2-0131" - ) - assert inst.contact[0].relationship[0].coding[2].code == "MTH" - assert ( - inst.contact[0].relationship[0].coding[2].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - assert inst.contact[0].telecom[0].system == "phone" - assert inst.contact[0].telecom[0].use == "mobile" - assert inst.contact[0].telecom[0].value == "+31201234567" - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/patient-" "mothersMaidenName" - ) - assert inst.extension[0].valueString == "Organa" - assert inst.gender == "female" - assert inst.id == "infant-twin-1" - assert ( - inst.identifier[0].system - == "http://coruscanthealth.org/main-hospital/patient-identifier" - ) - assert inst.identifier[0].type.coding[0].code == "MR" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].value == "MRN7465737865" - assert ( - inst.identifier[1].system - == "http://new-republic.gov/galactic-citizen-identifier" - ) - assert inst.identifier[1].value == "7465737865" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.multipleBirthInteger == 1 - assert inst.name[0].family == "Solo" - assert inst.name[0].given[0] == "Jaina" - assert inst.name[0].use == "official" - assert inst.text.status == "generated" - - -def test_patient_4(base_settings): - """No. 4 tests collection for Patient. - Test File: patient-example-infant-twin-1.json - """ - filename = base_settings["unittest_data_dir"] / "patient-example-infant-twin-1.json" - inst = patient.Patient.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Patient" == inst.resource_type - - impl_patient_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Patient" == data["resourceType"] - - inst2 = patient.Patient(**data) - impl_patient_4(inst2) - - -def impl_patient_5(inst): - assert inst.birthDate == fhirtypes.Date.validate("1995-10-12") - assert inst.gender == "female" - assert inst.generalPractitioner[0].display == "Too-Onebee" - assert inst.generalPractitioner[0].reference == "Practitioner/21B" - assert inst.id == "infant-mom" - assert inst.maritalStatus.coding[0].code == "M" - assert inst.maritalStatus.coding[0].display == "Married" - assert ( - inst.maritalStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Solo" - assert inst.name[0].given[0] == "Leia" - assert inst.name[0].use == "official" - assert inst.name[1].family == "Organa" - assert inst.name[1].given[0] == "Leia" - assert inst.name[1].use == "maiden" - assert inst.text.status == "generated" - - -def test_patient_5(base_settings): - """No. 5 tests collection for Patient. - Test File: patient-example-infant-mom.json - """ - filename = base_settings["unittest_data_dir"] / "patient-example-infant-mom.json" - inst = patient.Patient.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Patient" == inst.resource_type - - impl_patient_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Patient" == data["resourceType"] - - inst2 = patient.Patient(**data) - impl_patient_5(inst2) - - -def impl_patient_6(inst): - assert inst.birthDate == fhirtypes.Date.validate("2017-09-05") - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/patient-" "mothersMaidenName" - ) - assert inst.extension[0].valueString == "Everywoman" - assert inst.gender == "male" - assert inst.id == "newborn" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.multipleBirthInteger == 2 - assert inst.text.status == "generated" - - -def test_patient_6(base_settings): - """No. 6 tests collection for Patient. - Test File: patient-example-newborn.json - """ - filename = base_settings["unittest_data_dir"] / "patient-example-newborn.json" - inst = patient.Patient.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Patient" == inst.resource_type - - impl_patient_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Patient" == data["resourceType"] - - inst2 = patient.Patient(**data) - impl_patient_6(inst2) - - -def impl_patient_7(inst): - assert inst.contact[0].name.family == "Organa" - assert inst.contact[0].name.given[0] == "Leia" - assert inst.contact[0].name.use == "maiden" - assert inst.contact[0].relationship[0].coding[0].code == "72705000" - assert inst.contact[0].relationship[0].coding[0].display == "Mother" - assert inst.contact[0].relationship[0].coding[0].system == "http://snomed.info/sct" - assert inst.contact[0].relationship[0].coding[1].code == "N" - assert ( - inst.contact[0].relationship[0].coding[1].system - == "http://terminology.hl7.org/CodeSystem/v2-0131" - ) - assert inst.contact[0].relationship[0].coding[2].code == "MTH" - assert ( - inst.contact[0].relationship[0].coding[2].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - assert inst.contact[0].telecom[0].system == "phone" - assert inst.contact[0].telecom[0].use == "mobile" - assert inst.contact[0].telecom[0].value == "+31201234567" - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/patient-" "mothersMaidenName" - ) - assert inst.extension[0].valueString == "Organa" - assert inst.gender == "male" - assert inst.id == "infant-fetal" - assert ( - inst.identifier[0].system - == "http://coruscanthealth.org/main-hospital/patient-identifier" - ) - assert inst.identifier[0].type.coding[0].code == "MR" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].value == "MRN657865757378" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_patient_7(base_settings): - """No. 7 tests collection for Patient. - Test File: patient-example-infant-fetal.json - """ - filename = base_settings["unittest_data_dir"] / "patient-example-infant-fetal.json" - inst = patient.Patient.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Patient" == inst.resource_type - - impl_patient_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Patient" == data["resourceType"] - - inst2 = patient.Patient(**data) - impl_patient_7(inst2) - - -def impl_patient_8(inst): - assert inst.active is True - assert inst.address[0].line[0] == "2222 Home Street" - assert inst.address[0].use == "home" - assert inst.birthDate == fhirtypes.Date.validate("1973-05-31") - assert inst.gender == "female" - assert inst.id == "genetics-example1" - assert inst.identifier[0].system == "http://hl7.org/fhir/sid/us-ssn" - assert inst.identifier[0].type.coding[0].code == "SS" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].value == "444222222" - assert inst.managingOrganization.reference == "Organization/hl7" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate("2012-05-29T23:45:32Z") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Everywoman" - assert inst.name[0].given[0] == "Eve" - assert inst.name[0].use == "official" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "555-555-2003" - assert inst.text.status == "generated" - - -def test_patient_8(base_settings): - """No. 8 tests collection for Patient. - Test File: patient-genetics-example1.json - """ - filename = base_settings["unittest_data_dir"] / "patient-genetics-example1.json" - inst = patient.Patient.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Patient" == inst.resource_type - - impl_patient_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Patient" == data["resourceType"] - - inst2 = patient.Patient(**data) - impl_patient_8(inst2) - - -def impl_patient_9(inst): - assert inst.active is True - assert inst.gender == "other" - assert inst.id == "pat2" - assert inst.identifier[0].system == "urn:oid:0.1.2.3.4.5.6.7" - assert inst.identifier[0].type.coding[0].code == "MR" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].use == "usual" - assert inst.identifier[0].value == "123456" - assert inst.link[0].other.reference == "Patient/pat1" - assert inst.link[0].type == "seealso" - assert inst.managingOrganization.display == "ACME Healthcare, Inc" - assert inst.managingOrganization.reference == "Organization/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Donald" - assert inst.name[0].given[0] == "Duck" - assert inst.name[0].given[1] == "D" - assert inst.name[0].use == "official" - assert inst.photo[0].contentType == "image/gif" - assert inst.text.status == "generated" - - -def test_patient_9(base_settings): - """No. 9 tests collection for Patient. - Test File: patient-example-b.json - """ - filename = base_settings["unittest_data_dir"] / "patient-example-b.json" - inst = patient.Patient.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Patient" == inst.resource_type - - impl_patient_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Patient" == data["resourceType"] - - inst2 = patient.Patient(**data) - impl_patient_9(inst2) - - -def impl_patient_10(inst): - assert inst.active is True - assert inst.birthDate == fhirtypes.Date.validate("1982-01-23") - assert inst.deceasedDateTime == fhirtypes.DateTime.validate( - "2015-02-14T13:42:00+10:00" - ) - assert inst.gender == "male" - assert inst.id == "pat3" - assert inst.identifier[0].system == "urn:oid:0.1.2.3.4.5.6.7" - assert inst.identifier[0].type.coding[0].code == "MR" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].use == "usual" - assert inst.identifier[0].value == "123457" - assert inst.managingOrganization.display == "ACME Healthcare, Inc" - assert inst.managingOrganization.reference == "Organization/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Notsowell" - assert inst.name[0].given[0] == "Simon" - assert inst.name[0].use == "official" - assert inst.text.status == "generated" - - -def test_patient_10(base_settings): - """No. 10 tests collection for Patient. - Test File: patient-example-c.json - """ - filename = base_settings["unittest_data_dir"] / "patient-example-c.json" - inst = patient.Patient.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Patient" == inst.resource_type - - impl_patient_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Patient" == data["resourceType"] - - inst2 = patient.Patient(**data) - impl_patient_10(inst2) diff --git a/fhir/resources/tests/test_paymentnotice.py b/fhir/resources/tests/test_paymentnotice.py deleted file mode 100644 index 3c649ba6..00000000 --- a/fhir/resources/tests/test_paymentnotice.py +++ /dev/null @@ -1,67 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/PaymentNotice -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import paymentnotice - - -def impl_paymentnotice_1(inst): - assert inst.amount.currency == "USD" - assert float(inst.amount.value) == float(12500.0) - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T11:15:33+10:00") - assert inst.id == "77654" - assert inst.identifier[0].system == "http://benefitsinc.com/paymentnotice" - assert inst.identifier[0].value == "776543" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.payee.reference == "Organization/1" - assert inst.payment.reference == "PaymentReconciliation/ER2500" - assert inst.paymentDate == fhirtypes.Date.validate("2014-08-15") - assert inst.paymentStatus.coding[0].code == "paid" - assert ( - inst.paymentStatus.coding[0].system - == "http://terminology.hl7.org/CodeSystem/paymentstatus" - ) - assert inst.provider.reference == "Organization/1" - assert inst.recipient.identifier.system == "http://regulators.gov" - assert inst.recipient.identifier.value == "AB123" - assert inst.request.reference == "http://benefitsinc.com/fhir/claim/12345" - assert ( - inst.response.reference == "http://benefitsinc.com/fhir/claimresponse/CR12345" - ) - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the PaymentNotice
" - ) - assert inst.text.status == "generated" - - -def test_paymentnotice_1(base_settings): - """No. 1 tests collection for PaymentNotice. - Test File: paymentnotice-example.json - """ - filename = base_settings["unittest_data_dir"] / "paymentnotice-example.json" - inst = paymentnotice.PaymentNotice.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PaymentNotice" == inst.resource_type - - impl_paymentnotice_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PaymentNotice" == data["resourceType"] - - inst2 = paymentnotice.PaymentNotice(**data) - impl_paymentnotice_1(inst2) diff --git a/fhir/resources/tests/test_paymentreconciliation.py b/fhir/resources/tests/test_paymentreconciliation.py deleted file mode 100644 index 3d775f6f..00000000 --- a/fhir/resources/tests/test_paymentreconciliation.py +++ /dev/null @@ -1,129 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/PaymentReconciliation -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import paymentreconciliation - - -def impl_paymentreconciliation_1(inst): - assert inst.created == fhirtypes.DateTime.validate("2014-08-16T11:15:33+10:00") - assert inst.detail[0].amount.currency == "USD" - assert float(inst.detail[0].amount.value) == float(3500.0) - assert inst.detail[0].date == fhirtypes.Date.validate("2014-08-16") - assert ( - inst.detail[0].identifier.system - == "http://www.BenefitsInc.com/payment/2018/detail" - ) - assert inst.detail[0].identifier.value == "10-12345-001" - assert inst.detail[0].payee.reference == "Organization/1" - assert ( - inst.detail[0].request.identifier.system == "http://happyvalleyclinic.com/claim" - ) - assert inst.detail[0].request.identifier.value == "AB12345" - assert ( - inst.detail[0].response.identifier.system - == "http://www.BenefitsInc.com/fhir/claimresponse" - ) - assert inst.detail[0].response.identifier.value == "CR20140815-AB12345" - assert inst.detail[0].submitter.reference == "Organization/1" - assert inst.detail[0].type.coding[0].code == "payment" - assert ( - inst.detail[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/payment-type" - ) - assert inst.detail[1].amount.currency == "USD" - assert float(inst.detail[1].amount.value) == float(4000.0) - assert inst.detail[1].date == fhirtypes.Date.validate("2014-08-12") - assert ( - inst.detail[1].identifier.system - == "http://www.BenefitsInc.com/payment/2018/detail" - ) - assert inst.detail[1].identifier.value == "10-12345-002" - assert ( - inst.detail[1].request.reference - == "http://www.BenefitsInc.com/fhir/oralhealthclaim/225476332699" - ) - assert inst.detail[1].type.coding[0].code == "payment" - assert ( - inst.detail[1].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/payment-type" - ) - assert inst.detail[2].amount.currency == "USD" - assert float(inst.detail[2].amount.value) == float(-1500.0) - assert inst.detail[2].date == fhirtypes.Date.validate("2014-08-16") - assert ( - inst.detail[2].identifier.system - == "http://www.BenefitsInc.com/payment/2018/detail" - ) - assert inst.detail[2].identifier.value == "10-12345-003" - assert inst.detail[2].type.coding[0].code == "advance" - assert ( - inst.detail[2].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/payment-type" - ) - assert inst.disposition == "2014 August mid-month settlement." - assert inst.formCode.coding[0].code == "PAYREC/2016/01B" - assert inst.formCode.coding[0].system == "http://ncforms.org/formid" - assert inst.id == "ER2500" - assert ( - inst.identifier[0].system - == "http://www.BenefitsInc.com/fhir/enrollmentresponse" - ) - assert inst.identifier[0].value == "781234" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome == "complete" - assert inst.paymentAmount.currency == "USD" - assert float(inst.paymentAmount.value) == float(7000.0) - assert inst.paymentDate == fhirtypes.Date.validate("2014-08-01") - assert inst.paymentIdentifier.system == "http://www.BenefitsInc.com/payment/2018" - assert inst.paymentIdentifier.value == "10-12345" - assert inst.paymentIssuer.reference == "Organization/2" - assert inst.period.end == fhirtypes.DateTime.validate("2014-08-31T11:15:33+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2014-08-16T11:15:33+10:00") - assert inst.processNote[0].text == ( - "Due to the year end holiday the cutoff for submissions for " - "December will be the 28th." - ) - assert inst.processNote[0].type == "display" - assert ( - inst.request.reference - == "http://www.BenefitsInc.com/fhir/eligibility/225476332402" - ) - assert inst.requestor.reference == "Organization/1" - assert inst.status == "active" - assert inst.text.div == ( - '
A human-readable' - " rendering of the PaymentReconciliation
" - ) - assert inst.text.status == "generated" - - -def test_paymentreconciliation_1(base_settings): - """No. 1 tests collection for PaymentReconciliation. - Test File: paymentreconciliation-example.json - """ - filename = base_settings["unittest_data_dir"] / "paymentreconciliation-example.json" - inst = paymentreconciliation.PaymentReconciliation.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PaymentReconciliation" == inst.resource_type - - impl_paymentreconciliation_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PaymentReconciliation" == data["resourceType"] - - inst2 = paymentreconciliation.PaymentReconciliation(**data) - impl_paymentreconciliation_1(inst2) diff --git a/fhir/resources/tests/test_person.py b/fhir/resources/tests/test_person.py deleted file mode 100644 index d318dd5e..00000000 --- a/fhir/resources/tests/test_person.py +++ /dev/null @@ -1,320 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Person -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import person - - -def impl_person_1(inst): - assert inst.active is True - assert inst.address[0].city == "Sandusky" - assert inst.address[0].country == "USA" - assert inst.address[0].line[0] == "2086 College St" - assert inst.address[0].postalCode == "44870" - assert inst.address[0].state == "OH" - assert inst.address[0].use == "home" - assert inst.birthDate == fhirtypes.Date.validate("1974-03-07") - assert inst.gender == "female" - assert inst.id == "pp" - assert inst.identifier[0].assigner.display == "Ohio Bureau of Motor Vehicles" - assert inst.identifier[0].period.start == fhirtypes.DateTime.validate( - "2041-09-23T11:15:33+10:00" - ) - assert inst.identifier[0].system == "urn:oid:2.16.840.1.113883.4.3.39" - assert inst.identifier[0].type.coding[0].code == "DL" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].type.text == "Ohio driver license" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "TL545786" - assert inst.link[0].assurance == "level3" - assert inst.link[0].target.display == "Eve Everywoman" - assert inst.link[0].target.reference == "http://www.goodhealth.com/Patient/98574" - assert inst.link[1].assurance == "level2" - assert inst.link[1].target.display == "Eve Marie Everywoman" - assert inst.link[1].target.reference == "http://www.acme-medical.com/Patient/ab34d" - assert inst.managingOrganization.display == "Goodhealth Patient Portal" - assert ( - inst.managingOrganization.reference - == "http://www.goodhealth.com/Organization/12" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Everywoman" - assert inst.name[0].given[0] == "Eve" - assert inst.name[0].given[1] == "Marie" - assert inst.name[0].use == "official" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "home" - assert inst.telecom[0].value == "(621)-479-9743" - assert inst.text.status == "generated" - - -def test_person_1(base_settings): - """No. 1 tests collection for Person. - Test File: person-patient-portal.json - """ - filename = base_settings["unittest_data_dir"] / "person-patient-portal.json" - inst = person.Person.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Person" == inst.resource_type - - impl_person_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Person" == data["resourceType"] - - inst2 = person.Person(**data) - impl_person_1(inst2) - - -def impl_person_2(inst): - assert inst.active is True - assert inst.birthDate == fhirtypes.Date.validate("1963") - assert inst.gender == "female" - assert inst.id == "f002" - assert inst.link[0].target.display == "Ariadne Bor-Jansma" - assert inst.link[0].target.reference == "RelatedPerson/f002" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].text == "Ariadne Bor-Jansma" - assert inst.name[0].use == "usual" - assert inst.photo.contentType == "image/jpeg" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "home" - assert inst.telecom[0].value == "+31201234567" - assert inst.text.status == "generated" - - -def test_person_2(base_settings): - """No. 2 tests collection for Person. - Test File: person-example-f002-ariadne.json - """ - filename = base_settings["unittest_data_dir"] / "person-example-f002-ariadne.json" - inst = person.Person.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Person" == inst.resource_type - - impl_person_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Person" == data["resourceType"] - - inst2 = person.Person(**data) - impl_person_2(inst2) - - -def impl_person_3(inst): - assert inst.active is True - assert inst.address[0].city == "Northfield" - assert inst.address[0].line[0] == "1003 Healthcare Drive" - assert inst.address[0].state == "MN" - assert inst.address[0].use == "home" - assert inst.birthDate == fhirtypes.Date.validate("1959-04-22") - assert inst.gender == "male" - assert inst.id == "pd" - assert inst.identifier[0].system == "http://hl7.org/fhir/sid/us-ssn" - assert inst.identifier[0].type.coding[0].code == "SS" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "444444444" - assert inst.link[0].assurance == "level2" - assert inst.link[0].target.display == "Dr. Harold Hippocrates" - assert ( - inst.link[0].target.reference == "http://www.goodhealth.com/Practitioner/98574" - ) - assert inst.link[1].assurance == "level2" - assert inst.link[1].target.display == "Harold Hippocrates, MD" - assert ( - inst.link[1].target.reference - == "http://www.acme-medical.com/Practitioner/ab34d" - ) - assert ( - inst.managingOrganization.display == "Northfield Regional Physician Directory" - ) - assert ( - inst.managingOrganization.reference - == "http://www.northfield-regional.com/Organization/2" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Hippocrates" - assert inst.name[0].given[0] == "Harold" - assert inst.name[0].use == "official" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "555-555-1003" - assert inst.text.status == "generated" - - -def test_person_3(base_settings): - """No. 3 tests collection for Person. - Test File: person-provider-directory.json - """ - filename = base_settings["unittest_data_dir"] / "person-provider-directory.json" - inst = person.Person.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Person" == inst.resource_type - - impl_person_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Person" == data["resourceType"] - - inst2 = person.Person(**data) - impl_person_3(inst2) - - -def impl_person_4(inst): - assert inst.active is True - assert inst.address[0].city == "PleasantVille" - assert inst.address[0].line[0] == "534 Erewhon St" - assert inst.address[0].postalCode == "3999" - assert inst.address[0].state == "Vic" - assert inst.address[0].use == "home" - assert inst.birthDate == fhirtypes.Date.validate("1974-12-25") - assert inst.gender == "male" - assert inst.id == "example" - assert inst.identifier[0].assigner.display == "Acme Healthcare" - assert inst.identifier[0].period.start == fhirtypes.DateTime.validate( - "2001-05-06T11:15:33+10:00" - ) - assert inst.identifier[0].system == "urn:oid:1.2.36.146.595.217.0.1" - assert inst.identifier[0].type.coding[0].code == "MR" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].use == "usual" - assert inst.identifier[0].value == "12345" - assert inst.link[0].target.display == "Peter Chalmers" - assert inst.link[0].target.reference == "RelatedPerson/peter" - assert inst.link[1].target.display == "Peter Chalmers" - assert inst.link[1].target.reference == "Patient/example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Chalmers" - assert inst.name[0].given[0] == "Peter" - assert inst.name[0].given[1] == "James" - assert inst.name[0].use == "official" - assert inst.name[1].given[0] == "Jim" - assert inst.name[1].use == "usual" - assert inst.telecom[0].use == "home" - assert inst.telecom[1].system == "phone" - assert inst.telecom[1].use == "work" - assert inst.telecom[1].value == "(03) 5555 6473" - assert inst.telecom[2].system == "email" - assert inst.telecom[2].use == "home" - assert inst.telecom[2].value == "Jim@example.org" - assert inst.text.status == "generated" - - -def test_person_4(base_settings): - """No. 4 tests collection for Person. - Test File: person-example.json - """ - filename = base_settings["unittest_data_dir"] / "person-example.json" - inst = person.Person.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Person" == inst.resource_type - - impl_person_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Person" == data["resourceType"] - - inst2 = person.Person(**data) - impl_person_4(inst2) - - -def impl_person_5(inst): - assert inst.active is True - assert inst.address[0].city == "PleasantVille" - assert inst.address[0].line[0] == "534 Erewhon St" - assert inst.address[0].postalCode == "3999" - assert inst.address[0].state == "Vic" - assert inst.address[0].use == "home" - assert inst.birthDate == fhirtypes.Date.validate("1974-12-25") - assert inst.gender == "male" - assert inst.id == "grahame" - assert inst.identifier[0].assigner.display == "Acme Healthcare" - assert inst.identifier[0].period.start == fhirtypes.DateTime.validate( - "2001-05-06T11:15:33+10:00" - ) - assert inst.identifier[0].system == "urn:oid:1.2.36.146.595.217.0.1" - assert inst.identifier[0].type.coding[0].code == "MR" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].use == "usual" - assert inst.identifier[0].value == "12345" - assert inst.managingOrganization.reference == "Organization/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Chalmers" - assert inst.name[0].given[0] == "Peter" - assert inst.name[0].given[1] == "James" - assert inst.name[0].use == "official" - assert inst.name[1].given[0] == "Jim" - assert inst.name[1].use == "usual" - assert inst.telecom[0].use == "home" - assert inst.telecom[1].system == "phone" - assert inst.telecom[1].use == "work" - assert inst.telecom[1].value == "(03) 5555 6473" - assert inst.text.status == "generated" - - -def test_person_5(base_settings): - """No. 5 tests collection for Person. - Test File: person-grahame.json - """ - filename = base_settings["unittest_data_dir"] / "person-grahame.json" - inst = person.Person.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Person" == inst.resource_type - - impl_person_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Person" == data["resourceType"] - - inst2 = person.Person(**data) - impl_person_5(inst2) diff --git a/fhir/resources/tests/test_plandefinition.py b/fhir/resources/tests/test_plandefinition.py deleted file mode 100644 index 6bbeefd9..00000000 --- a/fhir/resources/tests/test_plandefinition.py +++ /dev/null @@ -1,2036 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/PlanDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import plandefinition - - -def impl_plandefinition_1(inst): - assert ( - inst.action[0].action[0].action[0].action[0].action[0].definitionCanonical - == "#1111" - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[0] - .extension[0] - .extension[0] - .url - == "day" - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[0] - .extension[0] - .extension[0] - .valueInteger - == 1 - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[0] - .extension[0] - .extension[1] - .url - == "day" - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[0] - .extension[0] - .extension[1] - .valueInteger - == 8 - ) - assert ( - inst.action[0].action[0].action[0].action[0].action[0].extension[0].url - == "http://hl7.org/fhir/StructureDefinition/timing-daysOfCycle" - ) - assert inst.action[0].action[0].action[0].action[0].action[0].id == "action-1" - assert ( - inst.action[0].action[0].action[0].action[0].action[0].textEquivalent - == "Gemcitabine 1250 mg/m² IV over 30 minutes on days 1 and 8" - ) - assert ( - inst.action[0].action[0].action[0].action[0].action[1].definitionCanonical - == "#2222" - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[1] - .extension[0] - .extension[0] - .url - == "day" - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[1] - .extension[0] - .extension[0] - .valueInteger - == 1 - ) - assert ( - inst.action[0].action[0].action[0].action[0].action[1].extension[0].url - == "http://hl7.org/fhir/StructureDefinition/timing-daysOfCycle" - ) - assert inst.action[0].action[0].action[0].action[0].action[1].id == "action-2" - assert ( - inst.action[0].action[0].action[0].action[0].action[1].relatedAction[0].actionId - == "action-1" - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[1] - .relatedAction[0] - .relationship - == "concurrent-with-start" - ) - assert ( - inst.action[0].action[0].action[0].action[0].action[1].textEquivalent - == "CARBOplatin AUC 5 IV over 30 minutes on Day 1" - ) - assert inst.action[0].action[0].action[0].action[0].id == "cycle-definition-1" - assert ( - inst.action[0].action[0].action[0].action[0].textEquivalent - == "21-day cycle for 6 cycles" - ) - assert inst.action[0].action[0].action[0].action[0].timingTiming.repeat.count == 6 - assert float( - inst.action[0].action[0].action[0].action[0].timingTiming.repeat.duration - ) == float(21) - assert ( - inst.action[0].action[0].action[0].action[0].timingTiming.repeat.durationUnit - == "d" - ) - assert inst.action[0].action[0].action[0].groupingBehavior == "sentence-group" - assert inst.action[0].action[0].action[0].selectionBehavior == "exactly-one" - assert inst.action[0].action[0].selectionBehavior == "all" - assert inst.action[0].selectionBehavior == "exactly-one" - assert inst.approvalDate == fhirtypes.Date.validate("2016-07-27") - assert inst.author[0].name == "Lee Surprenant" - assert inst.contained[0].id == "1111" - assert inst.contained[1].id == "2222" - assert inst.copyright == "All rights reserved." - assert inst.experimental is True - assert inst.id == "KDN5" - assert inst.identifier[0].system == "http://example.org/ordertemplates" - assert inst.identifier[0].value == "KDN5" - assert inst.lastReviewDate == fhirtypes.Date.validate("2016-07-27") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "National Comprehensive Cancer Network, Inc." - assert ( - inst.relatedArtifact[0].display == "NCCN Guidelines for Kidney Cancer. V.2.2016" - ) - assert inst.relatedArtifact[0].type == "derived-from" - assert inst.relatedArtifact[0].url == ( - "http://www.example.org/professionals/physician_gls/PDF/kidne" "y.pdf" - ) - assert ( - inst.relatedArtifact[1].citation - == "Oudard S, et al. J Urol. 2007;177(5):1698-702" - ) - assert inst.relatedArtifact[1].type == "citation" - assert inst.relatedArtifact[1].url == "http://www.ncbi.nlm.nih.gov/pubmed/17437788" - assert inst.status == "draft" - assert inst.text.status == "additional" - assert inst.title == "Gemcitabine/CARBOplatin" - assert inst.type.text == "Chemotherapy Order Template" - assert inst.useContext[0].code.code == "treamentSetting-or-diseaseStatus" - assert ( - inst.useContext[0].code.system - == "http://example.org/fhir/CodeSystem/indications" - ) - assert ( - inst.useContext[0].extension[0].url - == "http://hl7.org/fhir/StructureDefinition/usagecontext-group" - ) - assert inst.useContext[0].extension[0].valueString == "A" - assert inst.useContext[0].valueCodeableConcept.text == "Metastatic" - assert inst.useContext[1].code.code == "disease-or-histology" - assert ( - inst.useContext[1].code.system - == "http://example.org/fhir/CodeSystem/indications" - ) - assert ( - inst.useContext[1].extension[0].url - == "http://hl7.org/fhir/StructureDefinition/usagecontext-group" - ) - assert inst.useContext[1].extension[0].valueString == "A" - assert ( - inst.useContext[1].valueCodeableConcept.text - == "Collecting Duct/Medullary Subtypes" - ) - assert inst.useContext[2].code.code == "focus" - assert ( - inst.useContext[2].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert ( - inst.useContext[2].extension[0].url - == "http://hl7.org/fhir/StructureDefinition/usagecontext-group" - ) - assert inst.useContext[2].extension[0].valueString == "A" - assert inst.useContext[2].valueCodeableConcept.text == "Kidney Cancer" - assert inst.useContext[3].code.code == "treatmentSetting-or-diseaseStatus" - assert ( - inst.useContext[3].code.system - == "http://example.org/fhir/CodeSystem/indications" - ) - assert ( - inst.useContext[3].extension[0].url - == "http://hl7.org/fhir/StructureDefinition/usagecontext-group" - ) - assert inst.useContext[3].extension[0].valueString == "B" - assert inst.useContext[3].valueCodeableConcept.text == "Relapsed" - assert inst.useContext[4].code.code == "disease-or-histology" - assert ( - inst.useContext[4].code.system - == "http://example.org/fhir/CodeSystem/indications" - ) - assert ( - inst.useContext[4].extension[0].url - == "http://hl7.org/fhir/StructureDefinition/usagecontext-group" - ) - assert inst.useContext[4].extension[0].valueString == "B" - assert ( - inst.useContext[4].valueCodeableConcept.text - == "Collecting Duct/Medullary Subtypes" - ) - assert inst.useContext[5].code.code == "focus" - assert ( - inst.useContext[5].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert ( - inst.useContext[5].extension[0].url - == "http://hl7.org/fhir/StructureDefinition/usagecontext-group" - ) - assert inst.useContext[5].extension[0].valueString == "B" - assert inst.useContext[5].valueCodeableConcept.text == ( - "Kidney Cancer – Collecting Duct/Medullary Subtypes - " "Metastatic" - ) - assert inst.version == "1" - - -def test_plandefinition_1(base_settings): - """No. 1 tests collection for PlanDefinition. - Test File: plandefinition-example-kdn5-simplified.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "plandefinition-example-kdn5-simplified.json" - ) - inst = plandefinition.PlanDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PlanDefinition" == inst.resource_type - - impl_plandefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PlanDefinition" == data["resourceType"] - - inst2 = plandefinition.PlanDefinition(**data) - impl_plandefinition_1(inst2) - - -def impl_plandefinition_2(inst): - assert ( - inst.action[0].action[0].definitionCanonical - == "#activitydefinition-medicationrequest-1" - ) - assert inst.action[0].action[0].id == "medication-action-1" - assert inst.action[0].action[0].title == "Administer Medication 1" - assert ( - inst.action[0].action[1].definitionCanonical - == "#activitydefinition-medicationrequest-2" - ) - assert inst.action[0].action[1].id == "medication-action-2" - assert inst.action[0].action[1].relatedAction[0].actionId == "medication-action-1" - assert inst.action[0].action[1].relatedAction[0].offsetDuration.unit == "h" - assert float( - inst.action[0].action[1].relatedAction[0].offsetDuration.value - ) == float(1) - assert inst.action[0].action[1].relatedAction[0].relationship == "after-end" - assert inst.action[0].action[1].title == "Administer Medication 2" - assert inst.action[0].groupingBehavior == "logical-group" - assert inst.action[0].selectionBehavior == "all" - assert inst.contained[0].id == "activitydefinition-medicationrequest-1" - assert inst.contained[1].id == "activitydefinition-medicationrequest-2" - assert inst.id == "options-example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "draft" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - assert inst.title == "This example illustrates relationships between actions." - - -def test_plandefinition_2(base_settings): - """No. 2 tests collection for PlanDefinition. - Test File: plandefinition-options-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "plandefinition-options-example.json" - ) - inst = plandefinition.PlanDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PlanDefinition" == inst.resource_type - - impl_plandefinition_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PlanDefinition" == data["resourceType"] - - inst2 = plandefinition.PlanDefinition(**data) - impl_plandefinition_2(inst2) - - -def impl_plandefinition_3(inst): - assert ( - inst.action[0].action[0].dynamicValue[0].expression.expression - == "Communication Request to Provider" - ) - assert inst.action[0].action[0].dynamicValue[0].expression.language == "text/cql" - assert inst.action[0].action[0].dynamicValue[0].path == "/" - assert inst.action[0].action[0].textEquivalent == ( - "A Breastfeeding Readiness Assessment is recommended, please " - "authorize or reject the order." - ) - assert inst.action[0].action[0].title == "Notify the provider to sign the order." - assert inst.action[0].action[0].type.coding[0].code == "create" - assert ( - inst.action[0].condition[0].expression.expression - == "Should Notify Provider to Sign Assessment Order" - ) - assert inst.action[0].condition[0].expression.language == "text/cql" - assert inst.action[0].condition[0].kind == "applicability" - assert inst.action[0].title == ( - "Mother should be administered a breastfeeding readiness " "assessment." - ) - assert inst.action[0].trigger[0].name == "Admission" - assert inst.action[0].trigger[0].type == "named-event" - assert inst.action[0].trigger[1].name == "Birth" - assert inst.action[0].trigger[1].type == "named-event" - assert inst.action[0].trigger[2].name == "Infant Transfer to Recovery" - assert inst.action[0].trigger[2].type == "named-event" - assert inst.action[0].trigger[3].name == "Transfer to Post-Partum" - assert inst.action[0].trigger[3].type == "named-event" - assert inst.date == fhirtypes.DateTime.validate("2015-03-08T11:15:33+10:00") - assert inst.id == "exclusive-breastfeeding-intervention-02" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "exclusive-breastfeeding-intervention-02" - assert inst.library[0] == "Library/library-exclusive-breastfeeding-cds-logic" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.relatedArtifact[0].resource == "Measure/measure-exclusive-breastfeeding" - assert inst.relatedArtifact[0].type == "derived-from" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Exclusive Breastfeeding Intervention-02" - assert inst.topic[0].text == "Exclusive Breastfeeding" - assert inst.version == "1.0.0" - - -def test_plandefinition_3(base_settings): - """No. 3 tests collection for PlanDefinition. - Test File: plandefinition-exclusive-breastfeeding-intervention-02.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "plandefinition-exclusive-breastfeeding-intervention-02.json" - ) - inst = plandefinition.PlanDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PlanDefinition" == inst.resource_type - - impl_plandefinition_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PlanDefinition" == data["resourceType"] - - inst2 = plandefinition.PlanDefinition(**data) - impl_plandefinition_3(inst2) - - -def impl_plandefinition_4(inst): - assert ( - inst.action[0].action[0].dynamicValue[0].expression.expression - == "Communication Request to Charge Nurse" - ) - assert inst.action[0].action[0].dynamicValue[0].expression.language == "text/cql" - assert inst.action[0].action[0].dynamicValue[0].path == "/" - assert inst.action[0].action[0].textEquivalent == ( - "A Breastfeeding Readiness Assessment is recommended, please " - "administer the assessment." - ) - assert ( - inst.action[0].action[0].title - == "Notify the charge nurse to perform the assessment." - ) - assert inst.action[0].action[0].type.coding[0].code == "create" - assert ( - inst.action[0].action[1].dynamicValue[0].expression.expression - == "Communication Request to Bedside Nurse" - ) - assert inst.action[0].action[1].dynamicValue[0].expression.language == "text/cql" - assert inst.action[0].action[1].dynamicValue[0].path == "/" - assert inst.action[0].action[1].textEquivalent == ( - "A Breastfeeding Readiness Assessment is recommended, please " - "administer the assessment." - ) - assert ( - inst.action[0].action[1].title - == "Notify the bedside nurse to perform the assessment." - ) - assert inst.action[0].action[1].type.coding[0].code == "create" - assert ( - inst.action[0].condition[0].expression.expression - == "Should Notify Nurse to Perform Assessment" - ) - assert inst.action[0].condition[0].expression.language == "text/cql" - assert inst.action[0].condition[0].kind == "applicability" - assert inst.action[0].title == ( - "Mother should be administered a breastfeeding readiness " "assessment." - ) - assert inst.action[0].trigger[0].name == "Admission" - assert inst.action[0].trigger[0].type == "named-event" - assert inst.action[0].trigger[1].name == "Birth" - assert inst.action[0].trigger[1].type == "named-event" - assert inst.action[0].trigger[2].name == "Infant Transfer to Recovery" - assert inst.action[0].trigger[2].type == "named-event" - assert inst.action[0].trigger[3].name == "Transfer to Post-Partum" - assert inst.action[0].trigger[3].type == "named-event" - assert inst.date == fhirtypes.DateTime.validate("2015-03-08T11:15:33+10:00") - assert inst.id == "exclusive-breastfeeding-intervention-03" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "exclusive-breastfeeding-intervention-03" - assert inst.library[0] == "Library/library-exclusive-breastfeeding-cds-logic" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.relatedArtifact[0].resource == "Measure/measure-exclusive-breastfeeding" - assert inst.relatedArtifact[0].type == "derived-from" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Exclusive Breastfeeding Intervention-03" - assert inst.topic[0].text == "Exclusive Breastfeeding" - assert inst.version == "1.0.0" - - -def test_plandefinition_4(base_settings): - """No. 4 tests collection for PlanDefinition. - Test File: plandefinition-exclusive-breastfeeding-intervention-03.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "plandefinition-exclusive-breastfeeding-intervention-03.json" - ) - inst = plandefinition.PlanDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PlanDefinition" == inst.resource_type - - impl_plandefinition_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PlanDefinition" == data["resourceType"] - - inst2 = plandefinition.PlanDefinition(**data) - impl_plandefinition_4(inst2) - - -def impl_plandefinition_5(inst): - assert ( - inst.action[0].action[0].action[0].definitionCanonical - == "#referralToCardiologyConsult" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[0].expression.expression - == "Now()" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[0].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[0].path == "timing.event" - assert inst.action[0].action[0].action[0].dynamicValue[1].expression.expression == ( - "Code '261QM0850X' from CardiologyChestPainLogic.\"NUCC " - "Provider Taxonomy\" display 'Adult Mental Health'" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[1].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[1].path == "specialty" - assert ( - inst.action[0].action[0].action[0].dynamicValue[2].expression.expression - == "CardiologyChestPainLogic.ServiceRequestFulfillmentTime" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[2].expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[2].path == "occurrenceDateTime" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[3].expression.expression - == "CardiologyChestPainLogic.Patient" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[3].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[3].path == "subject" - assert ( - inst.action[0].action[0].action[0].dynamicValue[4].expression.expression - == "CardiologyChestPainLogic.Practitioner" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[4].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[4].path == "requester.agent" - assert ( - inst.action[0].action[0].action[0].dynamicValue[5].expression.expression - == "CardiologyChestPainLogic.CardiologyReferralReason" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[5].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[5].path == "reasonCode" - assert ( - inst.action[0].action[0].action[0].dynamicValue[6].expression.expression - == "CardiologyChestPainLogic.RiskAssessment" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[6].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[6].path == "reasonReference" - assert ( - inst.action[0].action[0].action[0].textEquivalent - == "Referral to cardiology to evaluate chest pain (routine)" - ) - assert ( - inst.action[0].action[0].action[1].definitionCanonical - == "#CollectReferralReason" - ) - assert ( - inst.action[0].action[0].action[1].title == "Reason for cardiology consultation" - ) - assert ( - inst.action[0].action[0].action[2].definitionCanonical - == "#CardiologyConsultationGoal" - ) - assert inst.action[0].action[0].action[2].title == "Goal of cardiology consultation" - assert inst.action[0].action[0].groupingBehavior == "logical-group" - assert inst.action[0].action[0].selectionBehavior == "any" - assert inst.action[0].action[0].title == "Consults and Referrals" - assert inst.action[0].action[1].action[0].groupingBehavior == "logical-group" - assert inst.action[0].action[1].action[0].selectionBehavior == "at-most-one" - assert ( - inst.action[0].action[1].action[1].action[0].definitionCanonical - == "#metoprololTartrate25Prescription" - ) - assert ( - inst.action[0] - .action[1] - .action[1] - .action[0] - .dynamicValue[0] - .expression.expression - == "'draft'" - ) - assert ( - inst.action[0].action[1].action[1].action[0].dynamicValue[0].expression.language - == "text/cql" - ) - assert inst.action[0].action[1].action[1].action[0].dynamicValue[0].path == "status" - assert ( - inst.action[0] - .action[1] - .action[1] - .action[0] - .dynamicValue[1] - .expression.expression - == "CardiologyChestPainLogic.Patient" - ) - assert ( - inst.action[0].action[1].action[1].action[0].dynamicValue[1].expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[1].action[0].dynamicValue[1].path == "patient" - ) - assert ( - inst.action[0] - .action[1] - .action[1] - .action[0] - .dynamicValue[2] - .expression.expression - == "CardiologyChestPainLogic.Practitioner" - ) - assert ( - inst.action[0].action[1].action[1].action[0].dynamicValue[2].expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[1].action[0].dynamicValue[2].path - == "prescriber" - ) - assert ( - inst.action[0].action[1].action[1].action[0].textEquivalent - == "metoprolol tartrate 25 mg tablet 1 tablet oral 2 time daily" - ) - assert ( - inst.action[0].action[1].action[1].action[1].definitionCanonical - == "#metoprololTartrate50Prescription" - ) - assert ( - inst.action[0] - .action[1] - .action[1] - .action[1] - .dynamicValue[0] - .expression.expression - == "'draft'" - ) - assert ( - inst.action[0].action[1].action[1].action[1].dynamicValue[0].expression.language - == "text/cql" - ) - assert inst.action[0].action[1].action[1].action[1].dynamicValue[0].path == "status" - assert ( - inst.action[0] - .action[1] - .action[1] - .action[1] - .dynamicValue[1] - .expression.expression - == "CardiologyChestPainLogic.Patient" - ) - assert ( - inst.action[0].action[1].action[1].action[1].dynamicValue[1].expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[1].action[1].dynamicValue[1].path == "patient" - ) - assert ( - inst.action[0] - .action[1] - .action[1] - .action[1] - .dynamicValue[2] - .expression.expression - == "CardiologyChestPainLogic.Practitioner" - ) - assert ( - inst.action[0].action[1].action[1].action[1].dynamicValue[2].expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[1].action[1].dynamicValue[2].path - == "prescriber" - ) - assert ( - inst.action[0].action[1].action[1].action[1].textEquivalent - == "metoprolol tartrate 50 mg tablet 1 tablet oral 2 time daily" - ) - assert ( - inst.action[0].action[1].action[1].action[2].definitionCanonical - == "#amlodipinePrescription" - ) - assert ( - inst.action[0] - .action[1] - .action[1] - .action[2] - .dynamicValue[0] - .expression.expression - == "'draft'" - ) - assert ( - inst.action[0].action[1].action[1].action[2].dynamicValue[0].expression.language - == "text/cql" - ) - assert inst.action[0].action[1].action[1].action[2].dynamicValue[0].path == "status" - assert ( - inst.action[0] - .action[1] - .action[1] - .action[2] - .dynamicValue[1] - .expression.expression - == "CardiologyChestPainLogic.Patient" - ) - assert ( - inst.action[0].action[1].action[1].action[2].dynamicValue[1].expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[1].action[2].dynamicValue[1].path == "patient" - ) - assert ( - inst.action[0] - .action[1] - .action[1] - .action[2] - .dynamicValue[2] - .expression.expression - == "CardiologyChestPainLogic.Practitioner" - ) - assert ( - inst.action[0].action[1].action[1].action[2].dynamicValue[2].expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[1].action[2].dynamicValue[2].path - == "prescriber" - ) - assert ( - inst.action[0].action[1].action[1].action[2].textEquivalent - == "amlodipine 5 tablet 1 tablet oral daily" - ) - assert inst.action[0].action[1].action[1].groupingBehavior == "logical-group" - assert inst.action[0].action[1].action[1].selectionBehavior == "at-most-one" - assert inst.action[0].action[1].action[1].title == "Antianginal Therapy" - assert ( - inst.action[0].action[1].action[2].action[0].definitionCanonical - == "#nitroglycerinPrescription" - ) - assert ( - inst.action[0] - .action[1] - .action[2] - .action[0] - .dynamicValue[0] - .expression.expression - == "'draft'" - ) - assert ( - inst.action[0].action[1].action[2].action[0].dynamicValue[0].expression.language - == "text/cql" - ) - assert inst.action[0].action[1].action[2].action[0].dynamicValue[0].path == "status" - assert ( - inst.action[0] - .action[1] - .action[2] - .action[0] - .dynamicValue[1] - .expression.expression - == "CardiologyChestPainLogic.Patient" - ) - assert ( - inst.action[0].action[1].action[2].action[0].dynamicValue[1].expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[2].action[0].dynamicValue[1].path == "patient" - ) - assert ( - inst.action[0] - .action[1] - .action[2] - .action[0] - .dynamicValue[2] - .expression.expression - == "CardiologyChestPainLogic.Practitioner" - ) - assert ( - inst.action[0].action[1].action[2].action[0].dynamicValue[2].expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[2].action[0].dynamicValue[2].path - == "prescriber" - ) - assert inst.action[0].action[1].action[2].action[0].textEquivalent == ( - "nitroglycerin 0.4 mg tablet sub-lingual every 5 minutes as " - "needed for chest pain; maximum 3 tablets" - ) - assert inst.action[0].action[1].action[2].groupingBehavior == "logical-group" - assert inst.action[0].action[1].action[2].selectionBehavior == "at-most-one" - assert inst.action[0].action[1].action[2].title == "Nitroglycerin" - assert inst.action[0].action[1].description == ( - "Consider the following medications for stable patients to be" - " initiated prior to the cardiology consultation." - ) - assert inst.action[0].action[1].title == "Medications" - assert inst.author[0].name == "Bruce Bray MD" - assert inst.author[1].name == "Scott Wall MD" - assert inst.author[2].name == "Aiden Abidov MD, PhD" - assert inst.contained[0].id == "cardiology-chestPain-logic" - assert inst.contained[1].id == "referralToCardiologyConsult" - assert inst.contained[2].id == "metoprololTartrate25Prescription" - assert inst.contained[3].id == "metoprololTartrate25Medication" - assert inst.contained[4].id == "metoprololTartrate25Substance" - assert inst.contained[5].id == "metoprololTartrate50Prescription" - assert inst.contained[6].id == "metoprololTartrate50Medication" - assert inst.contained[7].id == "metoprololTartrate50Substance" - assert inst.contained[8].id == "nitroglycerinPrescription" - assert inst.contained[9].id == "nitroglycerinMedication" - assert inst.copyright == ( - "© Copyright Cognitive Medical Systems, Inc. 9444 Waples " - "Street Suite 300 San Diego, CA 92121" - ) - assert inst.date == fhirtypes.DateTime.validate("2017-08-29T11:15:33+10:00") - assert inst.id == "example-cardiology-os" - assert inst.identifier[0].system == "urn:va.gov:kbs:knart:artifact:r1" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "bb7ccea6-9744-4743-854a-bcffd87191f6" - assert inst.identifier[1].system == ( - "urn:va.gov:kbs:contract:VA118-16-D-1008:to:VA-118-16-F-1008-" "0007" - ) - assert inst.identifier[1].value == "CLIN0004AG" - assert inst.identifier[2].system == "urn:cognitivemedicine.com:lab:jira" - assert inst.identifier[2].value == "KP-914" - assert inst.library[0] == "#cardiology-chestPain-logic" - assert inst.name == "ChestPainCoronaryArteryDiseaseOrderSetKNART" - assert inst.publisher == "Department of Veterans Affairs" - assert inst.relatedArtifact[0].display == ( - "Cardiology: Chest Pain (CP) / Coronary Artery Disease (CAD) " - "Clinical Content White Paper" - ) - assert inst.relatedArtifact[0].type == "derived-from" - assert inst.relatedArtifact[0].url == "http://example.com/" - assert inst.relatedArtifact[1].display == ( - "Outcome CVD (coronary death, myocardial infarction, coronary" - " insufficiency, angina, ischemic stroke, hemorrhagic stroke," - " transient ischemic attack, peripheral artery disease, heart" - " failure)" - ) - assert inst.relatedArtifact[1].type == "justification" - assert inst.relatedArtifact[1].url == ( - "https://www.framinghamheartstudy.org/risk-" - "functions/cardiovascular-disease/10-year-risk.php" - ) - assert inst.relatedArtifact[2].display == ( - "General cardiovascular risk profile for use in primary care:" - " the Framingham Heart Study" - ) - assert inst.relatedArtifact[2].type == "justification" - assert inst.relatedArtifact[2].url == ( - "https://www.framinghamheartstudy.org/risk-" - "functions/cardiovascular-disease/10-year-risk.php" - ) - assert inst.relatedArtifact[3].type == "justification" - assert inst.relatedArtifact[3].url == "https://example.org/" - assert inst.relatedArtifact[4].type == "justification" - assert inst.relatedArtifact[4].url == "http://example.org/" - assert ( - inst.relatedArtifact[5].display - == "LABEL: ASPIRIN 81 MG- aspirin tablet, coated" - ) - assert inst.relatedArtifact[5].type == "justification" - assert inst.relatedArtifact[5].url == ( - "https://dailymed.nlm.nih.gov/dailymed/drugInfo.cfm?setid=b40" - "64039-2345-4227-b83d-54dc13a838d3" - ) - assert inst.relatedArtifact[6].display == ( - "LABEL: CLOPIDOGREL- clopidogrel bisulfate tablet, film " "coated" - ) - assert inst.relatedArtifact[6].type == "justification" - assert inst.relatedArtifact[6].url == ( - "https://dailymed.nlm.nih.gov/dailymed/drugInfo.cfm?setid=7fe" - "85155-bc00-406b-b097-e8aece187a8a" - ) - assert ( - inst.relatedArtifact[7].display - == "LABEL: LIPITOR- atorvastatin calcium tablet, film coated" - ) - assert inst.relatedArtifact[7].type == "justification" - assert inst.relatedArtifact[7].url == ( - "https://dailymed.nlm.nih.gov/dailymed/drugInfo.cfm?setid=7fe" - "85155-bc00-406b-b097-e8aece187a8a" - ) - assert inst.relatedArtifact[8].display == ( - "LABEL: METOPROLOL SUCCINATE EXTENDED-RELEASE - metoprolol " - "succinate tablet, film coated, extended release" - ) - assert inst.relatedArtifact[8].type == "justification" - assert inst.relatedArtifact[8].url == ( - "https://dailymed.nlm.nih.gov/dailymed/drugInfo.cfm?setid=2d9" - "48600-35d8-4490-983b-918bdce488c8" - ) - assert ( - inst.relatedArtifact[9].display == "LABEL: NITROGLYCERIN- nitroglycerin tablet" - ) - assert inst.relatedArtifact[9].type == "justification" - assert inst.relatedArtifact[9].url == ( - "https://dailymed.nlm.nih.gov/dailymed/drugInfo.cfm?setid=67b" - "f2a15-b115-47ac-ae28-ce2dafd6b5c9" - ) - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == ( - "Chest Pain (CP) - Coronary Artery Disease (CAD) Order Set " "KNART" - ) - assert inst.type.coding[0].code == "order-set" - assert inst.type.coding[0].display == "Order Set" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/plan-definition-type" - ) - assert inst.url == "http://va.gov/kas/orderset/B5-Cardiology-ChestPainCAD-OS" - assert inst.useContext[0].code.code == "focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "look up value" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].display - == "appropriate snomed condition" - ) - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "0.1" - - -def test_plandefinition_5(base_settings): - """No. 5 tests collection for PlanDefinition. - Test File: plandefinition-example-cardiology-os.json - """ - filename = ( - base_settings["unittest_data_dir"] / "plandefinition-example-cardiology-os.json" - ) - inst = plandefinition.PlanDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PlanDefinition" == inst.resource_type - - impl_plandefinition_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PlanDefinition" == data["resourceType"] - - inst2 = plandefinition.PlanDefinition(**data) - impl_plandefinition_5(inst2) - - -def impl_plandefinition_6(inst): - assert inst.action[0].cardinalityBehavior == "single" - assert inst.action[0].condition[0].expression.expression == ( - "exists ([Condition: Obesity]) or not exists ([Observation: " - "BMI] O where O.effectiveDateTime 2 years or less before " - "Today())" - ) - assert inst.action[0].condition[0].expression.language == "text/cql" - assert inst.action[0].condition[0].kind == "applicability" - assert inst.action[0].definitionCanonical == "#procedure" - assert ( - inst.action[0].description - == "Measure, Weight, Height, Waist, Circumference; Calculate BMI" - ) - assert inst.action[0].goalId[0] == "reduce-bmi-ratio" - assert inst.action[0].requiredBehavior == "must-unless-documented" - assert inst.action[0].title == "Measure BMI" - assert inst.author[0].name == "National Heart, Lung, and Blood Institute" - assert inst.author[0].telecom[0].system == "url" - assert ( - inst.author[0].telecom[0].value - == "https://www.nhlbi.nih.gov/health-pro/guidelines" - ) - assert inst.contained[0].id == "procedure" - assert inst.goal[0].addresses[0].coding[0].code == "414916001" - assert inst.goal[0].addresses[0].coding[0].display == "Obesity (disorder)" - assert inst.goal[0].addresses[0].coding[0].system == "http://snomed.info/sct" - assert inst.goal[0].category.text == "Treatment" - assert inst.goal[0].description.text == "Reduce BMI to below 25" - assert inst.goal[0].documentation[0].display == "Evaluation and Treatment Strategy" - assert inst.goal[0].documentation[0].type == "justification" - assert inst.goal[0].documentation[0].url == ( - "https://www.nhlbi.nih.gov/health-" - "pro/guidelines/current/obesity-" - "guidelines/e_textbook/txgd/42.htm" - ) - assert inst.goal[0].id == "reduce-bmi-ratio" - assert inst.goal[0].priority.text == "medium-priority" - assert inst.goal[0].start.text == "When the patient's BMI Ratio is at or above 25" - assert inst.goal[0].target[0].detailRange.high.unit == "kg/m2" - assert float(inst.goal[0].target[0].detailRange.high.value) == float(24.9) - assert inst.goal[0].target[0].due.unit == "a" - assert float(inst.goal[0].target[0].due.value) == float(1) - assert inst.goal[0].target[0].measure.coding[0].code == "39156-5" - assert ( - inst.goal[0].target[0].measure.coding[0].display - == "Body mass index (BMI) [Ratio]" - ) - assert inst.goal[0].target[0].measure.coding[0].system == "http://loinc.org" - assert inst.id == "protocol-example" - assert inst.identifier[0].system == "http://acme.org" - assert inst.identifier[0].value == "example-1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.purpose == ( - "Example of A medical algorithm for assessment and treatment " - "of overweight and obesity" - ) - assert ( - inst.relatedArtifact[0].display == "Overweight and Obesity Treatment Guidelines" - ) - assert inst.relatedArtifact[0].type == "derived-from" - assert inst.relatedArtifact[0].url == ( - "http://www.nhlbi.nih.gov/health-" - "pro/guidelines/current/obesity-" - "guidelines/e_textbook/txgd/algorthm/algorthm.htm" - ) - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "Obesity Assessment Protocol" - assert inst.type.coding[0].code == "clinical-protocol" - assert inst.useContext[0].code.code == "focus" - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "414916001" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].display - == "Obesity (disorder)" - ) - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - - -def test_plandefinition_6(base_settings): - """No. 6 tests collection for PlanDefinition. - Test File: plandefinition-protocol-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "plandefinition-protocol-example.json" - ) - inst = plandefinition.PlanDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PlanDefinition" == inst.resource_type - - impl_plandefinition_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PlanDefinition" == data["resourceType"] - - inst2 = plandefinition.PlanDefinition(**data) - impl_plandefinition_6(inst2) - - -def impl_plandefinition_7(inst): - assert ( - inst.action[0].action[0].action[0].definitionCanonical - == "#referralToMentalHealthCare" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[0].expression.expression - == "Now()" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[0].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[0].path == "timing.event" - assert inst.action[0].action[0].action[0].dynamicValue[1].expression.expression == ( - "Code '261QM0850X' from SuicideRiskLogic.\"NUCC Provider " - "Taxonomy\" display 'Adult Mental Health'" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[1].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[1].path == "specialty" - assert ( - inst.action[0].action[0].action[0].dynamicValue[2].expression.expression - == "SuicideRiskLogic.ServiceRequestFulfillmentTime" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[2].expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[2].path == "occurrenceDateTime" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[3].expression.expression - == "SuicideRiskLogic.Patient" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[3].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[3].path == "subject" - assert ( - inst.action[0].action[0].action[0].dynamicValue[4].expression.expression - == "SuicideRiskLogic.Practitioner" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[4].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[4].path == "requester.agent" - assert ( - inst.action[0].action[0].action[0].dynamicValue[5].expression.expression - == "SuicideRiskLogic.RiskAssessmentScore" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[5].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[5].path == "reasonCode" - assert ( - inst.action[0].action[0].action[0].dynamicValue[6].expression.expression - == "SuicideRiskLogic.RiskAssessment" - ) - assert ( - inst.action[0].action[0].action[0].dynamicValue[6].expression.language - == "text/cql" - ) - assert inst.action[0].action[0].action[0].dynamicValue[6].path == "reasonReference" - assert inst.action[0].action[0].action[0].textEquivalent == ( - "Refer to outpatient mental health program for evaluation and" - " treatment of mental health conditions now" - ) - assert inst.action[0].action[0].groupingBehavior == "logical-group" - assert inst.action[0].action[0].selectionBehavior == "any" - assert inst.action[0].action[0].title == "Consults and Referrals" - assert ( - inst.action[0].action[1].action[0].action[0].action[0].definitionCanonical - == "#citalopramPrescription" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .action[0] - .action[0] - .dynamicValue[0] - .expression.expression - == "'draft'" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .action[0] - .action[0] - .dynamicValue[0] - .expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[0].action[0].action[0].dynamicValue[0].path - == "status" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .action[0] - .action[0] - .dynamicValue[1] - .expression.expression - == "SuicideRiskLogic.Patient" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .action[0] - .action[0] - .dynamicValue[1] - .expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[0].action[0].action[0].dynamicValue[1].path - == "patient" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .action[0] - .action[0] - .dynamicValue[2] - .expression.expression - == "SuicideRiskLogic.Practitioner" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .action[0] - .action[0] - .dynamicValue[2] - .expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[0].action[0].action[0].dynamicValue[2].path - == "prescriber" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .action[0] - .action[0] - .dynamicValue[3] - .expression.expression - == "SuicideRiskLogic.RiskAssessmentScore" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .action[0] - .action[0] - .dynamicValue[3] - .expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[0].action[0].action[0].dynamicValue[3].path - == "reasonCode" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .action[0] - .action[0] - .dynamicValue[4] - .expression.expression - == "SuicideRiskLogic.RiskAssessment" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .action[0] - .action[0] - .dynamicValue[4] - .expression.language - == "text/cql" - ) - assert ( - inst.action[0].action[1].action[0].action[0].action[0].dynamicValue[4].path - == "reasonReference" - ) - assert inst.action[0].action[1].action[0].action[0].action[0].textEquivalent == ( - "citalopram 20 mg tablet 1 tablet oral 1 time daily now (30 " - "table; 3 refills)" - ) - assert inst.action[0].action[1].action[0].action[0].action[1].textEquivalent == ( - "escitalopram 10 mg tablet 1 tablet oral 1 time daily now (30" - " tablet; 3 refills)" - ) - assert inst.action[0].action[1].action[0].action[0].action[2].textEquivalent == ( - "fluoxetine 20 mg capsule 1 capsule oral 1 time daily now (30" - " tablet; 3 refills)" - ) - assert inst.action[0].action[1].action[0].action[0].action[3].textEquivalent == ( - "paroxetine 20 mg tablet 1 tablet oral 1 time daily now (30 " - "tablet; 3 refills)" - ) - assert inst.action[0].action[1].action[0].action[0].action[4].textEquivalent == ( - "sertraline 50 mg tablet 1 tablet oral 1 time daily now (30 " - "tablet; 3 refills)" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .action[0] - .documentation[0] - .document.contentType - == "text/html" - ) - assert inst.action[0].action[1].action[0].action[0].documentation[ - 0 - ].document.title == ( - "National Library of Medicine. DailyMed website. CITALOPRAM- " - "citalopram hydrobromide tablet, film coated." - ) - assert inst.action[0].action[1].action[0].action[0].documentation[ - 0 - ].document.url == ( - "http://dailymed.nlm.nih.gov/dailymed/drugInfo.cfm?setid=6dae" - "b45c-451d-b135-bf8f-2d6dff4b6b01" - ) - assert ( - inst.action[0].action[1].action[0].action[0].documentation[0].type == "citation" - ) - assert ( - inst.action[0].action[1].action[0].action[0].groupingBehavior == "logical-group" - ) - assert ( - inst.action[0].action[1].action[0].action[0].selectionBehavior == "at-most-one" - ) - assert inst.action[0].action[1].action[0].action[0].title == ( - "Selective Serotonin Reuptake Inhibitors (Choose a mazimum of" - " one or document reasons for exception)" - ) - assert inst.action[0].action[1].action[0].action[1].textEquivalent == ( - "Dopamine Norepinephrine Reuptake Inhibitors (Choose a " - "maximum of one or document reasons for exception)" - ) - assert inst.action[0].action[1].action[0].action[2].textEquivalent == ( - "Serotonin Norepinephrine Reuptake Inhibitors (Choose a " - "maximum of one or doument reasons for exception)" - ) - assert inst.action[0].action[1].action[0].action[3].textEquivalent == ( - "Norepinephrine-Serotonin Modulators (Choose a maximum of one" - " or document reasons for exception)" - ) - assert ( - inst.action[0].action[1].action[0].documentation[0].document.contentType - == "text/html" - ) - assert inst.action[0].action[1].action[0].documentation[0].document.extension[ - 0 - ].url == ("http://hl7.org/fhir/StructureDefinition/cqf-" "qualityOfEvidence") - assert ( - inst.action[0] - .action[1] - .action[0] - .documentation[0] - .document.extension[0] - .valueCodeableConcept.coding[0] - .code - == "high" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .documentation[0] - .document.extension[0] - .valueCodeableConcept.coding[0] - .system - == "http://terminology.hl7.org/CodeSystem/evidence-quality" - ) - assert ( - inst.action[0] - .action[1] - .action[0] - .documentation[0] - .document.extension[0] - .valueCodeableConcept.text - == "High Quality" - ) - assert inst.action[0].action[1].action[0].documentation[0].document.title == ( - "Practice Guideline for the Treatment of Patients with Major " - "Depressive Disorder" - ) - assert inst.action[0].action[1].action[0].documentation[0].document.url == ( - "http://psychiatryonline.org/pb/assets/raw/sitewide/practice_" - "guidelines/guidelines/mdd.pdf" - ) - assert inst.action[0].action[1].action[0].documentation[0].type == "citation" - assert inst.action[0].action[1].action[0].groupingBehavior == "logical-group" - assert inst.action[0].action[1].action[0].selectionBehavior == "at-most-one" - assert inst.action[0].action[1].action[0].title == "First-Line Antidepressants" - assert inst.action[0].action[1].groupingBehavior == "logical-group" - assert inst.action[0].action[1].selectionBehavior == "at-most-one" - assert inst.action[0].action[1].title == "Medications" - assert inst.action[0].title == "Suicide Risk Assessment and Outpatient Management" - assert inst.approvalDate == fhirtypes.Date.validate("2016-03-12") - assert inst.author[0].name == "Motive Medical Intelligence" - assert inst.author[0].telecom[0].system == "phone" - assert inst.author[0].telecom[0].use == "work" - assert inst.author[0].telecom[0].value == "415-362-4007" - assert inst.author[0].telecom[1].system == "email" - assert inst.author[0].telecom[1].use == "work" - assert inst.author[0].telecom[1].value == "info@motivemi.com" - assert inst.contact[0].telecom[0].system == "phone" - assert inst.contact[0].telecom[0].use == "work" - assert inst.contact[0].telecom[0].value == "415-362-4007" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].use == "work" - assert inst.contact[0].telecom[1].value == "info@motivemi.com" - assert inst.contained[0].id == "referralToMentalHealthCare" - assert inst.contained[1].id == "citalopramPrescription" - assert inst.contained[2].id == "citalopramMedication" - assert inst.contained[3].id == "citalopramSubstance" - assert inst.copyright == ( - "© Copyright 2016 Motive Medical Intelligence. All rights " "reserved." - ) - assert inst.date == fhirtypes.DateTime.validate("2015-08-15T11:15:33+10:00") - assert inst.description == ( - "Orders to be applied to a patient characterized as low " "suicide risk." - ) - assert inst.effectivePeriod.end == fhirtypes.DateTime.validate( - "2017-12-31T11:15:33+10:00" - ) - assert inst.effectivePeriod.start == fhirtypes.DateTime.validate( - "2016-01-01T11:15:33+10:00" - ) - assert inst.experimental is True - assert inst.id == "low-suicide-risk-order-set" - assert inst.identifier[0].system == "http://motivemi.com/artifacts" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "mmi:low-suicide-risk-order-set" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.lastReviewDate == fhirtypes.Date.validate("2016-08-15") - assert inst.library[0] == "Library/suiciderisk-orderset-logic" - assert inst.name == "LowSuicideRiskOrderSet" - assert inst.publisher == "Motive Medical Intelligence" - assert inst.purpose == ( - "This order set helps ensure consistent application of " - "appropriate orders for the care of low suicide risk " - "patients." - ) - assert inst.relatedArtifact[0].display == ( - "Practice Guideline for the Treatment of Patients with Major " - "Depressive Disorder" - ) - assert inst.relatedArtifact[0].type == "derived-from" - assert inst.relatedArtifact[0].url == ( - "http://psychiatryonline.org/pb/assets/raw/sitewide/practice_" - "guidelines/guidelines/mdd.pdf" - ) - assert ( - inst.relatedArtifact[1].resource - == "ActivityDefinition/referralPrimaryCareMentalHealth" - ) - assert inst.relatedArtifact[1].type == "composed-of" - assert ( - inst.relatedArtifact[2].resource == "ActivityDefinition/citalopramPrescription" - ) - assert inst.relatedArtifact[2].type == "composed-of" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Low Suicide Risk Order Set" - assert inst.topic[0].text == "Suicide risk assessment" - assert inst.url == ( - "http://motivemi.com/artifacts/PlanDefinition/low-suicide-" "risk-order-set" - ) - assert inst.usage == ( - "This order set should be applied after assessing a patient " - "for suicide risk, when the findings of that assessment " - "indicate the patient has low suicide risk." - ) - assert inst.useContext[0].code.code == "age" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "D000328" - assert inst.useContext[0].valueCodeableConcept.coding[0].display == "Adult" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "https://meshb.nlm.nih.gov" - ) - assert inst.useContext[1].code.code == "focus" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "87512008" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].display - == "Mild major depression" - ) - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[2].code.code == "focus" - assert ( - inst.useContext[2].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[2].valueCodeableConcept.coding[0].code == "40379007" - assert ( - inst.useContext[2].valueCodeableConcept.coding[0].display - == "Major depression, recurrent, mild" - ) - assert ( - inst.useContext[2].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[3].code.code == "focus" - assert ( - inst.useContext[3].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[3].valueCodeableConcept.coding[0].code == "394687007" - assert ( - inst.useContext[3].valueCodeableConcept.coding[0].display == "Low suicide risk" - ) - assert ( - inst.useContext[3].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[4].code.code == "focus" - assert ( - inst.useContext[4].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[4].valueCodeableConcept.coding[0].code == "225337009" - assert ( - inst.useContext[4].valueCodeableConcept.coding[0].display - == "Suicide risk assessment" - ) - assert ( - inst.useContext[4].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[5].code.code == "user" - assert ( - inst.useContext[5].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[5].valueCodeableConcept.coding[0].code == "309343006" - assert inst.useContext[5].valueCodeableConcept.coding[0].display == "Physician" - assert ( - inst.useContext[5].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[6].code.code == "venue" - assert ( - inst.useContext[6].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[6].valueCodeableConcept.coding[0].code == "440655000" - assert ( - inst.useContext[6].valueCodeableConcept.coding[0].display - == "Outpatient environment" - ) - assert ( - inst.useContext[6].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "1.0.0" - - -def test_plandefinition_7(base_settings): - """No. 7 tests collection for PlanDefinition. - Test File: plandefinition-example.json - """ - filename = base_settings["unittest_data_dir"] / "plandefinition-example.json" - inst = plandefinition.PlanDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PlanDefinition" == inst.resource_type - - impl_plandefinition_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PlanDefinition" == data["resourceType"] - - inst2 = plandefinition.PlanDefinition(**data) - impl_plandefinition_7(inst2) - - -def impl_plandefinition_8(inst): - assert inst.action[0].action[0].description == "Will offer Naloxone instead" - assert inst.action[0].action[1].description == ( - "Risk of overdose carefully considered and outweighed by " - "benefit; snooze 3 mo" - ) - assert inst.action[0].action[2].description == "N/A - see comment; snooze 3 mo" - assert inst.action[0].condition[0].expression.expression == "Inclusion Criteria" - assert inst.action[0].condition[0].expression.language == "text/cql" - assert inst.action[0].condition[0].kind == "applicability" - assert inst.action[0].description == ( - "Checking if the trigger prescription meets the inclusion " - "criteria for recommendation #8 workflow." - ) - assert inst.action[0].documentation[0].document.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/cqf-" "strengthOfRecommendation" - ) - assert ( - inst.action[0] - .documentation[0] - .document.extension[0] - .valueCodeableConcept.coding[0] - .code - == "strong" - ) - assert ( - inst.action[0] - .documentation[0] - .document.extension[0] - .valueCodeableConcept.coding[0] - .display - == "Strong" - ) - assert inst.action[0].documentation[0].document.extension[ - 0 - ].valueCodeableConcept.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/recommendation-" "strength" - ) - assert inst.action[0].documentation[0].document.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/cqf-" "qualityOfEvidence" - ) - assert ( - inst.action[0] - .documentation[0] - .document.extension[1] - .valueCodeableConcept.coding[0] - .code - == "low" - ) - assert ( - inst.action[0] - .documentation[0] - .document.extension[1] - .valueCodeableConcept.coding[0] - .display - == "Low quality" - ) - assert ( - inst.action[0] - .documentation[0] - .document.extension[1] - .valueCodeableConcept.coding[0] - .system - == "http://terminology.hl7.org/CodeSystem/evidence-quality" - ) - assert inst.action[0].documentation[0].type == "documentation" - assert inst.action[0].dynamicValue[0].expression.expression == "Get Detail" - assert inst.action[0].dynamicValue[0].expression.language == "text/cql" - assert inst.action[0].dynamicValue[0].path == "action.description" - assert inst.action[0].dynamicValue[1].expression.expression == "Get Summary" - assert inst.action[0].dynamicValue[1].expression.language == "text/cql" - assert inst.action[0].dynamicValue[1].path == "action.title" - assert inst.action[0].dynamicValue[2].expression.expression == "Get Indicator" - assert inst.action[0].dynamicValue[2].expression.language == "text/cql" - assert inst.action[0].dynamicValue[2].path == "action.extension" - assert inst.action[0].groupingBehavior == "visual-group" - assert inst.action[0].selectionBehavior == "exactly-one" - assert inst.action[0].title == ( - "Existing patient exhibits risk factors for opioid-related " "harms." - ) - assert inst.action[0].trigger[0].name == "medication-prescribe" - assert inst.action[0].trigger[0].type == "named-event" - assert inst.author[0].name == "Kensaku Kawamoto, MD, PhD, MHS" - assert inst.author[1].name == "Bryn Rhodes" - assert inst.author[2].name == "Floyd Eisenberg, MD, MPH" - assert inst.author[3].name == "Robert McClure, MD, MPH" - assert inst.copyright == "© CDC 2016+." - assert inst.date == fhirtypes.DateTime.validate("2018-03-19T11:15:33+10:00") - assert inst.id == "opioidcds-08" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "cdc-opioid-guidance" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.library[0] == "Library/opioidcds-recommendation-08" - assert inst.name == "cdc-opioid-08" - assert inst.publisher == "Centers for Disease Control and Prevention (CDC)" - assert ( - inst.relatedArtifact[0].display - == "CDC guideline for prescribing opioids for chronic pain" - ) - assert inst.relatedArtifact[0].type == "documentation" - assert inst.relatedArtifact[0].url == ( - "https://guidelines.gov/summaries/summary/50153/cdc-" - "guideline-for-prescribing-opioids-for-chronic-pain---united-" - "states-2016#420" - ) - assert inst.relatedArtifact[1].display == "MME Conversion Tables" - assert inst.relatedArtifact[1].type == "documentation" - assert inst.relatedArtifact[1].url == ( - "https://www.cdc.gov/drugoverdose/pdf/calculating_total_daily" "_dose-a.pdf" - ) - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "CDC Opioid Prescribing Guideline Recommendation #8" - assert inst.topic[0].text == "Opioid Prescribing" - assert inst.type.coding[0].code == "eca-rule" - assert inst.type.coding[0].display == "ECA Rule" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/plan-definition-type" - ) - assert inst.url == ( - "http://hl7.org/fhir/ig/opioid-" "cds/PlanDefinition/opioidcds-08" - ) - assert inst.usage == ( - "Before starting and periodically during continuation of " - "opioid therapy, clinicians should evaluate risk factors for " - "opioid-related harms." - ) - assert inst.useContext[0].code.code == "focus" - assert inst.useContext[0].code.display == "Clinical Focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "182888003" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].display - == "Medication requested (situation)" - ) - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[1].code.code == "focus" - assert inst.useContext[1].code.display == "Clinical Focus" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "82423001" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].display - == "Chronic pain (finding)" - ) - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "0.1.0" - - -def test_plandefinition_8(base_settings): - """No. 8 tests collection for PlanDefinition. - Test File: plandefinition-opioidcds-08.json - """ - filename = base_settings["unittest_data_dir"] / "plandefinition-opioidcds-08.json" - inst = plandefinition.PlanDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PlanDefinition" == inst.resource_type - - impl_plandefinition_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PlanDefinition" == data["resourceType"] - - inst2 = plandefinition.PlanDefinition(**data) - impl_plandefinition_8(inst2) - - -def impl_plandefinition_9(inst): - assert ( - inst.action[0].action[0].dynamicValue[0].expression.expression - == "Create Lactation Consult Request" - ) - assert inst.action[0].action[0].dynamicValue[0].expression.language == "text/cql" - assert inst.action[0].action[0].dynamicValue[0].path == "/" - assert ( - inst.action[0].action[0].textEquivalent == "Create a lactation consult request" - ) - assert inst.action[0].action[0].title == "Create a lactation consult request." - assert inst.action[0].action[0].type.coding[0].code == "create" - assert ( - inst.action[0].condition[0].expression.expression - == "Should Create Lactation Consult" - ) - assert inst.action[0].condition[0].expression.language == "text/cql" - assert inst.action[0].condition[0].kind == "applicability" - assert inst.action[0].title == ( - "Mother should be referred to a lactation specialist for " "consultation." - ) - assert inst.action[0].trigger[0].name == "Admission" - assert inst.action[0].trigger[0].type == "named-event" - assert inst.action[0].trigger[1].name == "Birth" - assert inst.action[0].trigger[1].type == "named-event" - assert inst.action[0].trigger[2].name == "Infant Transfer to Recovery" - assert inst.action[0].trigger[2].type == "named-event" - assert inst.action[0].trigger[3].name == "Transfer to Post-Partum" - assert inst.action[0].trigger[3].type == "named-event" - assert inst.date == fhirtypes.DateTime.validate("2015-03-08T11:15:33+10:00") - assert inst.description == ( - "Exclusive breastfeeding intervention intended to improve " - "outcomes for exclusive breastmilk feeding of newborns by " - "creating a lactation consult for the mother if appropriate." - ) - assert inst.id == "exclusive-breastfeeding-intervention-04" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "exclusive-breastfeeding-intervention-04" - assert inst.library[0] == "Library/library-exclusive-breastfeeding-cds-logic" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.relatedArtifact[0].resource == "Measure/measure-exclusive-breastfeeding" - assert inst.relatedArtifact[0].type == "derived-from" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "Exclusive Breastfeeding Intervention-04" - assert inst.topic[0].text == "Exclusive Breastfeeding" - assert inst.version == "1.0.0" - - -def test_plandefinition_9(base_settings): - """No. 9 tests collection for PlanDefinition. - Test File: plandefinition-exclusive-breastfeeding-intervention-04.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "plandefinition-exclusive-breastfeeding-intervention-04.json" - ) - inst = plandefinition.PlanDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PlanDefinition" == inst.resource_type - - impl_plandefinition_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PlanDefinition" == data["resourceType"] - - inst2 = plandefinition.PlanDefinition(**data) - impl_plandefinition_9(inst2) - - -def impl_plandefinition_10(inst): - assert inst.action[0].action[0].description == "Will precribe immediate release" - assert inst.action[0].action[1].description == ( - "Risk of overdose carefully considered and outweighed by " - "benefit; snooze 3 mo" - ) - assert inst.action[0].action[2].description == "N/A - see comment; snooze 3 mo" - assert inst.action[0].condition[0].expression.description == ( - "Check whether the opioid prescription for the existing " - "patient is extended-release without any opioids-with-abuse-" - "potential prescribed in the past 90 days." - ) - assert inst.action[0].condition[0].expression.expression == "Inclusion Criteria" - assert inst.action[0].condition[0].expression.language == "text/cql" - assert inst.action[0].condition[0].kind == "applicability" - assert inst.action[0].description == ( - "Checking if the trigger prescription meets the inclusion " - "criteria for recommendation #4 workflow." - ) - assert inst.action[0].documentation[0].document.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/cqf-" "strengthOfRecommendation" - ) - assert ( - inst.action[0] - .documentation[0] - .document.extension[0] - .valueCodeableConcept.coding[0] - .code - == "strong" - ) - assert ( - inst.action[0] - .documentation[0] - .document.extension[0] - .valueCodeableConcept.coding[0] - .display - == "Strong" - ) - assert inst.action[0].documentation[0].document.extension[ - 0 - ].valueCodeableConcept.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/recommendation-" "strength" - ) - assert inst.action[0].documentation[0].document.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/cqf-" "qualityOfEvidence" - ) - assert ( - inst.action[0] - .documentation[0] - .document.extension[1] - .valueCodeableConcept.coding[0] - .code - == "low" - ) - assert ( - inst.action[0] - .documentation[0] - .document.extension[1] - .valueCodeableConcept.coding[0] - .display - == "Low quality" - ) - assert ( - inst.action[0] - .documentation[0] - .document.extension[1] - .valueCodeableConcept.coding[0] - .system - == "http://terminology.hl7.org/CodeSystem/evidence-quality" - ) - assert inst.action[0].documentation[0].type == "documentation" - assert inst.action[0].dynamicValue[0].expression.expression == "Get Summary" - assert inst.action[0].dynamicValue[0].expression.language == "text/cql" - assert inst.action[0].dynamicValue[0].path == "action.title" - assert inst.action[0].dynamicValue[1].expression.expression == "Get Detail" - assert inst.action[0].dynamicValue[1].expression.language == "text/cql" - assert inst.action[0].dynamicValue[1].path == "action.description" - assert inst.action[0].dynamicValue[2].expression.expression == "Get Indicator" - assert inst.action[0].dynamicValue[2].expression.language == "text/cql" - assert inst.action[0].dynamicValue[2].path == "activity.extension" - assert inst.action[0].groupingBehavior == "visual-group" - assert inst.action[0].selectionBehavior == "exactly-one" - assert inst.action[0].title == "Extended-release opioid prescription triggered." - assert inst.action[0].trigger[0].name == "medication-prescribe" - assert inst.action[0].trigger[0].type == "named-event" - assert inst.author[0].name == "Kensaku Kawamoto, MD, PhD, MHS" - assert inst.author[1].name == "Bryn Rhodes" - assert inst.author[2].name == "Floyd Eisenberg, MD, MPH" - assert inst.author[3].name == "Robert McClure, MD, MPH" - assert inst.copyright == "© CDC 2016+." - assert inst.date == fhirtypes.DateTime.validate("2018-03-19T11:15:33+10:00") - assert inst.description == ( - "When starting opioid therapy for chronic pain, clinicians " - "should prescribe immediate-release opioids instead of " - "extended-release/long-acting (ER/LA) opioids." - ) - assert inst.id == "opioidcds-04" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "cdc-opioid-guidance" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.library[0] == "Library/opioidcds-recommendation-04" - assert inst.name == "cdc-opioid-04" - assert inst.publisher == "Centers for Disease Control and Prevention (CDC)" - assert ( - inst.relatedArtifact[0].display - == "CDC guideline for prescribing opioids for chronic pain" - ) - assert inst.relatedArtifact[0].type == "documentation" - assert inst.relatedArtifact[0].url == ( - "https://guidelines.gov/summaries/summary/50153/cdc-" - "guideline-for-prescribing-opioids-for-chronic-pain---united-" - "states-2016#420" - ) - assert inst.relatedArtifact[1].display == "MME Conversion Tables" - assert inst.relatedArtifact[1].type == "documentation" - assert inst.relatedArtifact[1].url == ( - "https://www.cdc.gov/drugoverdose/pdf/calculating_total_daily" "_dose-a.pdf" - ) - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "CDC Opioid Prescribing Guideline Recommendation #4" - assert inst.topic[0].text == "Opioid Prescribing" - assert inst.type.coding[0].code == "eca-rule" - assert inst.type.coding[0].display == "ECA Rule" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/plan-definition-type" - ) - assert inst.url == ( - "http://hl7.org/fhir/ig/opioid-" "cds/PlanDefinition/opioidcds-04" - ) - assert inst.usage == ( - "Providers should use caution when prescribing extended-" - "release/long-acting (ER/LA) opioids as they carry a higher " - "risk and negligible benefit compared to immediate-release " - "opioids." - ) - assert inst.useContext[0].code.code == "focus" - assert inst.useContext[0].code.display == "Clinical Focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "182888003" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].display - == "Medication requested (situation)" - ) - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.useContext[1].code.code == "focus" - assert inst.useContext[1].code.display == "Clinical Focus" - assert ( - inst.useContext[1].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[1].valueCodeableConcept.coding[0].code == "82423001" - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].display - == "Chronic pain (finding)" - ) - assert ( - inst.useContext[1].valueCodeableConcept.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.version == "0.1.0" - - -def test_plandefinition_10(base_settings): - """No. 10 tests collection for PlanDefinition. - Test File: plandefinition-opioidcds-04.json - """ - filename = base_settings["unittest_data_dir"] / "plandefinition-opioidcds-04.json" - inst = plandefinition.PlanDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PlanDefinition" == inst.resource_type - - impl_plandefinition_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PlanDefinition" == data["resourceType"] - - inst2 = plandefinition.PlanDefinition(**data) - impl_plandefinition_10(inst2) diff --git a/fhir/resources/tests/test_practitioner.py b/fhir/resources/tests/test_practitioner.py deleted file mode 100644 index 3021709a..00000000 --- a/fhir/resources/tests/test_practitioner.py +++ /dev/null @@ -1,518 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Practitioner -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import practitioner - - -def impl_practitioner_1(inst): - assert inst.active is True - assert inst.address[0].city == "Den helder" - assert inst.address[0].country == "NLD" - assert inst.address[0].line[0] == "Walvisbaai 3" - assert inst.address[0].postalCode == "2333ZA" - assert inst.address[0].use == "work" - assert inst.birthDate == fhirtypes.Date.validate("1983-04-20") - assert inst.gender == "male" - assert inst.id == "f203" - assert inst.identifier[0].system == "urn:oid:2.16.528.1.1007.3.1" - assert inst.identifier[0].type.text == "UZI-nummer" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345678903" - assert inst.identifier[1].system == "https://www.bigregister.nl/" - assert inst.identifier[1].type.text == "BIG-nummer" - assert inst.identifier[1].use == "official" - assert inst.identifier[1].value == "12345678903" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].text == "Juri van Gelder" - assert inst.name[0].use == "official" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "+31715269111" - assert inst.text.status == "generated" - - -def test_practitioner_1(base_settings): - """No. 1 tests collection for Practitioner. - Test File: practitioner-example-f203-jvg.json - """ - filename = base_settings["unittest_data_dir"] / "practitioner-example-f203-jvg.json" - inst = practitioner.Practitioner.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Practitioner" == inst.resource_type - - impl_practitioner_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Practitioner" == data["resourceType"] - - inst2 = practitioner.Practitioner(**data) - impl_practitioner_1(inst2) - - -def impl_practitioner_2(inst): - assert inst.active is True - assert inst.address[0].city == "Den helder" - assert inst.address[0].country == "NLD" - assert inst.address[0].line[0] == "Walvisbaai 3" - assert inst.address[0].line[1] == "C4 - Automatisering" - assert inst.address[0].postalCode == "2333ZA" - assert inst.address[0].use == "work" - assert inst.birthDate == fhirtypes.Date.validate("1956-12-24") - assert inst.gender == "male" - assert inst.id == "f201" - assert inst.identifier[0].system == "urn:oid:2.16.528.1.1007.3.1" - assert inst.identifier[0].type.text == "UZI-nummer" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345678901" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Bronsig" - assert inst.name[0].given[0] == "Arend" - assert inst.name[0].prefix[0] == "Dr." - assert inst.name[0].text == "Dokter Bronsig" - assert inst.name[0].use == "official" - assert inst.qualification[0].code.coding[0].code == "41672002" - assert inst.qualification[0].code.coding[0].display == "Pulmonologist" - assert inst.qualification[0].code.coding[0].system == "http://snomed.info/sct" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "+31715269111" - assert inst.text.status == "generated" - - -def test_practitioner_2(base_settings): - """No. 2 tests collection for Practitioner. - Test File: practitioner-example-f201-ab.json - """ - filename = base_settings["unittest_data_dir"] / "practitioner-example-f201-ab.json" - inst = practitioner.Practitioner.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Practitioner" == inst.resource_type - - impl_practitioner_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Practitioner" == data["resourceType"] - - inst2 = practitioner.Practitioner(**data) - impl_practitioner_2(inst2) - - -def impl_practitioner_3(inst): - assert inst.active is True - assert inst.address[0].city == "Den helder" - assert inst.address[0].country == "NLD" - assert inst.address[0].line[0] == "Walvisbaai 3" - assert inst.address[0].line[1] == "C4 - Automatisering" - assert inst.address[0].postalCode == "2333ZA" - assert inst.address[0].use == "work" - assert inst.birthDate == fhirtypes.Date.validate("1960-06-12") - assert inst.gender == "male" - assert inst.id == "f202" - assert inst.identifier[0].system == "urn:oid:2.16.528.1.1007.3.1" - assert inst.identifier[0].type.text == "UZI-nummer" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345678902" - assert inst.identifier[1].system == "https://www.bigregister.nl/" - assert inst.identifier[1].type.text == "BIG-nummer" - assert inst.identifier[1].use == "official" - assert inst.identifier[1].value == "12345678902" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Maas" - assert inst.name[0].given[0] == "Luigi" - assert inst.name[0].prefix[0] == "Dr." - assert inst.name[0].text == "Luigi Maas" - assert inst.name[0].use == "official" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "+31715269111" - assert inst.text.status == "generated" - - -def test_practitioner_3(base_settings): - """No. 3 tests collection for Practitioner. - Test File: practitioner-example-f202-lm.json - """ - filename = base_settings["unittest_data_dir"] / "practitioner-example-f202-lm.json" - inst = practitioner.Practitioner.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Practitioner" == inst.resource_type - - impl_practitioner_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Practitioner" == data["resourceType"] - - inst2 = practitioner.Practitioner(**data) - impl_practitioner_3(inst2) - - -def impl_practitioner_4(inst): - assert inst.id == "xcda-author" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Hippocrates" - assert inst.name[0].given[0] == "Harold" - assert inst.name[0].suffix[0] == "MD" - assert inst.text.status == "generated" - - -def test_practitioner_4(base_settings): - """No. 4 tests collection for Practitioner. - Test File: practitioner-example-xcda-author.json - """ - filename = ( - base_settings["unittest_data_dir"] / "practitioner-example-xcda-author.json" - ) - inst = practitioner.Practitioner.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Practitioner" == inst.resource_type - - impl_practitioner_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Practitioner" == data["resourceType"] - - inst2 = practitioner.Practitioner(**data) - impl_practitioner_4(inst2) - - -def impl_practitioner_5(inst): - assert inst.address[0].city == "Amsterdam" - assert inst.address[0].country == "NLD" - assert inst.address[0].line[0] == "Galapagosweg 91" - assert inst.address[0].postalCode == "1105 AZ" - assert inst.address[0].use == "work" - assert inst.birthDate == fhirtypes.Date.validate("1963-07-01") - assert inst.communication[0].coding[0].code == "nl" - assert inst.communication[0].coding[0].display == "Dutch" - assert inst.communication[0].coding[0].system == "urn:ietf:bcp:47" - assert inst.gender == "male" - assert inst.id == "f003" - assert inst.identifier[0].system == "urn:oid:2.16.528.1.1007.3.1" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "846100293" - assert inst.identifier[1].system == "urn:oid:2.16.840.1.113883.2.4.6.3" - assert inst.identifier[1].use == "usual" - assert inst.identifier[1].value == "243HID3RT938" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Versteegh" - assert inst.name[0].given[0] == "Marc" - assert inst.name[0].suffix[0] == "MD" - assert inst.name[0].use == "official" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "0205562431" - assert inst.telecom[1].system == "email" - assert inst.telecom[1].use == "work" - assert inst.telecom[1].value == "m.versteegh@bmc.nl" - assert inst.telecom[2].system == "fax" - assert inst.telecom[2].use == "work" - assert inst.telecom[2].value == "0205662948" - assert inst.text.status == "generated" - - -def test_practitioner_5(base_settings): - """No. 5 tests collection for Practitioner. - Test File: practitioner-example-f003-mv.json - """ - filename = base_settings["unittest_data_dir"] / "practitioner-example-f003-mv.json" - inst = practitioner.Practitioner.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Practitioner" == inst.resource_type - - impl_practitioner_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Practitioner" == data["resourceType"] - - inst2 = practitioner.Practitioner(**data) - impl_practitioner_5(inst2) - - -def impl_practitioner_6(inst): - assert inst.address[0].city == "Den Burg" - assert inst.address[0].country == "NLD" - assert inst.address[0].line[0] == "Galapagosweg 91" - assert inst.address[0].postalCode == "9105 PZ" - assert inst.address[0].use == "work" - assert inst.birthDate == fhirtypes.Date.validate("1979-04-29") - assert inst.gender == "male" - assert inst.id == "f002" - assert inst.identifier[0].system == "urn:oid:2.16.528.1.1007.3.1" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "730291637" - assert inst.identifier[1].system == "urn:oid:2.16.840.1.113883.2.4.6.3" - assert inst.identifier[1].use == "usual" - assert inst.identifier[1].value == "174BIP3JH438" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Voigt" - assert inst.name[0].given[0] == "Pieter" - assert inst.name[0].suffix[0] == "MD" - assert inst.name[0].use == "official" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "0205569336" - assert inst.telecom[1].system == "email" - assert inst.telecom[1].use == "work" - assert inst.telecom[1].value == "p.voigt@bmc.nl" - assert inst.telecom[2].system == "fax" - assert inst.telecom[2].use == "work" - assert inst.telecom[2].value == "0205669382" - assert inst.text.status == "generated" - - -def test_practitioner_6(base_settings): - """No. 6 tests collection for Practitioner. - Test File: practitioner-example-f002-pv.json - """ - filename = base_settings["unittest_data_dir"] / "practitioner-example-f002-pv.json" - inst = practitioner.Practitioner.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Practitioner" == inst.resource_type - - impl_practitioner_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Practitioner" == data["resourceType"] - - inst2 = practitioner.Practitioner(**data) - impl_practitioner_6(inst2) - - -def impl_practitioner_7(inst): - assert inst.active is True - assert inst.address[0].city == "PleasantVille" - assert inst.address[0].line[0] == "534 Erewhon St" - assert inst.address[0].postalCode == "3999" - assert inst.address[0].state == "Vic" - assert inst.address[0].use == "home" - assert inst.id == "example" - assert inst.identifier[0].system == "http://www.acme.org/practitioners" - assert inst.identifier[0].value == "23" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Careful" - assert inst.name[0].given[0] == "Adam" - assert inst.name[0].prefix[0] == "Dr" - assert inst.qualification[0].code.coding[0].code == "BS" - assert inst.qualification[0].code.coding[0].display == "Bachelor of Science" - assert ( - inst.qualification[0].code.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0360/2.7" - ) - assert inst.qualification[0].code.text == "Bachelor of Science" - assert ( - inst.qualification[0].identifier[0].system - == "http://example.org/UniversityIdentifier" - ) - assert inst.qualification[0].identifier[0].value == "12345" - assert inst.qualification[0].issuer.display == "Example University" - assert inst.qualification[0].period.start == fhirtypes.DateTime.validate("1995") - assert inst.text.status == "generated" - - -def test_practitioner_7(base_settings): - """No. 7 tests collection for Practitioner. - Test File: practitioner-example.json - """ - filename = base_settings["unittest_data_dir"] / "practitioner-example.json" - inst = practitioner.Practitioner.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Practitioner" == inst.resource_type - - impl_practitioner_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Practitioner" == data["resourceType"] - - inst2 = practitioner.Practitioner(**data) - impl_practitioner_7(inst2) - - -def impl_practitioner_8(inst): - assert inst.address[0].city == "Den Burg" - assert inst.address[0].country == "NLD" - assert inst.address[0].line[0] == "Galapagosweg 91" - assert inst.address[0].postalCode == "9105 PZ" - assert inst.address[0].use == "work" - assert inst.birthDate == fhirtypes.Date.validate("1971-11-07") - assert inst.gender == "female" - assert inst.id == "f007" - assert inst.identifier[0].system == "urn:oid:2.16.528.1.1007.3.1" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "874635264" - assert inst.identifier[1].system == "urn:oid:2.16.840.1.113883.2.4.6.3" - assert inst.identifier[1].use == "usual" - assert inst.identifier[1].value == "567IUI51C154" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Heps" - assert inst.name[0].given[0] == "Simone" - assert inst.name[0].suffix[0] == "MD" - assert inst.name[0].use == "official" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "020556936" - assert inst.telecom[1].system == "email" - assert inst.telecom[1].use == "work" - assert inst.telecom[1].value == "S.M.Heps@bmc.nl" - assert inst.telecom[2].system == "fax" - assert inst.telecom[2].use == "work" - assert inst.telecom[2].value == "0205669283" - assert inst.text.status == "generated" - - -def test_practitioner_8(base_settings): - """No. 8 tests collection for Practitioner. - Test File: practitioner-example-f007-sh.json - """ - filename = base_settings["unittest_data_dir"] / "practitioner-example-f007-sh.json" - inst = practitioner.Practitioner.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Practitioner" == inst.resource_type - - impl_practitioner_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Practitioner" == data["resourceType"] - - inst2 = practitioner.Practitioner(**data) - impl_practitioner_8(inst2) - - -def impl_practitioner_9(inst): - assert inst.address[0].city == "Den helder" - assert inst.address[0].country == "NLD" - assert inst.address[0].line[0] == "Walvisbaai 3" - assert inst.address[0].postalCode == "2333ZA" - assert inst.address[0].use == "work" - assert inst.birthDate == fhirtypes.Date.validate("1967-11-05") - assert inst.gender == "female" - assert inst.id == "f204" - assert inst.identifier[0].system == "urn:oid:2.16.528.1.1007.3.1" - assert inst.identifier[0].type.text == "UZI-nummer" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "12345678904" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].text == "Carla Espinosa" - assert inst.name[0].use == "usual" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "+31715262169" - assert inst.text.status == "generated" - - -def test_practitioner_9(base_settings): - """No. 9 tests collection for Practitioner. - Test File: practitioner-example-f204-ce.json - """ - filename = base_settings["unittest_data_dir"] / "practitioner-example-f204-ce.json" - inst = practitioner.Practitioner.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Practitioner" == inst.resource_type - - impl_practitioner_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Practitioner" == data["resourceType"] - - inst2 = practitioner.Practitioner(**data) - impl_practitioner_9(inst2) - - -def impl_practitioner_10(inst): - assert inst.id == "xcda1" - assert ( - inst.identifier[0].system == "http://healthcare.example.org/identifiers/staff" - ) - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "D234123" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Dopplemeyer" - assert inst.name[0].given[0] == "Sherry" - assert inst.telecom[0].system == "email" - assert inst.telecom[0].value == "john.doe@healthcare.example.org" - assert inst.text.status == "generated" - - -def test_practitioner_10(base_settings): - """No. 10 tests collection for Practitioner. - Test File: practitioner-example-xcda1.json - """ - filename = base_settings["unittest_data_dir"] / "practitioner-example-xcda1.json" - inst = practitioner.Practitioner.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Practitioner" == inst.resource_type - - impl_practitioner_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Practitioner" == data["resourceType"] - - inst2 = practitioner.Practitioner(**data) - impl_practitioner_10(inst2) diff --git a/fhir/resources/tests/test_practitionerrole.py b/fhir/resources/tests/test_practitionerrole.py deleted file mode 100644 index 8a29c41a..00000000 --- a/fhir/resources/tests/test_practitionerrole.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/PractitionerRole -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import practitionerrole - - -def impl_practitionerrole_1(inst): - assert inst.active is True - assert inst.availabilityExceptions == ( - "Adam is generally unavailable on public holidays and during " - "the Christmas/New Year break" - ) - assert inst.availableTime[0].availableEndTime == fhirtypes.Time.validate("16:30:00") - assert inst.availableTime[0].availableStartTime == fhirtypes.Time.validate( - "09:00:00" - ) - assert inst.availableTime[0].daysOfWeek[0] == "mon" - assert inst.availableTime[0].daysOfWeek[1] == "tue" - assert inst.availableTime[0].daysOfWeek[2] == "wed" - assert inst.availableTime[1].availableEndTime == fhirtypes.Time.validate("12:00:00") - assert inst.availableTime[1].availableStartTime == fhirtypes.Time.validate( - "09:00:00" - ) - assert inst.availableTime[1].daysOfWeek[0] == "thu" - assert inst.availableTime[1].daysOfWeek[1] == "fri" - assert inst.code[0].coding[0].code == "RP" - assert ( - inst.code[0].coding[0].system == "http://terminology.hl7.org/CodeSystem/v2-0286" - ) - assert inst.endpoint[0].reference == "Endpoint/example" - assert inst.healthcareService[0].reference == "HealthcareService/example" - assert inst.id == "example" - assert inst.identifier[0].system == "http://www.acme.org/practitioners" - assert inst.identifier[0].value == "23" - assert inst.location[0].display == "South Wing, second floor" - assert inst.location[0].reference == "Location/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert ( - inst.notAvailable[0].description - == "Adam will be on extended leave during May 2017" - ) - assert inst.notAvailable[0].during.end == fhirtypes.DateTime.validate( - "2017-05-20T11:15:33+10:00" - ) - assert inst.notAvailable[0].during.start == fhirtypes.DateTime.validate( - "2017-05-01T11:15:33+10:00" - ) - assert inst.organization.reference == "Organization/f001" - assert inst.period.end == fhirtypes.DateTime.validate("2012-03-31T11:15:33+10:00") - assert inst.period.start == fhirtypes.DateTime.validate("2012-01-01T11:15:33+10:00") - assert inst.practitioner.display == "Dr Adam Careful" - assert inst.practitioner.reference == "Practitioner/example" - assert inst.specialty[0].coding[0].code == "408443003" - assert inst.specialty[0].coding[0].display == "General medical practice" - assert inst.specialty[0].coding[0].system == "http://snomed.info/sct" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "(03) 5555 6473" - assert inst.telecom[1].system == "email" - assert inst.telecom[1].use == "work" - assert inst.telecom[1].value == "adam.southern@example.org" - assert inst.text.status == "generated" - - -def test_practitionerrole_1(base_settings): - """No. 1 tests collection for PractitionerRole. - Test File: practitionerrole-example.json - """ - filename = base_settings["unittest_data_dir"] / "practitionerrole-example.json" - inst = practitionerrole.PractitionerRole.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "PractitionerRole" == inst.resource_type - - impl_practitionerrole_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "PractitionerRole" == data["resourceType"] - - inst2 = practitionerrole.PractitionerRole(**data) - impl_practitionerrole_1(inst2) diff --git a/fhir/resources/tests/test_procedure.py b/fhir/resources/tests/test_procedure.py deleted file mode 100644 index 72a44ba6..00000000 --- a/fhir/resources/tests/test_procedure.py +++ /dev/null @@ -1,590 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Procedure -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import procedure - - -def impl_procedure_1(inst): - assert inst.bodySite[0].coding[0].code == "272676008" - assert inst.bodySite[0].coding[0].display == "Sphenoid bone" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.code.coding[0].code == "367336001" - assert inst.code.coding[0].display == "Chemotherapy" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.encounter.display == "Roel's encounter on January 28th, 2013" - assert inst.encounter.reference == "Encounter/f202" - assert inst.id == "f201" - assert inst.instantiatesCanonical[0] == "PlanDefinition/KDN5" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == ( - "Eerste neo-adjuvante TPF-kuur bij groot proces in sphenoid " - "met intracraniale uitbreiding." - ) - assert inst.performedPeriod.end == fhirtypes.DateTime.validate( - "2013-01-28T14:27:00+01:00" - ) - assert inst.performedPeriod.start == fhirtypes.DateTime.validate( - "2013-01-28T13:31:00+01:00" - ) - assert inst.performer[0].actor.display == "Dokter Bronsig" - assert inst.performer[0].actor.reference == "Practitioner/f201" - assert inst.performer[0].function.coding[0].code == "310512001" - assert inst.performer[0].function.coding[0].display == "Medical oncologist" - assert inst.performer[0].function.coding[0].system == "http://snomed.info/sct" - assert inst.reasonCode[0].text == "DiagnosticReport/f201" - assert inst.status == "completed" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - - -def test_procedure_1(base_settings): - """No. 1 tests collection for Procedure. - Test File: procedure-example-f201-tpf.json - """ - filename = base_settings["unittest_data_dir"] / "procedure-example-f201-tpf.json" - inst = procedure.Procedure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Procedure" == inst.resource_type - - impl_procedure_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Procedure" == data["resourceType"] - - inst2 = procedure.Procedure(**data) - impl_procedure_1(inst2) - - -def impl_procedure_2(inst): - assert inst.basedOn[0].display == "Maternity care plan" - assert inst.basedOn[0].reference == "CarePlan/preg" - assert inst.code.coding[0].code == "62013009" - assert inst.code.coding[0].display == "Ambulating patient (procedure)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Ambulation" - assert inst.id == "ambulation" - assert inst.identifier[0].value == "12345" - assert inst.instantiatesUri[0] == ( - "http://example.org/protocol-for-hypertension-during-" "pregnancy" - ) - assert ( - inst.location.display - == "Burgers University Medical Center, South Wing, second floor" - ) - assert inst.location.reference == "Location/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.display == "Carla Espinosa" - assert inst.performer[0].actor.reference == "Practitioner/f204" - assert inst.performer[0].onBehalfOf.display == "University Medical Hospital" - assert inst.performer[0].onBehalfOf.reference == "Organization/f001" - assert inst.reasonReference[0].display == "Blood Pressure" - assert inst.reasonReference[0].reference == "Observation/blood-pressure" - assert inst.status == "not-done" - assert inst.statusReason.coding[0].code == "398254007" - assert inst.statusReason.coding[0].display == " Pre-eclampsia (disorder)" - assert inst.statusReason.coding[0].system == "http://snomed.info/sct" - assert inst.statusReason.text == "Pre-eclampsia" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Ambulation ' - "procedure was not done
" - ) - assert inst.text.status == "generated" - - -def test_procedure_2(base_settings): - """No. 2 tests collection for Procedure. - Test File: procedure-example-ambulation.json - """ - filename = base_settings["unittest_data_dir"] / "procedure-example-ambulation.json" - inst = procedure.Procedure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Procedure" == inst.resource_type - - impl_procedure_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Procedure" == data["resourceType"] - - inst2 = procedure.Procedure(**data) - impl_procedure_2(inst2) - - -def impl_procedure_3(inst): - assert inst.code.coding[0].code == "25267002" - assert ( - inst.code.coding[0].display == "Insertion of intracardiac pacemaker (procedure)" - ) - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Implant Pacemaker" - assert inst.focalDevice[0].action.coding[0].code == "implanted" - assert ( - inst.focalDevice[0].action.coding[0].system - == "http://hl7.org/fhir/device-action" - ) - assert inst.focalDevice[0].manipulated.reference == "Device/example-pacemaker" - assert inst.followUp[0].text == "ROS 5 days - 2013-04-10" - assert inst.id == "example-implant" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == ( - "Routine Appendectomy. Appendix was inflamed and in retro-" "caecal position" - ) - assert inst.performedDateTime == fhirtypes.DateTime.validate( - "2015-04-05T11:15:33+10:00" - ) - assert inst.performer[0].actor.display == "Dr Cecil Surgeon" - assert inst.performer[0].actor.reference == "Practitioner/example" - assert inst.reasonCode[0].text == "Bradycardia" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_procedure_3(base_settings): - """No. 3 tests collection for Procedure. - Test File: procedure-example-implant.json - """ - filename = base_settings["unittest_data_dir"] / "procedure-example-implant.json" - inst = procedure.Procedure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Procedure" == inst.resource_type - - impl_procedure_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Procedure" == data["resourceType"] - - inst2 = procedure.Procedure(**data) - impl_procedure_3(inst2) - - -def impl_procedure_4(inst): - assert inst.code.coding[0].code == "76164006" - assert inst.code.coding[0].display == "Biopsy of colon (procedure)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Biopsy of colon" - assert inst.id == "colon-biopsy" - assert inst.identifier[0].value == "12345" - assert ( - inst.location.display - == "Burgers University Medical Center, South Wing, second floor" - ) - assert inst.location.reference == "Location/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.partOf[0].display == "Colonoscopy" - assert inst.partOf[0].reference == "Procedure/colonoscopy" - assert inst.performer[0].actor.display == "Dr Adam Careful" - assert inst.performer[0].actor.reference == "Practitioner/example" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Biopsy of colon,' - " which was part of colonoscopy
" - ) - assert inst.text.status == "generated" - - -def test_procedure_4(base_settings): - """No. 4 tests collection for Procedure. - Test File: procedure-example-colon-biopsy.json - """ - filename = ( - base_settings["unittest_data_dir"] / "procedure-example-colon-biopsy.json" - ) - inst = procedure.Procedure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Procedure" == inst.resource_type - - impl_procedure_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Procedure" == data["resourceType"] - - inst2 = procedure.Procedure(**data) - impl_procedure_4(inst2) - - -def impl_procedure_5(inst): - assert inst.bodySite[0].coding[0].code == "83030008" - assert inst.bodySite[0].coding[0].display == "Retropharyngeal area" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.code.coding[0].code == "48387007" - assert inst.code.coding[0].display == "Tracheotomy" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.encounter.reference == "Encounter/f003" - assert inst.followUp[0].text == "described in care plan" - assert inst.id == "f004" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome.text == "removal of the retropharyngeal abscess" - assert inst.performedPeriod.end == fhirtypes.DateTime.validate( - "2013-03-22T10:30:10+01:00" - ) - assert inst.performedPeriod.start == fhirtypes.DateTime.validate( - "2013-03-22T09:30:10+01:00" - ) - assert inst.performer[0].actor.display == "A. Langeveld" - assert inst.performer[0].actor.reference == "Practitioner/f005" - assert inst.performer[0].function.coding[0].code == "01.000" - assert inst.performer[0].function.coding[0].display == "Arts" - assert ( - inst.performer[0].function.coding[0].system - == "urn:oid:2.16.840.1.113883.2.4.15.111" - ) - assert inst.performer[0].function.text == "Care role" - assert inst.reasonCode[0].text == "ensure breathing during surgery" - assert inst.report[0].display == "???????????" - assert inst.report[0].reference == "DiagnosticReport/f001" - assert inst.status == "completed" - assert inst.subject.display == "P. van de Heuvel" - assert inst.subject.reference == "Patient/f001" - assert inst.text.status == "generated" - - -def test_procedure_5(base_settings): - """No. 5 tests collection for Procedure. - Test File: procedure-example-f004-tracheotomy.json - """ - filename = ( - base_settings["unittest_data_dir"] / "procedure-example-f004-tracheotomy.json" - ) - inst = procedure.Procedure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Procedure" == inst.resource_type - - impl_procedure_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Procedure" == data["resourceType"] - - inst2 = procedure.Procedure(**data) - impl_procedure_5(inst2) - - -def impl_procedure_6(inst): - assert inst.basedOn[0].display == "Order for health education" - assert inst.basedOn[0].reference == "ServiceRequest/education" - assert inst.category.coding[0].code == "311401005" - assert inst.category.coding[0].display == "Patient education (procedure)" - assert inst.category.coding[0].system == "http://snomed.info/sct" - assert inst.category.text == "Education" - assert inst.code.coding[0].code == "48023004" - assert ( - inst.code.coding[0].display - == "Breast self-examination technique education (procedure)" - ) - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Health education - breast examination" - assert inst.id == "education" - assert inst.location.display == "Southside Community Health Center" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performedDateTime == fhirtypes.DateTime.validate( - "2014-08-16T11:15:33+10:00" - ) - assert inst.performer[0].actor.display == "Pamela Educator, RN" - assert inst.reasonCode[0].text == "early detection of breast mass" - assert inst.status == "completed" - assert inst.subject.display == "Jane Doe" - assert inst.text.div == ( - '
Health education' - " - breast examination for early detection of breast " - "mass
" - ) - assert inst.text.status == "generated" - - -def test_procedure_6(base_settings): - """No. 6 tests collection for Procedure. - Test File: procedure-example-education.json - """ - filename = base_settings["unittest_data_dir"] / "procedure-example-education.json" - inst = procedure.Procedure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Procedure" == inst.resource_type - - impl_procedure_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Procedure" == data["resourceType"] - - inst2 = procedure.Procedure(**data) - impl_procedure_6(inst2) - - -def impl_procedure_7(inst): - assert inst.code.coding[0].code == "73761001" - assert inst.code.coding[0].display == "Colonoscopy (procedure)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Colonoscopy" - assert inst.complicationDetail[0].display == "Perforated intestine condition" - assert inst.id == "colonoscopy" - assert inst.identifier[0].value == "12345" - assert ( - inst.location.display - == "Burgers University Medical Center, South Wing, second floor" - ) - assert inst.location.reference == "Location/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].actor.display == "Dr Adam Careful" - assert inst.performer[0].actor.reference == "Practitioner/example" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Colonoscopy with' - " complication
" - ) - assert inst.text.status == "generated" - assert inst.usedReference[0].display == "Colonoscope device" - - -def test_procedure_7(base_settings): - """No. 7 tests collection for Procedure. - Test File: procedure-example-colonoscopy.json - """ - filename = base_settings["unittest_data_dir"] / "procedure-example-colonoscopy.json" - inst = procedure.Procedure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Procedure" == inst.resource_type - - impl_procedure_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Procedure" == data["resourceType"] - - inst2 = procedure.Procedure(**data) - impl_procedure_7(inst2) - - -def impl_procedure_8(inst): - assert ( - inst.basedOn[0].display == "Order for the assessment of passive range of motion" - ) - assert inst.basedOn[0].reference == "ServiceRequest/physical-therapy" - assert inst.bodySite[0].coding[0].code == "36701003" - assert inst.bodySite[0].coding[0].display == "Both knees (body structure)" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.bodySite[0].text == "Both knees" - assert inst.category.coding[0].code == "386053000" - assert inst.category.coding[0].display == "Evaluation procedure (procedure)" - assert inst.category.coding[0].system == "http://snomed.info/sct" - assert inst.category.text == "Evaluation" - assert inst.code.coding[0].code == "710830005" - assert ( - inst.code.coding[0].display - == "Assessment of passive range of motion (procedure)" - ) - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Assessment of passive range of motion" - assert inst.id == "physical-therapy" - assert inst.location.display == "Sawbones Orthopedic Clinic" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performedDateTime == fhirtypes.DateTime.validate( - "2016-09-27T11:15:33+10:00" - ) - assert inst.performer[0].actor.display == "Paul Therapist, PT" - assert ( - inst.reasonCode[0].text - == "assessment of mobility limitations due to osteoarthritis" - ) - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Assessment of ' - "passive range of motion for both knees on Sept 27, 2016 due " - "to osteoarthritis
" - ) - assert inst.text.status == "generated" - - -def test_procedure_8(base_settings): - """No. 8 tests collection for Procedure. - Test File: procedure-example-physical-therapy.json - """ - filename = ( - base_settings["unittest_data_dir"] / "procedure-example-physical-therapy.json" - ) - inst = procedure.Procedure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Procedure" == inst.resource_type - - impl_procedure_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Procedure" == data["resourceType"] - - inst2 = procedure.Procedure(**data) - impl_procedure_8(inst2) - - -def impl_procedure_9(inst): - assert inst.bodySite[0].coding[0].code == "83030008" - assert inst.bodySite[0].coding[0].display == "Retropharyngeal area" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.code.coding[0].code == "172960003" - assert inst.code.coding[0].display == "Incision of retropharyngeal abscess" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.encounter.reference == "Encounter/f003" - assert inst.followUp[0].text == "described in care plan" - assert inst.id == "f003" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome.text == "removal of the retropharyngeal abscess" - assert inst.performedPeriod.end == fhirtypes.DateTime.validate( - "2013-03-24T10:30:10+01:00" - ) - assert inst.performedPeriod.start == fhirtypes.DateTime.validate( - "2013-03-24T09:30:10+01:00" - ) - assert inst.performer[0].actor.display == "E.M.J.M. van den broek" - assert inst.performer[0].actor.reference == "Practitioner/f001" - assert inst.performer[0].function.coding[0].code == "01.000" - assert inst.performer[0].function.coding[0].display == "Arts" - assert ( - inst.performer[0].function.coding[0].system - == "urn:oid:2.16.840.1.113883.2.4.15.111" - ) - assert inst.performer[0].function.text == "Care role" - assert inst.reasonCode[0].text == "abcess in retropharyngeal area" - assert inst.report[0].display == "Lab results blood test" - assert inst.report[0].reference == "DiagnosticReport/f001" - assert inst.status == "completed" - assert inst.subject.display == "P. van de Heuvel" - assert inst.subject.reference == "Patient/f001" - assert inst.text.status == "generated" - - -def test_procedure_9(base_settings): - """No. 9 tests collection for Procedure. - Test File: procedure-example-f003-abscess.json - """ - filename = ( - base_settings["unittest_data_dir"] / "procedure-example-f003-abscess.json" - ) - inst = procedure.Procedure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Procedure" == inst.resource_type - - impl_procedure_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Procedure" == data["resourceType"] - - inst2 = procedure.Procedure(**data) - impl_procedure_9(inst2) - - -def impl_procedure_10(inst): - assert inst.asserter.display == "Dr Cecil Surgeon" - assert inst.asserter.reference == "Practitioner/example" - assert inst.code.coding[0].code == "80146002" - assert inst.code.coding[0].display == "Appendectomy (Procedure)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Appendectomy" - assert inst.followUp[0].text == "ROS 5 days - 2013-04-10" - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == ( - "Routine Appendectomy. Appendix was inflamed and in retro-" "caecal position" - ) - assert inst.performedDateTime == fhirtypes.DateTime.validate( - "2013-04-05T11:15:33+10:00" - ) - assert inst.performer[0].actor.display == "Dr Cecil Surgeon" - assert inst.performer[0].actor.reference == "Practitioner/example" - assert inst.reasonCode[0].text == ( - "Generalized abdominal pain 24 hours. Localized in RIF with " - "rebound and guarding" - ) - assert inst.recorder.display == "Dr Cecil Surgeon" - assert inst.recorder.reference == "Practitioner/example" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Routine ' "Appendectomy
" - ) - assert inst.text.status == "generated" - - -def test_procedure_10(base_settings): - """No. 10 tests collection for Procedure. - Test File: procedure-example.json - """ - filename = base_settings["unittest_data_dir"] / "procedure-example.json" - inst = procedure.Procedure.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Procedure" == inst.resource_type - - impl_procedure_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Procedure" == data["resourceType"] - - inst2 = procedure.Procedure(**data) - impl_procedure_10(inst2) diff --git a/fhir/resources/tests/test_provenance.py b/fhir/resources/tests/test_provenance.py deleted file mode 100644 index cd54da43..00000000 --- a/fhir/resources/tests/test_provenance.py +++ /dev/null @@ -1,295 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Provenance -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import provenance - - -def impl_provenance_1(inst): - assert inst.activity.coding[0].code == "AU" - assert inst.activity.coding[0].display == "authenticated" - assert ( - inst.activity.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-DocumentCompletion" - ) - assert inst.agent[0].type.coding[0].code == "VERF" - assert inst.agent[0].type.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/contractsignertypecode" "s" - ) - assert inst.agent[0].who.identifier.system == "urn:ietf:rfc:3986" - assert inst.agent[0].who.identifier.value == "mailto:hhd@ssa.gov" - assert inst.id == "signature" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.reason[0].coding[0].code == "TREAT" - assert inst.reason[0].coding[0].display == "treatment" - assert ( - inst.reason[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.recorded == fhirtypes.Instant.validate("2015-08-27T08:39:24+10:00") - assert inst.signature[0].data == bytes_validator("Li4u") - assert inst.signature[0].sigFormat == "application/signature+xml" - assert inst.signature[0].targetFormat == "application/fhir+xml" - assert inst.signature[0].type[0].code == "1.2.840.10065.1.12.1.5" - assert inst.signature[0].type[0].display == "Verification Signature" - assert inst.signature[0].type[0].system == "urn:iso-astm:E1762-95:2013" - assert inst.signature[0].when == fhirtypes.Instant.validate( - "2015-08-27T08:39:24+10:00" - ) - assert inst.signature[0].who.reference == "Practitioner/xcda-author" - assert inst.target[0].reference == "DocumentReference/example" - assert inst.text.div == ( - '
procedure record' - " authored on 27-June 2015 by Harold Hippocrates, MD Content " - "extracted from Referral received 26-June
" - ) - assert inst.text.status == "generated" - - -def test_provenance_1(base_settings): - """No. 1 tests collection for Provenance. - Test File: provenance-example-sig.json - """ - filename = base_settings["unittest_data_dir"] / "provenance-example-sig.json" - inst = provenance.Provenance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Provenance" == inst.resource_type - - impl_provenance_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Provenance" == data["resourceType"] - - inst2 = provenance.Provenance(**data) - impl_provenance_1(inst2) - - -def impl_provenance_2(inst): - assert inst.agent[0].role[0].coding[0].code == "AUT" - assert ( - inst.agent[0].role[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.agent[0].who.reference == "Patient/72" - assert inst.id == "consent-signature" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.recorded == fhirtypes.Instant.validate("2016-05-26T00:41:10-04:00") - assert inst.signature[0].data == bytes_validator("dGhpcyBibG9iIGlzIHNuaXBwZWQ=") - assert inst.signature[0].sigFormat == "application/signature+xml" - assert inst.signature[0].targetFormat == "application/fhir+xml" - assert inst.signature[0].type[0].code == "1.2.840.10065.1.12.1.1" - assert inst.signature[0].type[0].display == "Author's Signature" - assert inst.signature[0].type[0].system == "urn:iso-astm:E1762-95:2013" - assert inst.signature[0].when == fhirtypes.Instant.validate( - "2016-05-26T00:41:10-04:00" - ) - assert inst.signature[0].who.reference == "Patient/72" - assert inst.target[0].reference == "Consent/consent-example-signature" - assert inst.text.status == "generated" - - -def test_provenance_2(base_settings): - """No. 2 tests collection for Provenance. - Test File: provenance-consent-signature.json - """ - filename = base_settings["unittest_data_dir"] / "provenance-consent-signature.json" - inst = provenance.Provenance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Provenance" == inst.resource_type - - impl_provenance_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Provenance" == data["resourceType"] - - inst2 = provenance.Provenance(**data) - impl_provenance_2(inst2) - - -def impl_provenance_3(inst): - assert inst.agent[0].type.coding[0].code == "AUT" - assert ( - inst.agent[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.agent[0].who.reference == "Patient/example" - assert inst.entity[0].role == "source" - assert inst.entity[0].what.identifier.type.coding[0].code == "CWL" - assert inst.entity[0].what.identifier.type.coding[0].display == "lobSTR" - assert ( - inst.entity[0].what.identifier.type.coding[0].system - == "https://github.com/common-workflow-language/workflows" - ) - assert inst.entity[0].what.identifier.value == ( - "https://github.com/common-workflow-" - "language/workflows/blob/master/workflows/lobSTR/lobSTR-" - "workflow.cwl" - ) - assert inst.id == "example-cwl" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurredPeriod.start == fhirtypes.DateTime.validate( - "2016-11-30T11:15:33+10:00" - ) - assert inst.reason[0].text == ( - "profiling Short Tandem Repeats (STRs) from high throughput " "sequencing data." - ) - assert inst.recorded == fhirtypes.Instant.validate("2016-12-01T08:12:14+10:00") - assert inst.target[0].reference == "MolecularSequence/example-pgx-1" - assert inst.text.status == "generated" - - -def test_provenance_3(base_settings): - """No. 3 tests collection for Provenance. - Test File: provenance-example-cwl.json - """ - filename = base_settings["unittest_data_dir"] / "provenance-example-cwl.json" - inst = provenance.Provenance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Provenance" == inst.resource_type - - impl_provenance_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Provenance" == data["resourceType"] - - inst2 = provenance.Provenance(**data) - impl_provenance_3(inst2) - - -def impl_provenance_4(inst): - assert inst.agent[0].type.coding[0].code == "AUT" - assert ( - inst.agent[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.agent[0].who.reference == "Practitioner/example" - assert inst.entity[0].role == "source" - assert inst.entity[0].what.identifier.type.coding[0].code == "biocompute" - assert inst.entity[0].what.identifier.type.coding[0].display == "obj.1001" - assert ( - inst.entity[0].what.identifier.type.coding[0].system - == "https://hive.biochemistry.gwu.edu" - ) - assert inst.entity[0].what.identifier.value == ( - "https://hive.biochemistry.gwu.edu/cgi-" - "bin/prd/htscsrs/servlet.cgi?pageid=bcoexample_1" - ) - assert inst.id == "example-biocompute-object" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurredPeriod.start == fhirtypes.DateTime.validate( - "2017-06-06T11:15:33+10:00" - ) - assert inst.reason[0].text == "antiviral resistance detection" - assert inst.recorded == fhirtypes.Instant.validate("2016-06-09T08:12:14+10:00") - assert inst.target[0].reference == "MolecularSequence/example" - assert inst.text.status == "generated" - - -def test_provenance_4(base_settings): - """No. 4 tests collection for Provenance. - Test File: provenance-example-biocompute-object.json - """ - filename = ( - base_settings["unittest_data_dir"] / "provenance-example-biocompute-object.json" - ) - inst = provenance.Provenance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Provenance" == inst.resource_type - - impl_provenance_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Provenance" == data["resourceType"] - - inst2 = provenance.Provenance(**data) - impl_provenance_4(inst2) - - -def impl_provenance_5(inst): - assert inst.agent[0].type.coding[0].code == "AUT" - assert ( - inst.agent[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.agent[0].who.reference == "Practitioner/xcda-author" - assert inst.agent[1].id == "a1" - assert inst.agent[1].type.coding[0].code == "DEV" - assert ( - inst.agent[1].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-ParticipationType" - ) - assert inst.agent[1].who.reference == "Device/software" - assert inst.entity[0].role == "source" - assert inst.entity[0].what.display == "CDA Document in XDS repository" - assert inst.entity[0].what.reference == "DocumentReference/example" - assert inst.id == "example" - assert inst.location.reference == "Location/1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurredPeriod.end == fhirtypes.DateTime.validate( - "2015-06-28T11:15:33+10:00" - ) - assert inst.occurredPeriod.start == fhirtypes.DateTime.validate( - "2015-06-27T11:15:33+10:00" - ) - assert inst.policy[0] == "http://acme.com/fhir/Consent/25" - assert inst.reason[0].coding[0].code == "3457005" - assert inst.reason[0].coding[0].display == "Referral" - assert inst.reason[0].coding[0].system == "http://snomed.info/sct" - assert inst.recorded == fhirtypes.Instant.validate("2015-06-27T08:39:24+10:00") - assert inst.target[0].reference == "Procedure/example/_history/1" - assert inst.text.status == "generated" - - -def test_provenance_5(base_settings): - """No. 5 tests collection for Provenance. - Test File: provenance-example.json - """ - filename = base_settings["unittest_data_dir"] / "provenance-example.json" - inst = provenance.Provenance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Provenance" == inst.resource_type - - impl_provenance_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Provenance" == data["resourceType"] - - inst2 = provenance.Provenance(**data) - impl_provenance_5(inst2) diff --git a/fhir/resources/tests/test_questionnaire.py b/fhir/resources/tests/test_questionnaire.py deleted file mode 100644 index 7ee18c3d..00000000 --- a/fhir/resources/tests/test_questionnaire.py +++ /dev/null @@ -1,3311 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Questionnaire -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import questionnaire - - -def impl_questionnaire_1(inst): - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.id == "qs1" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.item[0].item[0].linkId == "display.ID" - assert inst.item[0].item[0].type == "display" - assert inst.item[0].item[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[1].linkId == "display.ID" - assert inst.item[0].item[1].text == ( - "Demographics and administrative information about a person " - "independent of a specific health-related context." - ) - assert inst.item[0].item[1].type == "display" - assert inst.item[0].item[2].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[2].extension[0].valueInteger == 1 - assert inst.item[0].item[2].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[2].extension[1].valueString == "string" - assert inst.item[0].item[2].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[2].item[0].linkId == "display.ID" - assert inst.item[0].item[2].item[0].type == "display" - assert inst.item[0].item[2].item[1].linkId == "Person.id.value" - assert inst.item[0].item[2].item[1].repeats is False - assert inst.item[0].item[2].item[1].required is False - assert inst.item[0].item[2].item[1].text == "Logical id of this artifact" - assert inst.item[0].item[2].item[1].type == "string" - assert inst.item[0].item[2].linkId == "Person.id" - assert inst.item[0].item[2].repeats is True - assert inst.item[0].item[2].required is False - assert inst.item[0].item[2].type == "group" - assert inst.item[0].item[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[3].extension[0].valueInteger == 1 - assert inst.item[0].item[3].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[3].item[0].linkId == "display.ID" - assert inst.item[0].item[3].item[0].text == ( - "The metadata about the resource. This is content that is " - "maintained by the infrastructure. Changes to the content " - "might not always be associated with version changes to the " - "resource." - ) - assert inst.item[0].item[3].item[0].type == "display" - assert inst.item[0].item[3].linkId == "Person.meta" - assert inst.item[0].item[3].repeats is True - assert inst.item[0].item[3].required is False - assert inst.item[0].item[3].text == "Metadata about the resource" - assert inst.item[0].item[3].type == "group" - assert inst.item[0].item[4].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[4].extension[0].valueInteger == 1 - assert inst.item[0].item[4].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[4].extension[1].valueString == "uri" - assert inst.item[0].item[4].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[4].item[0].linkId == "display.ID" - assert inst.item[0].item[4].item[0].type == "display" - assert inst.item[0].item[4].item[1].linkId == "Person.implicitRules.value" - assert inst.item[0].item[4].item[1].repeats is False - assert inst.item[0].item[4].item[1].required is False - assert ( - inst.item[0].item[4].item[1].text - == "A set of rules under which this content was created" - ) - assert inst.item[0].item[4].item[1].type == "string" - assert inst.item[0].item[4].linkId == "Person.implicitRules" - assert inst.item[0].item[4].repeats is True - assert inst.item[0].item[4].required is False - assert inst.item[0].item[4].type == "group" - assert inst.item[0].item[5].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[5].extension[0].valueInteger == 1 - assert inst.item[0].item[5].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[5].extension[1].valueString == "code" - assert inst.item[0].item[5].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[5].item[0].linkId == "display.ID" - assert inst.item[0].item[5].item[0].type == "display" - assert inst.item[0].item[5].item[1].linkId == "Person.language.value" - assert inst.item[0].item[5].item[1].repeats is False - assert inst.item[0].item[5].item[1].required is False - assert inst.item[0].item[5].item[1].text == "language" - assert inst.item[0].item[5].item[1].type == "choice" - assert inst.item[0].item[5].linkId == "Person.language" - assert inst.item[0].item[5].repeats is True - assert inst.item[0].item[5].required is False - assert inst.item[0].item[5].type == "group" - assert inst.item[0].item[6].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[6].extension[0].valueInteger == 1 - assert inst.item[0].item[6].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[6].item[0].linkId == "display.ID" - assert inst.item[0].item[6].item[0].type == "display" - assert inst.item[0].item[6].linkId == "Person.text" - assert inst.item[0].item[6].repeats is True - assert inst.item[0].item[6].required is False - assert ( - inst.item[0].item[6].text - == "Text summary of the resource, for human interpretation" - ) - assert inst.item[0].item[6].type == "group" - assert inst.item[0].item[7].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[7].item[0].linkId == "display.ID" - assert inst.item[0].item[7].item[0].type == "display" - assert inst.item[0].item[7].linkId == "Person.contained" - assert inst.item[0].item[7].repeats is True - assert inst.item[0].item[7].required is False - assert inst.item[0].item[7].text == "Contained, inline Resources" - assert inst.item[0].item[7].type == "group" - assert inst.item[0].item[8].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[8].item[0].linkId == "display.ID" - assert inst.item[0].item[8].item[0].type == "display" - assert inst.item[0].item[8].linkId == "Person.extension" - assert inst.item[0].item[8].repeats is True - assert inst.item[0].item[8].required is False - assert inst.item[0].item[8].text == "Additional content defined by implementations" - assert inst.item[0].item[8].type == "group" - assert inst.item[0].item[9].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[9].item[0].linkId == "display.ID" - assert inst.item[0].item[9].item[0].type == "display" - assert inst.item[0].item[9].linkId == "Person.modifierExtension" - assert inst.item[0].item[9].repeats is True - assert inst.item[0].item[9].required is False - assert inst.item[0].item[9].text == "Extensions that cannot be ignored" - assert inst.item[0].item[9].type == "group" - assert inst.item[0].linkId == "Person" - assert inst.item[0].repeats is True - assert inst.item[0].required is False - assert inst.item[0].text == "A generic person record" - assert inst.item[0].type == "group" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "Health Level Seven International (Patient Administration)" - assert inst.status == "draft" - assert inst.version == "4.0.1" - - -def test_questionnaire_1(base_settings): - """No. 1 tests collection for Questionnaire. - Test File: person-questionnaire.json - """ - filename = base_settings["unittest_data_dir"] / "person-questionnaire.json" - inst = questionnaire.Questionnaire.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Questionnaire" == inst.resource_type - - impl_questionnaire_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Questionnaire" == data["resourceType"] - - inst2 = questionnaire.Questionnaire(**data) - impl_questionnaire_1(inst2) - - -def impl_questionnaire_2(inst): - assert inst.contained[0].id == "vs2" - assert inst.date == fhirtypes.DateTime.validate("2015-10-09T00:00:00+11:00") - assert inst.id == "qs1" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.item[0].item[0].linkId == "display.ID" - assert inst.item[0].item[0].type == "display" - assert inst.item[0].item[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[1].linkId == "display.ID" - assert inst.item[0].item[1].type == "display" - assert inst.item[0].item[2].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[2].extension[0].valueInteger == 1 - assert inst.item[0].item[2].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[2].extension[1].valueString == "string" - assert inst.item[0].item[2].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[2].item[0].linkId == "display.ID" - assert inst.item[0].item[2].item[0].type == "display" - assert inst.item[0].item[2].item[1].linkId == "DiagnosticReport.id.value" - assert inst.item[0].item[2].item[1].repeats is False - assert inst.item[0].item[2].item[1].required is False - assert inst.item[0].item[2].item[1].text == "Logical id of this artifact" - assert inst.item[0].item[2].item[1].type == "string" - assert inst.item[0].item[2].linkId == "DiagnosticReport.id" - assert inst.item[0].item[2].repeats is True - assert inst.item[0].item[2].required is False - assert inst.item[0].item[2].type == "group" - assert inst.item[0].item[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[3].extension[0].valueInteger == 1 - assert inst.item[0].item[3].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[3].item[0].linkId == "display.ID" - assert inst.item[0].item[3].item[0].text == ( - "The metadata about the resource. This is content that is " - "maintained by the infrastructure. Changes to the content " - "might not always be associated with version changes to the " - "resource." - ) - assert inst.item[0].item[3].item[0].type == "display" - assert inst.item[0].item[3].linkId == "DiagnosticReport.meta" - assert inst.item[0].item[3].repeats is True - assert inst.item[0].item[3].required is False - assert inst.item[0].item[3].text == "Metadata about the resource" - assert inst.item[0].item[3].type == "group" - assert inst.item[0].item[4].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[4].extension[0].valueInteger == 1 - assert inst.item[0].item[4].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[4].extension[1].valueString == "uri" - assert inst.item[0].item[4].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[4].item[0].linkId == "display.ID" - assert inst.item[0].item[4].item[0].type == "display" - assert inst.item[0].item[4].item[1].linkId == "DiagnosticReport.implicitRules.value" - assert inst.item[0].item[4].item[1].repeats is False - assert inst.item[0].item[4].item[1].required is False - assert ( - inst.item[0].item[4].item[1].text - == "A set of rules under which this content was created" - ) - assert inst.item[0].item[4].item[1].type == "string" - assert inst.item[0].item[4].linkId == "DiagnosticReport.implicitRules" - assert inst.item[0].item[4].repeats is True - assert inst.item[0].item[4].required is False - assert inst.item[0].item[4].type == "group" - assert inst.item[0].item[5].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[5].extension[0].valueInteger == 1 - assert inst.item[0].item[5].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[5].extension[1].valueString == "code" - assert inst.item[0].item[5].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[5].item[0].linkId == "display.ID" - assert inst.item[0].item[5].item[0].type == "display" - assert inst.item[0].item[5].item[1].linkId == "DiagnosticReport.language.value" - assert inst.item[0].item[5].item[1].repeats is False - assert inst.item[0].item[5].item[1].required is False - assert inst.item[0].item[5].item[1].text == "language" - assert inst.item[0].item[5].item[1].type == "choice" - assert inst.item[0].item[5].linkId == "DiagnosticReport.language" - assert inst.item[0].item[5].repeats is True - assert inst.item[0].item[5].required is False - assert inst.item[0].item[5].type == "group" - assert inst.item[0].item[6].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[6].extension[0].valueInteger == 1 - assert inst.item[0].item[6].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[6].item[0].linkId == "display.ID" - assert inst.item[0].item[6].item[0].type == "display" - assert inst.item[0].item[6].linkId == "DiagnosticReport.text" - assert inst.item[0].item[6].repeats is True - assert inst.item[0].item[6].required is False - assert ( - inst.item[0].item[6].text - == "Text summary of the resource, for human interpretation" - ) - assert inst.item[0].item[6].type == "group" - assert inst.item[0].item[7].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[7].item[0].linkId == "display.ID" - assert inst.item[0].item[7].item[0].type == "display" - assert inst.item[0].item[7].linkId == "DiagnosticReport.contained" - assert inst.item[0].item[7].repeats is True - assert inst.item[0].item[7].required is False - assert inst.item[0].item[7].text == "Contained, inline Resources" - assert inst.item[0].item[7].type == "group" - assert inst.item[0].item[8].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[8].item[0].linkId == "display.ID" - assert inst.item[0].item[8].item[0].text == "An Extension" - assert inst.item[0].item[8].item[0].type == "display" - assert inst.item[0].item[8].linkId == "DiagnosticReport.extension" - assert inst.item[0].item[8].repeats is True - assert inst.item[0].item[8].required is False - assert inst.item[0].item[8].text == "Extension" - assert inst.item[0].item[8].type == "group" - assert inst.item[0].item[9].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[9].item[0].linkId == "display.ID" - assert inst.item[0].item[9].item[0].type == "display" - assert inst.item[0].item[9].linkId == "DiagnosticReport.modifierExtension" - assert inst.item[0].item[9].repeats is True - assert inst.item[0].item[9].required is False - assert inst.item[0].item[9].text == "Extensions that cannot be ignored" - assert inst.item[0].item[9].type == "group" - assert inst.item[0].linkId == "DiagnosticReport" - assert inst.item[0].repeats is True - assert inst.item[0].required is False - assert inst.item[0].text == ( - "A Diagnostic report - a combination of request information, " - "atomic results, images, interpretation, as well as formatted" - " reports" - ) - assert inst.item[0].type == "group" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "Health Level Seven International (Clinical Genomics)" - assert inst.status == "draft" - assert inst.version == "4.0.1" - - -def test_questionnaire_2(base_settings): - """No. 2 tests collection for Questionnaire. - Test File: hlaresult-questionnaire.json - """ - filename = base_settings["unittest_data_dir"] / "hlaresult-questionnaire.json" - inst = questionnaire.Questionnaire.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Questionnaire" == inst.resource_type - - impl_questionnaire_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Questionnaire" == data["resourceType"] - - inst2 = questionnaire.Questionnaire(**data) - impl_questionnaire_2(inst2) - - -def impl_questionnaire_3(inst): - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.id == "qs1" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.item[0].item[0].linkId == "display.ID" - assert inst.item[0].item[0].text == ( - "Can result from the failure of a REST call or be part of the" - " response message returned from a request message." - ) - assert inst.item[0].item[0].type == "display" - assert inst.item[0].item[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[1].linkId == "display.ID" - assert inst.item[0].item[1].text == ( - "A collection of error, warning, or information messages that" - " result from a system action." - ) - assert inst.item[0].item[1].type == "display" - assert inst.item[0].item[2].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[2].extension[0].valueInteger == 1 - assert inst.item[0].item[2].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[2].extension[1].valueString == "string" - assert inst.item[0].item[2].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[2].item[0].linkId == "display.ID" - assert inst.item[0].item[2].item[0].type == "display" - assert inst.item[0].item[2].item[1].linkId == "OperationOutcome.id.value" - assert inst.item[0].item[2].item[1].repeats is False - assert inst.item[0].item[2].item[1].required is False - assert inst.item[0].item[2].item[1].text == "Logical id of this artifact" - assert inst.item[0].item[2].item[1].type == "string" - assert inst.item[0].item[2].linkId == "OperationOutcome.id" - assert inst.item[0].item[2].repeats is True - assert inst.item[0].item[2].required is False - assert inst.item[0].item[2].type == "group" - assert inst.item[0].item[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[3].extension[0].valueInteger == 1 - assert inst.item[0].item[3].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[3].item[0].linkId == "display.ID" - assert inst.item[0].item[3].item[0].text == ( - "The metadata about the resource. This is content that is " - "maintained by the infrastructure. Changes to the content " - "might not always be associated with version changes to the " - "resource." - ) - assert inst.item[0].item[3].item[0].type == "display" - assert inst.item[0].item[3].linkId == "OperationOutcome.meta" - assert inst.item[0].item[3].repeats is True - assert inst.item[0].item[3].required is False - assert inst.item[0].item[3].text == "Metadata about the resource" - assert inst.item[0].item[3].type == "group" - assert inst.item[0].item[4].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[4].extension[0].valueInteger == 1 - assert inst.item[0].item[4].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[4].extension[1].valueString == "uri" - assert inst.item[0].item[4].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[4].item[0].linkId == "display.ID" - assert inst.item[0].item[4].item[0].type == "display" - assert inst.item[0].item[4].item[1].linkId == "OperationOutcome.implicitRules.value" - assert inst.item[0].item[4].item[1].repeats is False - assert inst.item[0].item[4].item[1].required is False - assert ( - inst.item[0].item[4].item[1].text - == "A set of rules under which this content was created" - ) - assert inst.item[0].item[4].item[1].type == "string" - assert inst.item[0].item[4].linkId == "OperationOutcome.implicitRules" - assert inst.item[0].item[4].repeats is True - assert inst.item[0].item[4].required is False - assert inst.item[0].item[4].type == "group" - assert inst.item[0].item[5].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[5].extension[0].valueInteger == 1 - assert inst.item[0].item[5].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[5].extension[1].valueString == "code" - assert inst.item[0].item[5].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[5].item[0].linkId == "display.ID" - assert inst.item[0].item[5].item[0].type == "display" - assert inst.item[0].item[5].item[1].linkId == "OperationOutcome.language.value" - assert inst.item[0].item[5].item[1].repeats is False - assert inst.item[0].item[5].item[1].required is False - assert inst.item[0].item[5].item[1].text == "language" - assert inst.item[0].item[5].item[1].type == "choice" - assert inst.item[0].item[5].linkId == "OperationOutcome.language" - assert inst.item[0].item[5].repeats is True - assert inst.item[0].item[5].required is False - assert inst.item[0].item[5].type == "group" - assert inst.item[0].item[6].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[6].extension[0].valueInteger == 1 - assert inst.item[0].item[6].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[6].item[0].linkId == "display.ID" - assert inst.item[0].item[6].item[0].type == "display" - assert inst.item[0].item[6].linkId == "OperationOutcome.text" - assert inst.item[0].item[6].repeats is True - assert inst.item[0].item[6].required is False - assert ( - inst.item[0].item[6].text - == "Text summary of the resource, for human interpretation" - ) - assert inst.item[0].item[6].type == "group" - assert inst.item[0].item[7].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[7].item[0].linkId == "display.ID" - assert inst.item[0].item[7].item[0].type == "display" - assert inst.item[0].item[7].linkId == "OperationOutcome.contained" - assert inst.item[0].item[7].repeats is True - assert inst.item[0].item[7].required is False - assert inst.item[0].item[7].text == "Contained, inline Resources" - assert inst.item[0].item[7].type == "group" - assert inst.item[0].item[8].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[8].item[0].linkId == "display.ID" - assert inst.item[0].item[8].item[0].type == "display" - assert inst.item[0].item[8].linkId == "OperationOutcome.extension" - assert inst.item[0].item[8].repeats is True - assert inst.item[0].item[8].required is False - assert inst.item[0].item[8].text == "Additional content defined by implementations" - assert inst.item[0].item[8].type == "group" - assert inst.item[0].item[9].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[9].item[0].linkId == "display.ID" - assert inst.item[0].item[9].item[0].type == "display" - assert inst.item[0].item[9].linkId == "OperationOutcome.modifierExtension" - assert inst.item[0].item[9].repeats is True - assert inst.item[0].item[9].required is False - assert inst.item[0].item[9].text == "Extensions that cannot be ignored" - assert inst.item[0].item[9].type == "group" - assert inst.item[0].linkId == "OperationOutcome" - assert inst.item[0].repeats is True - assert inst.item[0].required is False - assert inst.item[0].text == "Information about the success/failure of an action" - assert inst.item[0].type == "group" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "Health Level Seven International (FHIR Infrastructure)" - assert inst.status == "active" - assert inst.version == "4.0.1" - - -def test_questionnaire_3(base_settings): - """No. 3 tests collection for Questionnaire. - Test File: operationoutcome-questionnaire.json - """ - filename = ( - base_settings["unittest_data_dir"] / "operationoutcome-questionnaire.json" - ) - inst = questionnaire.Questionnaire.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Questionnaire" == inst.resource_type - - impl_questionnaire_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Questionnaire" == data["resourceType"] - - inst2 = questionnaire.Questionnaire(**data) - impl_questionnaire_3(inst2) - - -def impl_questionnaire_4(inst): - assert inst.contained[0].id == "vs2" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.id == "qs1" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.item[0].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[0].linkId == "display.ID" - assert inst.item[0].item[0].text == ( - "The EventDefinition resource provides a reusable description" - " of when a particular event can occur." - ) - assert inst.item[0].item[0].type == "display" - assert inst.item[0].item[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[1].extension[0].valueInteger == 1 - assert inst.item[0].item[1].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[1].extension[1].valueString == "string" - assert inst.item[0].item[1].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[1].item[0].linkId == "display.ID" - assert inst.item[0].item[1].item[0].type == "display" - assert inst.item[0].item[1].item[1].linkId == "EventDefinition.id.value" - assert inst.item[0].item[1].item[1].repeats is False - assert inst.item[0].item[1].item[1].required is False - assert inst.item[0].item[1].item[1].text == "Logical id of this artifact" - assert inst.item[0].item[1].item[1].type == "string" - assert inst.item[0].item[1].linkId == "EventDefinition.id" - assert inst.item[0].item[1].repeats is True - assert inst.item[0].item[1].required is False - assert inst.item[0].item[1].type == "group" - assert inst.item[0].item[2].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[2].extension[0].valueInteger == 1 - assert inst.item[0].item[2].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[2].item[0].linkId == "display.ID" - assert inst.item[0].item[2].item[0].text == ( - "The metadata about the resource. This is content that is " - "maintained by the infrastructure. Changes to the content " - "might not always be associated with version changes to the " - "resource." - ) - assert inst.item[0].item[2].item[0].type == "display" - assert inst.item[0].item[2].linkId == "EventDefinition.meta" - assert inst.item[0].item[2].repeats is True - assert inst.item[0].item[2].required is False - assert inst.item[0].item[2].text == "Metadata about the resource" - assert inst.item[0].item[2].type == "group" - assert inst.item[0].item[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[3].extension[0].valueInteger == 1 - assert inst.item[0].item[3].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[3].extension[1].valueString == "uri" - assert inst.item[0].item[3].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[3].item[0].linkId == "display.ID" - assert inst.item[0].item[3].item[0].type == "display" - assert inst.item[0].item[3].item[1].linkId == "EventDefinition.implicitRules.value" - assert inst.item[0].item[3].item[1].repeats is False - assert inst.item[0].item[3].item[1].required is False - assert ( - inst.item[0].item[3].item[1].text - == "A set of rules under which this content was created" - ) - assert inst.item[0].item[3].item[1].type == "string" - assert inst.item[0].item[3].linkId == "EventDefinition.implicitRules" - assert inst.item[0].item[3].repeats is True - assert inst.item[0].item[3].required is False - assert inst.item[0].item[3].type == "group" - assert inst.item[0].item[4].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[4].extension[0].valueInteger == 1 - assert inst.item[0].item[4].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[4].extension[1].valueString == "code" - assert inst.item[0].item[4].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[4].item[0].linkId == "display.ID" - assert inst.item[0].item[4].item[0].type == "display" - assert inst.item[0].item[4].item[1].linkId == "EventDefinition.language.value" - assert inst.item[0].item[4].item[1].repeats is False - assert inst.item[0].item[4].item[1].required is False - assert inst.item[0].item[4].item[1].text == "language" - assert inst.item[0].item[4].item[1].type == "choice" - assert inst.item[0].item[4].linkId == "EventDefinition.language" - assert inst.item[0].item[4].repeats is True - assert inst.item[0].item[4].required is False - assert inst.item[0].item[4].type == "group" - assert inst.item[0].item[5].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[5].extension[0].valueInteger == 1 - assert inst.item[0].item[5].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[5].item[0].linkId == "display.ID" - assert inst.item[0].item[5].item[0].type == "display" - assert inst.item[0].item[5].linkId == "EventDefinition.text" - assert inst.item[0].item[5].repeats is True - assert inst.item[0].item[5].required is False - assert ( - inst.item[0].item[5].text - == "Text summary of the resource, for human interpretation" - ) - assert inst.item[0].item[5].type == "group" - assert inst.item[0].item[6].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[6].item[0].linkId == "display.ID" - assert inst.item[0].item[6].item[0].type == "display" - assert inst.item[0].item[6].linkId == "EventDefinition.contained" - assert inst.item[0].item[6].repeats is True - assert inst.item[0].item[6].required is False - assert inst.item[0].item[6].text == "Contained, inline Resources" - assert inst.item[0].item[6].type == "group" - assert inst.item[0].item[7].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[7].item[0].linkId == "display.ID" - assert inst.item[0].item[7].item[0].type == "display" - assert inst.item[0].item[7].linkId == "EventDefinition.extension" - assert inst.item[0].item[7].repeats is True - assert inst.item[0].item[7].required is False - assert inst.item[0].item[7].text == "Additional content defined by implementations" - assert inst.item[0].item[7].type == "group" - assert inst.item[0].item[8].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[8].item[0].linkId == "display.ID" - assert inst.item[0].item[8].item[0].type == "display" - assert inst.item[0].item[8].linkId == "EventDefinition.modifierExtension" - assert inst.item[0].item[8].repeats is True - assert inst.item[0].item[8].required is False - assert inst.item[0].item[8].text == "Extensions that cannot be ignored" - assert inst.item[0].item[8].type == "group" - assert inst.item[0].item[9].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[9].extension[0].valueInteger == 1 - assert inst.item[0].item[9].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[9].extension[1].valueString == "uri" - assert inst.item[0].item[9].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[9].item[0].linkId == "display.ID" - assert inst.item[0].item[9].item[0].type == "display" - assert inst.item[0].item[9].item[1].linkId == "EventDefinition.url.value" - assert inst.item[0].item[9].item[1].repeats is False - assert inst.item[0].item[9].item[1].required is False - assert inst.item[0].item[9].item[1].text == ( - "Canonical identifier for this event definition, represented " - "as a URI (globally unique)" - ) - assert inst.item[0].item[9].item[1].type == "string" - assert inst.item[0].item[9].linkId == "EventDefinition.url" - assert inst.item[0].item[9].repeats is True - assert inst.item[0].item[9].required is False - assert inst.item[0].item[9].type == "group" - assert inst.item[0].linkId == "EventDefinition" - assert inst.item[0].repeats is True - assert inst.item[0].required is False - assert inst.item[0].text == "A description of when an event can occur" - assert inst.item[0].type == "group" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert ( - inst.publisher == "Health Level Seven International (Clinical Decision Support)" - ) - assert inst.status == "draft" - assert inst.version == "4.0.1" - - -def test_questionnaire_4(base_settings): - """No. 4 tests collection for Questionnaire. - Test File: eventdefinition-questionnaire.json - """ - filename = base_settings["unittest_data_dir"] / "eventdefinition-questionnaire.json" - inst = questionnaire.Questionnaire.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Questionnaire" == inst.resource_type - - impl_questionnaire_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Questionnaire" == data["resourceType"] - - inst2 = questionnaire.Questionnaire(**data) - impl_questionnaire_4(inst2) - - -def impl_questionnaire_5(inst): - assert inst.contained[0].id == "vs2" - assert inst.contained[1].id == "vs3" - assert inst.contained[2].id == "vs4" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.id == "qs1" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.item[0].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[0].linkId == "display.ID" - assert inst.item[0].item[0].text == ( - "This resource allows for the definition of some activity to " - "be performed, independent of a particular patient, " - "practitioner, or other performance context." - ) - assert inst.item[0].item[0].type == "display" - assert inst.item[0].item[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[1].extension[0].valueInteger == 1 - assert inst.item[0].item[1].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[1].extension[1].valueString == "string" - assert inst.item[0].item[1].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[1].item[0].linkId == "display.ID" - assert inst.item[0].item[1].item[0].type == "display" - assert inst.item[0].item[1].item[1].linkId == "ActivityDefinition.id.value" - assert inst.item[0].item[1].item[1].repeats is False - assert inst.item[0].item[1].item[1].required is False - assert inst.item[0].item[1].item[1].text == "Logical id of this artifact" - assert inst.item[0].item[1].item[1].type == "string" - assert inst.item[0].item[1].linkId == "ActivityDefinition.id" - assert inst.item[0].item[1].repeats is True - assert inst.item[0].item[1].required is False - assert inst.item[0].item[1].type == "group" - assert inst.item[0].item[2].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[2].extension[0].valueInteger == 1 - assert inst.item[0].item[2].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[2].item[0].linkId == "display.ID" - assert inst.item[0].item[2].item[0].text == ( - "The metadata about the resource. This is content that is " - "maintained by the infrastructure. Changes to the content " - "might not always be associated with version changes to the " - "resource." - ) - assert inst.item[0].item[2].item[0].type == "display" - assert inst.item[0].item[2].linkId == "ActivityDefinition.meta" - assert inst.item[0].item[2].repeats is True - assert inst.item[0].item[2].required is False - assert inst.item[0].item[2].text == "Metadata about the resource" - assert inst.item[0].item[2].type == "group" - assert inst.item[0].item[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[3].extension[0].valueInteger == 1 - assert inst.item[0].item[3].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[3].extension[1].valueString == "uri" - assert inst.item[0].item[3].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[3].item[0].linkId == "display.ID" - assert inst.item[0].item[3].item[0].type == "display" - assert ( - inst.item[0].item[3].item[1].linkId == "ActivityDefinition.implicitRules.value" - ) - assert inst.item[0].item[3].item[1].repeats is False - assert inst.item[0].item[3].item[1].required is False - assert ( - inst.item[0].item[3].item[1].text - == "A set of rules under which this content was created" - ) - assert inst.item[0].item[3].item[1].type == "string" - assert inst.item[0].item[3].linkId == "ActivityDefinition.implicitRules" - assert inst.item[0].item[3].repeats is True - assert inst.item[0].item[3].required is False - assert inst.item[0].item[3].type == "group" - assert inst.item[0].item[4].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[4].extension[0].valueInteger == 1 - assert inst.item[0].item[4].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[4].extension[1].valueString == "code" - assert inst.item[0].item[4].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[4].item[0].linkId == "display.ID" - assert inst.item[0].item[4].item[0].type == "display" - assert inst.item[0].item[4].item[1].linkId == "ActivityDefinition.language.value" - assert inst.item[0].item[4].item[1].repeats is False - assert inst.item[0].item[4].item[1].required is False - assert inst.item[0].item[4].item[1].text == "language" - assert inst.item[0].item[4].item[1].type == "choice" - assert inst.item[0].item[4].linkId == "ActivityDefinition.language" - assert inst.item[0].item[4].repeats is True - assert inst.item[0].item[4].required is False - assert inst.item[0].item[4].type == "group" - assert inst.item[0].item[5].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[5].extension[0].valueInteger == 1 - assert inst.item[0].item[5].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[5].item[0].linkId == "display.ID" - assert inst.item[0].item[5].item[0].type == "display" - assert inst.item[0].item[5].linkId == "ActivityDefinition.text" - assert inst.item[0].item[5].repeats is True - assert inst.item[0].item[5].required is False - assert ( - inst.item[0].item[5].text - == "Text summary of the resource, for human interpretation" - ) - assert inst.item[0].item[5].type == "group" - assert inst.item[0].item[6].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[6].item[0].linkId == "display.ID" - assert inst.item[0].item[6].item[0].type == "display" - assert inst.item[0].item[6].linkId == "ActivityDefinition.contained" - assert inst.item[0].item[6].repeats is True - assert inst.item[0].item[6].required is False - assert inst.item[0].item[6].text == "Contained, inline Resources" - assert inst.item[0].item[6].type == "group" - assert inst.item[0].item[7].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[7].item[0].linkId == "display.ID" - assert inst.item[0].item[7].item[0].type == "display" - assert inst.item[0].item[7].linkId == "ActivityDefinition.extension" - assert inst.item[0].item[7].repeats is True - assert inst.item[0].item[7].required is False - assert inst.item[0].item[7].text == "Additional content defined by implementations" - assert inst.item[0].item[7].type == "group" - assert inst.item[0].item[8].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[8].item[0].linkId == "display.ID" - assert inst.item[0].item[8].item[0].type == "display" - assert inst.item[0].item[8].linkId == "ActivityDefinition.modifierExtension" - assert inst.item[0].item[8].repeats is True - assert inst.item[0].item[8].required is False - assert inst.item[0].item[8].text == "Extensions that cannot be ignored" - assert inst.item[0].item[8].type == "group" - assert inst.item[0].item[9].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[9].extension[0].valueInteger == 1 - assert inst.item[0].item[9].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[9].extension[1].valueString == "uri" - assert inst.item[0].item[9].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[9].item[0].linkId == "display.ID" - assert inst.item[0].item[9].item[0].type == "display" - assert inst.item[0].item[9].item[1].linkId == "ActivityDefinition.url.value" - assert inst.item[0].item[9].item[1].repeats is False - assert inst.item[0].item[9].item[1].required is False - assert inst.item[0].item[9].item[1].text == ( - "Canonical identifier for this activity definition, " - "represented as a URI (globally unique)" - ) - assert inst.item[0].item[9].item[1].type == "string" - assert inst.item[0].item[9].linkId == "ActivityDefinition.url" - assert inst.item[0].item[9].repeats is True - assert inst.item[0].item[9].required is False - assert inst.item[0].item[9].type == "group" - assert inst.item[0].linkId == "ActivityDefinition" - assert inst.item[0].repeats is True - assert inst.item[0].required is False - assert inst.item[0].text == ( - "The definition of a specific activity to be taken, " - "independent of any particular patient or context" - ) - assert inst.item[0].type == "group" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert ( - inst.publisher == "Health Level Seven International (Clinical Decision Support)" - ) - assert inst.status == "draft" - assert inst.version == "4.0.1" - - -def test_questionnaire_5(base_settings): - """No. 5 tests collection for Questionnaire. - Test File: activitydefinition-questionnaire.json - """ - filename = ( - base_settings["unittest_data_dir"] / "activitydefinition-questionnaire.json" - ) - inst = questionnaire.Questionnaire.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Questionnaire" == inst.resource_type - - impl_questionnaire_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Questionnaire" == data["resourceType"] - - inst2 = questionnaire.Questionnaire(**data) - impl_questionnaire_5(inst2) - - -def impl_questionnaire_6(inst): - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.id == "qs1" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "minOccurs" - ) - assert inst.item[0].extension[0].valueInteger == 1 - assert inst.item[0].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].extension[1].valueInteger == 1 - assert inst.item[0].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[0].linkId == "display.ID" - assert inst.item[0].item[0].text == ( - "A guidance response is the formal response to a guidance " - "request, including any output parameters returned by the " - "evaluation, as well as the description of any proposed " - "actions to be taken." - ) - assert inst.item[0].item[0].type == "display" - assert inst.item[0].item[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[1].extension[0].valueInteger == 1 - assert inst.item[0].item[1].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[1].extension[1].valueString == "string" - assert inst.item[0].item[1].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[1].item[0].linkId == "display.ID" - assert inst.item[0].item[1].item[0].type == "display" - assert inst.item[0].item[1].item[1].linkId == "GuidanceResponse.id.value" - assert inst.item[0].item[1].item[1].repeats is False - assert inst.item[0].item[1].item[1].required is False - assert inst.item[0].item[1].item[1].text == "Logical id of this artifact" - assert inst.item[0].item[1].item[1].type == "string" - assert inst.item[0].item[1].linkId == "GuidanceResponse.id" - assert inst.item[0].item[1].repeats is True - assert inst.item[0].item[1].required is False - assert inst.item[0].item[1].type == "group" - assert inst.item[0].item[2].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[2].extension[0].valueInteger == 1 - assert inst.item[0].item[2].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[2].item[0].linkId == "display.ID" - assert inst.item[0].item[2].item[0].text == ( - "The metadata about the resource. This is content that is " - "maintained by the infrastructure. Changes to the content " - "might not always be associated with version changes to the " - "resource." - ) - assert inst.item[0].item[2].item[0].type == "display" - assert inst.item[0].item[2].linkId == "GuidanceResponse.meta" - assert inst.item[0].item[2].repeats is True - assert inst.item[0].item[2].required is False - assert inst.item[0].item[2].text == "Metadata about the resource" - assert inst.item[0].item[2].type == "group" - assert inst.item[0].item[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[3].extension[0].valueInteger == 1 - assert inst.item[0].item[3].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[3].extension[1].valueString == "uri" - assert inst.item[0].item[3].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[3].item[0].linkId == "display.ID" - assert inst.item[0].item[3].item[0].type == "display" - assert inst.item[0].item[3].item[1].linkId == "GuidanceResponse.implicitRules.value" - assert inst.item[0].item[3].item[1].repeats is False - assert inst.item[0].item[3].item[1].required is False - assert ( - inst.item[0].item[3].item[1].text - == "A set of rules under which this content was created" - ) - assert inst.item[0].item[3].item[1].type == "string" - assert inst.item[0].item[3].linkId == "GuidanceResponse.implicitRules" - assert inst.item[0].item[3].repeats is True - assert inst.item[0].item[3].required is False - assert inst.item[0].item[3].type == "group" - assert inst.item[0].item[4].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[4].extension[0].valueInteger == 1 - assert inst.item[0].item[4].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[4].extension[1].valueString == "code" - assert inst.item[0].item[4].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[4].item[0].linkId == "display.ID" - assert inst.item[0].item[4].item[0].type == "display" - assert inst.item[0].item[4].item[1].linkId == "GuidanceResponse.language.value" - assert inst.item[0].item[4].item[1].repeats is False - assert inst.item[0].item[4].item[1].required is False - assert inst.item[0].item[4].item[1].text == "language" - assert inst.item[0].item[4].item[1].type == "choice" - assert inst.item[0].item[4].linkId == "GuidanceResponse.language" - assert inst.item[0].item[4].repeats is True - assert inst.item[0].item[4].required is False - assert inst.item[0].item[4].type == "group" - assert inst.item[0].item[5].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[5].extension[0].valueInteger == 1 - assert inst.item[0].item[5].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[5].item[0].linkId == "display.ID" - assert inst.item[0].item[5].item[0].type == "display" - assert inst.item[0].item[5].linkId == "GuidanceResponse.text" - assert inst.item[0].item[5].repeats is True - assert inst.item[0].item[5].required is False - assert ( - inst.item[0].item[5].text - == "Text summary of the resource, for human interpretation" - ) - assert inst.item[0].item[5].type == "group" - assert inst.item[0].item[6].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[6].item[0].linkId == "display.ID" - assert inst.item[0].item[6].item[0].type == "display" - assert inst.item[0].item[6].linkId == "GuidanceResponse.contained" - assert inst.item[0].item[6].repeats is True - assert inst.item[0].item[6].required is False - assert inst.item[0].item[6].text == "Contained, inline Resources" - assert inst.item[0].item[6].type == "group" - assert inst.item[0].item[7].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[7].item[0].linkId == "display.ID" - assert inst.item[0].item[7].item[0].text == "An Extension" - assert inst.item[0].item[7].item[0].type == "display" - assert inst.item[0].item[7].linkId == "GuidanceResponse.extension" - assert inst.item[0].item[7].repeats is True - assert inst.item[0].item[7].required is False - assert inst.item[0].item[7].text == "Extension" - assert inst.item[0].item[7].type == "group" - assert inst.item[0].item[8].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[8].item[0].linkId == "display.ID" - assert inst.item[0].item[8].item[0].type == "display" - assert inst.item[0].item[8].linkId == "GuidanceResponse.modifierExtension" - assert inst.item[0].item[8].repeats is True - assert inst.item[0].item[8].required is False - assert inst.item[0].item[8].text == "Extensions that cannot be ignored" - assert inst.item[0].item[8].type == "group" - assert inst.item[0].item[9].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "minOccurs" - ) - assert inst.item[0].item[9].extension[0].valueInteger == 1 - assert inst.item[0].item[9].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[9].extension[1].valueInteger == 1 - assert inst.item[0].item[9].extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[9].extension[2].valueString == "Identifier" - assert inst.item[0].item[9].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[9].item[0].linkId == "display.ID" - assert inst.item[0].item[9].item[0].type == "display" - assert ( - inst.item[0].item[9].item[1].linkId - == "GuidanceResponse.requestIdentifier.label" - ) - assert inst.item[0].item[9].item[1].repeats is False - assert inst.item[0].item[9].item[1].required is False - assert inst.item[0].item[9].item[1].text == "label:" - assert inst.item[0].item[9].item[1].type == "string" - assert ( - inst.item[0].item[9].item[2].linkId - == "GuidanceResponse.requestIdentifier.system" - ) - assert inst.item[0].item[9].item[2].repeats is False - assert inst.item[0].item[9].item[2].required is False - assert inst.item[0].item[9].item[2].text == "system:" - assert inst.item[0].item[9].item[2].type == "string" - assert ( - inst.item[0].item[9].item[3].linkId - == "GuidanceResponse.requestIdentifier.value" - ) - assert inst.item[0].item[9].item[3].repeats is False - assert inst.item[0].item[9].item[3].required is False - assert inst.item[0].item[9].item[3].text == "value:" - assert inst.item[0].item[9].item[3].type == "string" - assert inst.item[0].item[9].linkId == "GuidanceResponse.requestIdentifier" - assert inst.item[0].item[9].repeats is True - assert inst.item[0].item[9].required is True - assert inst.item[0].item[9].text == ( - "The identifier of the request associated with this response," " if any" - ) - assert inst.item[0].item[9].type == "group" - assert inst.item[0].linkId == "GuidanceResponse" - assert inst.item[0].repeats is False - assert inst.item[0].required is True - assert inst.item[0].text == "The formal response to a guidance request" - assert inst.item[0].type == "group" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "HL7" - assert inst.status == "draft" - assert inst.version == "4.0.1" - - -def test_questionnaire_6(base_settings): - """No. 6 tests collection for Questionnaire. - Test File: cdshooksguidanceresponse-questionnaire.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "cdshooksguidanceresponse-questionnaire.json" - ) - inst = questionnaire.Questionnaire.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Questionnaire" == inst.resource_type - - impl_questionnaire_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Questionnaire" == data["resourceType"] - - inst2 = questionnaire.Questionnaire(**data) - impl_questionnaire_6(inst2) - - -def impl_questionnaire_7(inst): - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.id == "qs1" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.item[0].item[0].linkId == "display.ID" - assert inst.item[0].item[0].text == ( - "In FHIR, search is not performed directly on a resource (by " - "XML or JSON path), but on a named parameter that maps into " - "the resource content." - ) - assert inst.item[0].item[0].type == "display" - assert inst.item[0].item[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[1].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[1].linkId == "display.ID" - assert inst.item[0].item[1].text == ( - "A search parameter that defines a named search item that can" - " be used to search/filter on a resource." - ) - assert inst.item[0].item[1].type == "display" - assert inst.item[0].item[2].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[2].extension[0].valueInteger == 1 - assert inst.item[0].item[2].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[2].extension[1].valueString == "string" - assert inst.item[0].item[2].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[2].item[0].linkId == "display.ID" - assert inst.item[0].item[2].item[0].type == "display" - assert inst.item[0].item[2].item[1].linkId == "SearchParameter.id.value" - assert inst.item[0].item[2].item[1].repeats is False - assert inst.item[0].item[2].item[1].required is False - assert inst.item[0].item[2].item[1].text == "Logical id of this artifact" - assert inst.item[0].item[2].item[1].type == "string" - assert inst.item[0].item[2].linkId == "SearchParameter.id" - assert inst.item[0].item[2].repeats is True - assert inst.item[0].item[2].required is False - assert inst.item[0].item[2].type == "group" - assert inst.item[0].item[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[3].extension[0].valueInteger == 1 - assert inst.item[0].item[3].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[3].item[0].linkId == "display.ID" - assert inst.item[0].item[3].item[0].text == ( - "The metadata about the resource. This is content that is " - "maintained by the infrastructure. Changes to the content " - "might not always be associated with version changes to the " - "resource." - ) - assert inst.item[0].item[3].item[0].type == "display" - assert inst.item[0].item[3].linkId == "SearchParameter.meta" - assert inst.item[0].item[3].repeats is True - assert inst.item[0].item[3].required is False - assert inst.item[0].item[3].text == "Metadata about the resource" - assert inst.item[0].item[3].type == "group" - assert inst.item[0].item[4].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[4].extension[0].valueInteger == 1 - assert inst.item[0].item[4].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[4].extension[1].valueString == "uri" - assert inst.item[0].item[4].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[4].item[0].linkId == "display.ID" - assert inst.item[0].item[4].item[0].type == "display" - assert inst.item[0].item[4].item[1].linkId == "SearchParameter.implicitRules.value" - assert inst.item[0].item[4].item[1].repeats is False - assert inst.item[0].item[4].item[1].required is False - assert ( - inst.item[0].item[4].item[1].text - == "A set of rules under which this content was created" - ) - assert inst.item[0].item[4].item[1].type == "string" - assert inst.item[0].item[4].linkId == "SearchParameter.implicitRules" - assert inst.item[0].item[4].repeats is True - assert inst.item[0].item[4].required is False - assert inst.item[0].item[4].type == "group" - assert inst.item[0].item[5].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[5].extension[0].valueInteger == 1 - assert inst.item[0].item[5].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[5].extension[1].valueString == "code" - assert inst.item[0].item[5].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[5].item[0].linkId == "display.ID" - assert inst.item[0].item[5].item[0].type == "display" - assert inst.item[0].item[5].item[1].linkId == "SearchParameter.language.value" - assert inst.item[0].item[5].item[1].repeats is False - assert inst.item[0].item[5].item[1].required is False - assert inst.item[0].item[5].item[1].text == "language" - assert inst.item[0].item[5].item[1].type == "choice" - assert inst.item[0].item[5].linkId == "SearchParameter.language" - assert inst.item[0].item[5].repeats is True - assert inst.item[0].item[5].required is False - assert inst.item[0].item[5].type == "group" - assert inst.item[0].item[6].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[6].extension[0].valueInteger == 1 - assert inst.item[0].item[6].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[6].item[0].linkId == "display.ID" - assert inst.item[0].item[6].item[0].type == "display" - assert inst.item[0].item[6].linkId == "SearchParameter.text" - assert inst.item[0].item[6].repeats is True - assert inst.item[0].item[6].required is False - assert ( - inst.item[0].item[6].text - == "Text summary of the resource, for human interpretation" - ) - assert inst.item[0].item[6].type == "group" - assert inst.item[0].item[7].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[7].item[0].linkId == "display.ID" - assert inst.item[0].item[7].item[0].type == "display" - assert inst.item[0].item[7].linkId == "SearchParameter.contained" - assert inst.item[0].item[7].repeats is True - assert inst.item[0].item[7].required is False - assert inst.item[0].item[7].text == "Contained, inline Resources" - assert inst.item[0].item[7].type == "group" - assert inst.item[0].item[8].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[8].item[0].linkId == "display.ID" - assert inst.item[0].item[8].item[0].type == "display" - assert inst.item[0].item[8].linkId == "SearchParameter.extension" - assert inst.item[0].item[8].repeats is True - assert inst.item[0].item[8].required is False - assert inst.item[0].item[8].text == "Additional content defined by implementations" - assert inst.item[0].item[8].type == "group" - assert inst.item[0].item[9].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[9].item[0].linkId == "display.ID" - assert inst.item[0].item[9].item[0].type == "display" - assert inst.item[0].item[9].linkId == "SearchParameter.modifierExtension" - assert inst.item[0].item[9].repeats is True - assert inst.item[0].item[9].required is False - assert inst.item[0].item[9].text == "Extensions that cannot be ignored" - assert inst.item[0].item[9].type == "group" - assert inst.item[0].linkId == "SearchParameter" - assert inst.item[0].repeats is True - assert inst.item[0].required is False - assert inst.item[0].text == "Search parameter for a resource" - assert inst.item[0].type == "group" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "Health Level Seven International (FHIR Infrastructure)" - assert inst.status == "draft" - assert inst.version == "4.0.1" - - -def test_questionnaire_7(base_settings): - """No. 7 tests collection for Questionnaire. - Test File: searchparameter-questionnaire.json - """ - filename = base_settings["unittest_data_dir"] / "searchparameter-questionnaire.json" - inst = questionnaire.Questionnaire.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Questionnaire" == inst.resource_type - - impl_questionnaire_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Questionnaire" == data["resourceType"] - - inst2 = questionnaire.Questionnaire(**data) - impl_questionnaire_7(inst2) - - -def impl_questionnaire_8(inst): - assert inst.contained[0].id == "vs2" - assert inst.contained[1].id == "vs3" - assert inst.contained[2].id == "vs4" - assert inst.contained[3].id == "vs5" - assert inst.contained[4].id == "vs6" - assert inst.contained[5].id == "vs7" - assert inst.contained[6].id == "vs8" - assert inst.contained[7].id == "vs9" - assert inst.contained[8].id == "vs10" - assert inst.contained[9].id == "vs11" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.id == "qs1" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.item[0].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[0].linkId == "display.ID" - assert inst.item[0].item[0].text == ( - "This resource provides: the claim details; adjudication " - "details from the processing of a Claim; and optionally " - "account balance information, for informing the subscriber of" - " the benefits provided." - ) - assert inst.item[0].item[0].type == "display" - assert inst.item[0].item[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[1].extension[0].valueInteger == 1 - assert inst.item[0].item[1].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[1].extension[1].valueString == "string" - assert inst.item[0].item[1].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[1].item[0].linkId == "display.ID" - assert inst.item[0].item[1].item[0].type == "display" - assert inst.item[0].item[1].item[1].linkId == "ExplanationOfBenefit.id.value" - assert inst.item[0].item[1].item[1].repeats is False - assert inst.item[0].item[1].item[1].required is False - assert inst.item[0].item[1].item[1].text == "Logical id of this artifact" - assert inst.item[0].item[1].item[1].type == "string" - assert inst.item[0].item[1].linkId == "ExplanationOfBenefit.id" - assert inst.item[0].item[1].repeats is True - assert inst.item[0].item[1].required is False - assert inst.item[0].item[1].type == "group" - assert inst.item[0].item[2].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[2].extension[0].valueInteger == 1 - assert inst.item[0].item[2].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[2].item[0].linkId == "display.ID" - assert inst.item[0].item[2].item[0].text == ( - "The metadata about the resource. This is content that is " - "maintained by the infrastructure. Changes to the content " - "might not always be associated with version changes to the " - "resource." - ) - assert inst.item[0].item[2].item[0].type == "display" - assert inst.item[0].item[2].linkId == "ExplanationOfBenefit.meta" - assert inst.item[0].item[2].repeats is True - assert inst.item[0].item[2].required is False - assert inst.item[0].item[2].text == "Metadata about the resource" - assert inst.item[0].item[2].type == "group" - assert inst.item[0].item[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[3].extension[0].valueInteger == 1 - assert inst.item[0].item[3].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[3].extension[1].valueString == "uri" - assert inst.item[0].item[3].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[3].item[0].linkId == "display.ID" - assert inst.item[0].item[3].item[0].type == "display" - assert ( - inst.item[0].item[3].item[1].linkId - == "ExplanationOfBenefit.implicitRules.value" - ) - assert inst.item[0].item[3].item[1].repeats is False - assert inst.item[0].item[3].item[1].required is False - assert ( - inst.item[0].item[3].item[1].text - == "A set of rules under which this content was created" - ) - assert inst.item[0].item[3].item[1].type == "string" - assert inst.item[0].item[3].linkId == "ExplanationOfBenefit.implicitRules" - assert inst.item[0].item[3].repeats is True - assert inst.item[0].item[3].required is False - assert inst.item[0].item[3].type == "group" - assert inst.item[0].item[4].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[4].extension[0].valueInteger == 1 - assert inst.item[0].item[4].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[4].extension[1].valueString == "code" - assert inst.item[0].item[4].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[4].item[0].linkId == "display.ID" - assert inst.item[0].item[4].item[0].type == "display" - assert inst.item[0].item[4].item[1].linkId == "ExplanationOfBenefit.language.value" - assert inst.item[0].item[4].item[1].repeats is False - assert inst.item[0].item[4].item[1].required is False - assert inst.item[0].item[4].item[1].text == "language" - assert inst.item[0].item[4].item[1].type == "choice" - assert inst.item[0].item[4].linkId == "ExplanationOfBenefit.language" - assert inst.item[0].item[4].repeats is True - assert inst.item[0].item[4].required is False - assert inst.item[0].item[4].type == "group" - assert inst.item[0].item[5].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[5].extension[0].valueInteger == 1 - assert inst.item[0].item[5].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[5].item[0].linkId == "display.ID" - assert inst.item[0].item[5].item[0].type == "display" - assert inst.item[0].item[5].linkId == "ExplanationOfBenefit.text" - assert inst.item[0].item[5].repeats is True - assert inst.item[0].item[5].required is False - assert ( - inst.item[0].item[5].text - == "Text summary of the resource, for human interpretation" - ) - assert inst.item[0].item[5].type == "group" - assert inst.item[0].item[6].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[6].item[0].linkId == "display.ID" - assert inst.item[0].item[6].item[0].type == "display" - assert inst.item[0].item[6].linkId == "ExplanationOfBenefit.contained" - assert inst.item[0].item[6].repeats is True - assert inst.item[0].item[6].required is False - assert inst.item[0].item[6].text == "Contained, inline Resources" - assert inst.item[0].item[6].type == "group" - assert inst.item[0].item[7].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[7].item[0].linkId == "display.ID" - assert inst.item[0].item[7].item[0].type == "display" - assert inst.item[0].item[7].linkId == "ExplanationOfBenefit.extension" - assert inst.item[0].item[7].repeats is True - assert inst.item[0].item[7].required is False - assert inst.item[0].item[7].text == "Additional content defined by implementations" - assert inst.item[0].item[7].type == "group" - assert inst.item[0].item[8].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[8].item[0].linkId == "display.ID" - assert inst.item[0].item[8].item[0].type == "display" - assert inst.item[0].item[8].linkId == "ExplanationOfBenefit.modifierExtension" - assert inst.item[0].item[8].repeats is True - assert inst.item[0].item[8].required is False - assert inst.item[0].item[8].text == "Extensions that cannot be ignored" - assert inst.item[0].item[8].type == "group" - assert inst.item[0].item[9].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[9].extension[0].valueString == "Identifier" - assert inst.item[0].item[9].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[9].item[0].linkId == "display.ID" - assert ( - inst.item[0].item[9].item[0].text - == "A unique identifier assigned to this explanation of benefit." - ) - assert inst.item[0].item[9].item[0].type == "display" - assert ( - inst.item[0].item[9].item[1].linkId == "ExplanationOfBenefit.identifier.label" - ) - assert inst.item[0].item[9].item[1].repeats is False - assert inst.item[0].item[9].item[1].required is False - assert inst.item[0].item[9].item[1].text == "label:" - assert inst.item[0].item[9].item[1].type == "string" - assert ( - inst.item[0].item[9].item[2].linkId == "ExplanationOfBenefit.identifier.system" - ) - assert inst.item[0].item[9].item[2].repeats is False - assert inst.item[0].item[9].item[2].required is False - assert inst.item[0].item[9].item[2].text == "system:" - assert inst.item[0].item[9].item[2].type == "string" - assert ( - inst.item[0].item[9].item[3].linkId == "ExplanationOfBenefit.identifier.value" - ) - assert inst.item[0].item[9].item[3].repeats is False - assert inst.item[0].item[9].item[3].required is False - assert inst.item[0].item[9].item[3].text == "value:" - assert inst.item[0].item[9].item[3].type == "string" - assert inst.item[0].item[9].linkId == "ExplanationOfBenefit.identifier" - assert inst.item[0].item[9].repeats is True - assert inst.item[0].item[9].required is False - assert inst.item[0].item[9].text == "Business Identifier for the resource" - assert inst.item[0].item[9].type == "group" - assert inst.item[0].linkId == "ExplanationOfBenefit" - assert inst.item[0].repeats is True - assert inst.item[0].required is False - assert inst.item[0].text == "Explanation of Benefit resource" - assert inst.item[0].type == "group" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == "Health Level Seven International (Financial Management)" - assert inst.status == "draft" - assert inst.version == "4.0.1" - - -def test_questionnaire_8(base_settings): - """No. 8 tests collection for Questionnaire. - Test File: explanationofbenefit-questionnaire.json - """ - filename = ( - base_settings["unittest_data_dir"] / "explanationofbenefit-questionnaire.json" - ) - inst = questionnaire.Questionnaire.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Questionnaire" == inst.resource_type - - impl_questionnaire_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Questionnaire" == data["resourceType"] - - inst2 = questionnaire.Questionnaire(**data) - impl_questionnaire_8(inst2) - - -def impl_questionnaire_9(inst): - assert inst.contained[0].id == "vs2" - assert inst.contained[1].id == "vs3" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.id == "qs1" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.item[0].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[0].linkId == "fake.ID" - assert inst.item[0].item[0].text == ( - "Describes a comparison of an immunization event against " - "published recommendations to determine if the administration" - ' is "valid" in relation to those recommendations.' - ) - assert inst.item[0].item[0].type == "display" - assert inst.item[0].item[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[1].extension[0].valueInteger == 1 - assert inst.item[0].item[1].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[1].extension[1].valueString == "string" - assert inst.item[0].item[1].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[1].item[0].linkId == "fake.ID" - assert inst.item[0].item[1].item[0].type == "display" - assert inst.item[0].item[1].item[1].linkId == "ImmunizationEvaluation.id.value" - assert inst.item[0].item[1].item[1].repeats is False - assert inst.item[0].item[1].item[1].required is False - assert inst.item[0].item[1].item[1].text == "Logical id of this artifact" - assert inst.item[0].item[1].item[1].type == "string" - assert inst.item[0].item[1].linkId == "ImmunizationEvaluation.id" - assert inst.item[0].item[1].repeats is True - assert inst.item[0].item[1].required is False - assert inst.item[0].item[1].type == "group" - assert inst.item[0].item[2].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[2].extension[0].valueInteger == 1 - assert inst.item[0].item[2].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[2].item[0].linkId == "fake.ID" - assert inst.item[0].item[2].item[0].text == ( - "The metadata about the resource. This is content that is " - "maintained by the infrastructure. Changes to the content " - "might not always be associated with version changes to the " - "resource." - ) - assert inst.item[0].item[2].item[0].type == "display" - assert inst.item[0].item[2].linkId == "ImmunizationEvaluation.meta" - assert inst.item[0].item[2].repeats is True - assert inst.item[0].item[2].required is False - assert inst.item[0].item[2].text == "Metadata about the resource" - assert inst.item[0].item[2].type == "group" - assert inst.item[0].item[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[3].extension[0].valueInteger == 1 - assert inst.item[0].item[3].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[3].extension[1].valueString == "uri" - assert inst.item[0].item[3].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[3].item[0].linkId == "fake.ID" - assert inst.item[0].item[3].item[0].type == "display" - assert ( - inst.item[0].item[3].item[1].linkId - == "ImmunizationEvaluation.implicitRules.value" - ) - assert inst.item[0].item[3].item[1].repeats is False - assert inst.item[0].item[3].item[1].required is False - assert ( - inst.item[0].item[3].item[1].text - == "A set of rules under which this content was created" - ) - assert inst.item[0].item[3].item[1].type == "string" - assert inst.item[0].item[3].linkId == "ImmunizationEvaluation.implicitRules" - assert inst.item[0].item[3].repeats is True - assert inst.item[0].item[3].required is False - assert inst.item[0].item[3].type == "group" - assert inst.item[0].item[4].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[4].extension[0].valueInteger == 1 - assert inst.item[0].item[4].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[4].extension[1].valueString == "code" - assert inst.item[0].item[4].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[4].item[0].linkId == "fake.ID" - assert inst.item[0].item[4].item[0].type == "display" - assert ( - inst.item[0].item[4].item[1].linkId == "ImmunizationEvaluation.language.value" - ) - assert inst.item[0].item[4].item[1].repeats is False - assert inst.item[0].item[4].item[1].required is False - assert inst.item[0].item[4].item[1].text == "language" - assert inst.item[0].item[4].item[1].type == "choice" - assert inst.item[0].item[4].linkId == "ImmunizationEvaluation.language" - assert inst.item[0].item[4].repeats is True - assert inst.item[0].item[4].required is False - assert inst.item[0].item[4].type == "group" - assert inst.item[0].item[5].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[5].extension[0].valueInteger == 1 - assert inst.item[0].item[5].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[5].item[0].linkId == "fake.ID" - assert inst.item[0].item[5].item[0].type == "display" - assert inst.item[0].item[5].linkId == "ImmunizationEvaluation.text" - assert inst.item[0].item[5].repeats is True - assert inst.item[0].item[5].required is False - assert ( - inst.item[0].item[5].text - == "Text summary of the resource, for human interpretation" - ) - assert inst.item[0].item[5].type == "group" - assert inst.item[0].item[6].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[6].item[0].linkId == "fake.ID" - assert inst.item[0].item[6].item[0].type == "display" - assert inst.item[0].item[6].linkId == "ImmunizationEvaluation.contained" - assert inst.item[0].item[6].repeats is True - assert inst.item[0].item[6].required is False - assert inst.item[0].item[6].text == "Contained, inline Resources" - assert inst.item[0].item[6].type == "group" - assert inst.item[0].item[7].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[7].item[0].linkId == "fake.ID" - assert inst.item[0].item[7].item[0].type == "display" - assert inst.item[0].item[7].linkId == "ImmunizationEvaluation.extension" - assert inst.item[0].item[7].repeats is True - assert inst.item[0].item[7].required is False - assert inst.item[0].item[7].text == "Additional content defined by implementations" - assert inst.item[0].item[7].type == "group" - assert inst.item[0].item[8].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[8].item[0].linkId == "fake.ID" - assert inst.item[0].item[8].item[0].type == "display" - assert inst.item[0].item[8].linkId == "ImmunizationEvaluation.modifierExtension" - assert inst.item[0].item[8].repeats is True - assert inst.item[0].item[8].required is False - assert inst.item[0].item[8].text == "Extensions that cannot be ignored" - assert inst.item[0].item[8].type == "group" - assert inst.item[0].item[9].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[9].extension[0].valueString == "Identifier" - assert inst.item[0].item[9].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[9].item[0].linkId == "fake.ID" - assert inst.item[0].item[9].item[0].text == ( - "A unique identifier assigned to this immunization evaluation" " record." - ) - assert inst.item[0].item[9].item[0].type == "display" - assert ( - inst.item[0].item[9].item[1].linkId == "ImmunizationEvaluation.identifier.label" - ) - assert inst.item[0].item[9].item[1].repeats is False - assert inst.item[0].item[9].item[1].required is False - assert inst.item[0].item[9].item[1].text == "label:" - assert inst.item[0].item[9].item[1].type == "string" - assert ( - inst.item[0].item[9].item[2].linkId - == "ImmunizationEvaluation.identifier.system" - ) - assert inst.item[0].item[9].item[2].repeats is False - assert inst.item[0].item[9].item[2].required is False - assert inst.item[0].item[9].item[2].text == "system:" - assert inst.item[0].item[9].item[2].type == "string" - assert ( - inst.item[0].item[9].item[3].linkId == "ImmunizationEvaluation.identifier.value" - ) - assert inst.item[0].item[9].item[3].repeats is False - assert inst.item[0].item[9].item[3].required is False - assert inst.item[0].item[9].item[3].text == "value:" - assert inst.item[0].item[9].item[3].type == "string" - assert inst.item[0].item[9].linkId == "ImmunizationEvaluation.identifier" - assert inst.item[0].item[9].repeats is True - assert inst.item[0].item[9].required is False - assert inst.item[0].item[9].text == "Business identifier" - assert inst.item[0].item[9].type == "group" - assert inst.item[0].linkId == "ImmunizationEvaluation" - assert inst.item[0].repeats is True - assert inst.item[0].required is False - assert inst.item[0].text == "Immunization evaluation information" - assert inst.item[0].type == "group" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == ( - "Health Level Seven International (Public Health and " "Emergency Response)" - ) - assert inst.status == "draft" - assert inst.version == "4.0.1" - - -def test_questionnaire_9(base_settings): - """No. 9 tests collection for Questionnaire. - Test File: immunizationevaluation-questionnaire.json - """ - filename = ( - base_settings["unittest_data_dir"] / "immunizationevaluation-questionnaire.json" - ) - inst = questionnaire.Questionnaire.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Questionnaire" == inst.resource_type - - impl_questionnaire_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Questionnaire" == data["resourceType"] - - inst2 = questionnaire.Questionnaire(**data) - impl_questionnaire_9(inst2) - - -def impl_questionnaire_10(inst): - assert inst.contained[0].id == "vs2" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.id == "qs1" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.item[0].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[0].linkId == "fake.ID" - assert inst.item[0].item[0].text == "Indication for the Medicinal Product." - assert inst.item[0].item[0].type == "display" - assert inst.item[0].item[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[1].extension[0].valueInteger == 1 - assert inst.item[0].item[1].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[1].extension[1].valueString == "string" - assert inst.item[0].item[1].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[1].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[1].item[0].linkId == "fake.ID" - assert inst.item[0].item[1].item[0].type == "display" - assert inst.item[0].item[1].item[1].linkId == "MedicinalProductIndication.id.value" - assert inst.item[0].item[1].item[1].repeats is False - assert inst.item[0].item[1].item[1].required is False - assert inst.item[0].item[1].item[1].text == "Logical id of this artifact" - assert inst.item[0].item[1].item[1].type == "string" - assert inst.item[0].item[1].linkId == "MedicinalProductIndication.id" - assert inst.item[0].item[1].repeats is True - assert inst.item[0].item[1].required is False - assert inst.item[0].item[1].type == "group" - assert inst.item[0].item[2].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[2].extension[0].valueInteger == 1 - assert inst.item[0].item[2].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[2].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[2].item[0].linkId == "fake.ID" - assert inst.item[0].item[2].item[0].text == ( - "The metadata about the resource. This is content that is " - "maintained by the infrastructure. Changes to the content " - "might not always be associated with version changes to the " - "resource." - ) - assert inst.item[0].item[2].item[0].type == "display" - assert inst.item[0].item[2].linkId == "MedicinalProductIndication.meta" - assert inst.item[0].item[2].repeats is True - assert inst.item[0].item[2].required is False - assert inst.item[0].item[2].text == "Metadata about the resource" - assert inst.item[0].item[2].type == "group" - assert inst.item[0].item[3].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[3].extension[0].valueInteger == 1 - assert inst.item[0].item[3].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[3].extension[1].valueString == "uri" - assert inst.item[0].item[3].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[3].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[3].item[0].linkId == "fake.ID" - assert inst.item[0].item[3].item[0].type == "display" - assert ( - inst.item[0].item[3].item[1].linkId - == "MedicinalProductIndication.implicitRules.value" - ) - assert inst.item[0].item[3].item[1].repeats is False - assert inst.item[0].item[3].item[1].required is False - assert ( - inst.item[0].item[3].item[1].text - == "A set of rules under which this content was created" - ) - assert inst.item[0].item[3].item[1].type == "string" - assert inst.item[0].item[3].linkId == "MedicinalProductIndication.implicitRules" - assert inst.item[0].item[3].repeats is True - assert inst.item[0].item[3].required is False - assert inst.item[0].item[3].type == "group" - assert inst.item[0].item[4].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[4].extension[0].valueInteger == 1 - assert inst.item[0].item[4].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[4].extension[1].valueString == "code" - assert inst.item[0].item[4].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[4].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[4].item[0].linkId == "fake.ID" - assert inst.item[0].item[4].item[0].type == "display" - assert ( - inst.item[0].item[4].item[1].linkId - == "MedicinalProductIndication.language.value" - ) - assert inst.item[0].item[4].item[1].repeats is False - assert inst.item[0].item[4].item[1].required is False - assert inst.item[0].item[4].item[1].text == "language" - assert inst.item[0].item[4].item[1].type == "choice" - assert inst.item[0].item[4].linkId == "MedicinalProductIndication.language" - assert inst.item[0].item[4].repeats is True - assert inst.item[0].item[4].required is False - assert inst.item[0].item[4].type == "group" - assert inst.item[0].item[5].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "maxOccurs" - ) - assert inst.item[0].item[5].extension[0].valueInteger == 1 - assert inst.item[0].item[5].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[5].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[5].item[0].linkId == "fake.ID" - assert inst.item[0].item[5].item[0].type == "display" - assert inst.item[0].item[5].linkId == "MedicinalProductIndication.text" - assert inst.item[0].item[5].repeats is True - assert inst.item[0].item[5].required is False - assert ( - inst.item[0].item[5].text - == "Text summary of the resource, for human interpretation" - ) - assert inst.item[0].item[5].type == "group" - assert inst.item[0].item[6].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[6].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[6].item[0].linkId == "fake.ID" - assert inst.item[0].item[6].item[0].type == "display" - assert inst.item[0].item[6].linkId == "MedicinalProductIndication.contained" - assert inst.item[0].item[6].repeats is True - assert inst.item[0].item[6].required is False - assert inst.item[0].item[6].text == "Contained, inline Resources" - assert inst.item[0].item[6].type == "group" - assert inst.item[0].item[7].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[7].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[7].item[0].linkId == "fake.ID" - assert inst.item[0].item[7].item[0].type == "display" - assert inst.item[0].item[7].linkId == "MedicinalProductIndication.extension" - assert inst.item[0].item[7].repeats is True - assert inst.item[0].item[7].required is False - assert inst.item[0].item[7].text == "Additional content defined by implementations" - assert inst.item[0].item[7].type == "group" - assert inst.item[0].item[8].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[8].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[8].item[0].linkId == "fake.ID" - assert inst.item[0].item[8].item[0].type == "display" - assert inst.item[0].item[8].linkId == "MedicinalProductIndication.modifierExtension" - assert inst.item[0].item[8].repeats is True - assert inst.item[0].item[8].required is False - assert inst.item[0].item[8].text == "Extensions that cannot be ignored" - assert inst.item[0].item[8].type == "group" - assert inst.item[0].item[9].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "fhirType" - ) - assert inst.item[0].item[9].extension[0].valueString == "Reference" - assert inst.item[0].item[9].item[0].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "itemControl" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].code - == "flyover" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].display - == "Fly-over" - ) - assert ( - inst.item[0].item[9].item[0].extension[0].valueCodeableConcept.coding[0].system - == "http://hl7.org/fhir/questionnaire-item-control" - ) - assert inst.item[0].item[9].item[0].linkId == "fake.ID" - assert ( - inst.item[0].item[9].item[0].text - == "The medication for which this is an indication." - ) - assert inst.item[0].item[9].item[0].type == "display" - assert inst.item[0].item[9].item[1].extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "allowedResource" - ) - assert ( - inst.item[0].item[9].item[1].extension[0].valueCode - == "MedicinalProduct, Medication" - ) - assert inst.item[0].item[9].item[1].extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/questionnaire-" "referenceFilter" - ) - assert ( - inst.item[0].item[9].item[1].extension[1].valueString - == "subject=$subj&patient=$subj&encounter=$encounter" - ) - assert ( - inst.item[0].item[9].item[1].linkId - == "MedicinalProductIndication.subject.value" - ) - assert inst.item[0].item[9].item[1].repeats is False - assert inst.item[0].item[9].item[1].required is False - assert ( - inst.item[0].item[9].item[1].text - == "The medication for which this is an indication" - ) - assert inst.item[0].item[9].item[1].type == "reference" - assert inst.item[0].item[9].linkId == "MedicinalProductIndication.subject" - assert inst.item[0].item[9].repeats is True - assert inst.item[0].item[9].required is False - assert inst.item[0].item[9].type == "group" - assert inst.item[0].linkId == "MedicinalProductIndication" - assert inst.item[0].repeats is True - assert inst.item[0].required is False - assert inst.item[0].text == "MedicinalProductIndication" - assert inst.item[0].type == "group" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.publisher == ( - "Health Level Seven International (Biomedical Research and " "Regulation)" - ) - assert inst.status == "draft" - assert inst.version == "4.0.1" - - -def test_questionnaire_10(base_settings): - """No. 10 tests collection for Questionnaire. - Test File: medicinalproductindication-questionnaire.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "medicinalproductindication-questionnaire.json" - ) - inst = questionnaire.Questionnaire.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Questionnaire" == inst.resource_type - - impl_questionnaire_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Questionnaire" == data["resourceType"] - - inst2 = questionnaire.Questionnaire(**data) - impl_questionnaire_10(inst2) diff --git a/fhir/resources/tests/test_questionnaireresponse.py b/fhir/resources/tests/test_questionnaireresponse.py deleted file mode 100644 index b2ad9736..00000000 --- a/fhir/resources/tests/test_questionnaireresponse.py +++ /dev/null @@ -1,1756 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import questionnaireresponse - - -def impl_questionnaireresponse_1(inst): - assert inst.author.reference == "#questauth" - assert inst.authored == fhirtypes.DateTime.validate("2013-02-19T14:15:00-05:00") - assert inst.basedOn[0].reference == "#order" - assert inst.contained[0].id == "patsub" - assert inst.contained[1].id == "order" - assert inst.contained[2].id == "questauth" - assert inst.encounter.reference == "Encounter/example" - assert inst.id == "3141" - assert ( - inst.identifier.system - == "http://example.org/fhir/NamingSystem/questionnaire-ids" - ) - assert inst.identifier.value == "Q12349876" - assert ( - inst.item[0].item[0].answer[0].item[0].item[0].answer[0].valueCoding.code == "1" - ) - assert ( - inst.item[0].item[0].answer[0].item[0].item[0].answer[0].valueCoding.system - == "http://cancer.questionnaire.org/system/code/yesno" - ) - assert inst.item[0].item[0].answer[0].item[0].item[0].linkId == "1.1.1.1" - assert ( - inst.item[0].item[0].answer[0].item[0].item[1].answer[0].valueCoding.code == "1" - ) - assert ( - inst.item[0].item[0].answer[0].item[0].item[1].answer[0].valueCoding.system - == "http://cancer.questionnaire.org/system/code/yesno" - ) - assert inst.item[0].item[0].answer[0].item[0].item[1].linkId == "1.1.1.2" - assert ( - inst.item[0].item[0].answer[0].item[0].item[2].answer[0].valueCoding.code == "0" - ) - assert ( - inst.item[0].item[0].answer[0].item[0].item[2].answer[0].valueCoding.system - == "http://cancer.questionnaire.org/system/code/yesno" - ) - assert inst.item[0].item[0].answer[0].item[0].item[2].linkId == "1.1.1.3" - assert inst.item[0].item[0].answer[0].item[0].linkId == "1.1.1" - assert inst.item[0].item[0].answer[0].valueCoding.code == "1" - assert inst.item[0].item[0].answer[0].valueCoding.display == "Yes" - assert ( - inst.item[0].item[0].answer[0].valueCoding.system - == "http://cancer.questionnaire.org/system/code/yesno" - ) - assert inst.item[0].item[0].linkId == "1.1" - assert inst.item[0].linkId == "1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.partOf[0].reference == "Procedure/f201" - assert inst.status == "completed" - assert inst.subject.reference == "#patsub" - assert inst.text.status == "generated" - - -def test_questionnaireresponse_1(base_settings): - """No. 1 tests collection for QuestionnaireResponse. - Test File: questionnaireresponse-example.json - """ - filename = base_settings["unittest_data_dir"] / "questionnaireresponse-example.json" - inst = questionnaireresponse.QuestionnaireResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "QuestionnaireResponse" == inst.resource_type - - impl_questionnaireresponse_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "QuestionnaireResponse" == data["resourceType"] - - inst2 = questionnaireresponse.QuestionnaireResponse(**data) - impl_questionnaireresponse_1(inst2) - - -def impl_questionnaireresponse_2(inst): - assert inst.authored == fhirtypes.DateTime.validate("2008-01-17") - assert inst.id == "ussg-fht-answers" - assert inst.item[0].item[0].answer[0].valueDate == fhirtypes.Date.validate( - "2008-01-17" - ) - assert inst.item[0].item[0].linkId == "0.1" - assert inst.item[0].item[0].text == "Date Done" - assert inst.item[0].linkId == "0" - assert inst.item[1].definition == "http://loinc.org/fhir/DataElement/54126-8" - assert inst.item[1].item[0].item[0].answer[0].valueString == "Annie Proband" - assert ( - inst.item[1].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54125-0" - ) - assert inst.item[1].item[0].item[0].linkId == "1.1.1" - assert inst.item[1].item[0].item[0].text == "Name" - assert inst.item[1].item[0].item[1].answer[0].valueCoding.code == "LA3-6" - assert inst.item[1].item[0].item[1].answer[0].valueCoding.display == "Female" - assert ( - inst.item[1].item[0].item[1].answer[0].valueCoding.system == "http://loinc.org" - ) - assert ( - inst.item[1].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54131-8" - ) - assert inst.item[1].item[0].item[1].linkId == "1.1.2" - assert inst.item[1].item[0].item[1].text == "Gender" - assert inst.item[1].item[0].item[2].answer[0].valueDate == fhirtypes.Date.validate( - "1966-04-04" - ) - assert ( - inst.item[1].item[0].item[2].definition - == "http://loinc.org/fhir/DataElement/21112-8" - ) - assert inst.item[1].item[0].item[2].linkId == "1.1.3" - assert inst.item[1].item[0].item[2].text == "Date of Birth" - assert inst.item[1].item[0].item[3].answer[0].valueCoding.code == "LA32-8" - assert inst.item[1].item[0].item[3].answer[0].valueCoding.display == "No" - assert ( - inst.item[1].item[0].item[3].answer[0].valueCoding.system == "http://loinc.org" - ) - assert ( - inst.item[1].item[0].item[3].definition - == "http://loinc.org/fhir/DataElement/54132-6" - ) - assert inst.item[1].item[0].item[3].linkId == "1.1.4" - assert inst.item[1].item[0].item[3].text == "Were you born a twin?" - assert inst.item[1].item[0].item[4].answer[0].valueCoding.code == "LA32-8" - assert inst.item[1].item[0].item[4].answer[0].valueCoding.display == "No" - assert ( - inst.item[1].item[0].item[4].answer[0].valueCoding.system == "http://loinc.org" - ) - assert ( - inst.item[1].item[0].item[4].definition - == "http://loinc.org/fhir/DataElement/54128-4" - ) - assert inst.item[1].item[0].item[4].linkId == "1.1.5" - assert inst.item[1].item[0].item[4].text == "Were you adopted?" - assert inst.item[1].item[0].item[5].answer[0].valueCoding.code == "LA32-8" - assert inst.item[1].item[0].item[5].answer[0].valueCoding.display == "No" - assert ( - inst.item[1].item[0].item[5].answer[0].valueCoding.system == "http://loinc.org" - ) - assert ( - inst.item[1].item[0].item[5].definition - == "http://loinc.org/fhir/DataElement/54135-9" - ) - assert inst.item[1].item[0].item[5].linkId == "1.1.6" - assert inst.item[1].item[0].item[5].text == ( - "Are your parents related to each other in any way other than" " marriage?" - ) - assert ( - inst.item[1] - .item[0] - .item[6] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.code - == "[in_i]" - ) - assert ( - inst.item[1] - .item[0] - .item[6] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.display - == "inches" - ) - assert ( - inst.item[1] - .item[0] - .item[6] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.system - == "http://unitsofmeasure.org" - ) - assert inst.item[1].item[0].item[6].answer[0].item[0].item[0].linkId == "1.1.7.1.1" - assert inst.item[1].item[0].item[6].answer[0].item[0].item[0].text == "Units" - assert inst.item[1].item[0].item[6].answer[0].item[0].linkId == "1.1.7.1" - assert float(inst.item[1].item[0].item[6].answer[0].valueDecimal) == float(63) - assert ( - inst.item[1].item[0].item[6].definition - == "http://loinc.org/fhir/DataElement/8302-2" - ) - assert inst.item[1].item[0].item[6].linkId == "1.1.7" - assert inst.item[1].item[0].item[6].text == "Height" - assert ( - inst.item[1] - .item[0] - .item[7] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.code - == "[lb_av]" - ) - assert ( - inst.item[1] - .item[0] - .item[7] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.display - == "pounds" - ) - assert ( - inst.item[1] - .item[0] - .item[7] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.system - == "http://unitsofmeasure.org" - ) - assert inst.item[1].item[0].item[7].answer[0].item[0].item[0].linkId == "1.1.8.1.1" - assert inst.item[1].item[0].item[7].answer[0].item[0].item[0].text == "Units" - assert inst.item[1].item[0].item[7].answer[0].item[0].linkId == "1.1.8.1" - assert float(inst.item[1].item[0].item[7].answer[0].valueDecimal) == float(127) - assert ( - inst.item[1].item[0].item[7].definition - == "http://loinc.org/fhir/DataElement/29463-7" - ) - assert inst.item[1].item[0].item[7].linkId == "1.1.8" - assert inst.item[1].item[0].item[7].text == "Weight" - assert float(inst.item[1].item[0].item[8].answer[0].valueDecimal) == float(22.5) - assert ( - inst.item[1].item[0].item[8].definition - == "http://loinc.org/fhir/DataElement/39156-5" - ) - assert inst.item[1].item[0].item[8].linkId == "1.1.9" - assert inst.item[1].item[0].item[8].text == "Body mass index (BMI) [Ratio]" - assert inst.item[1].item[0].item[9].answer[0].valueCoding.code == "LA4457-3" - assert inst.item[1].item[0].item[9].answer[0].valueCoding.display == "White" - assert ( - inst.item[1].item[0].item[9].answer[0].valueCoding.system == "http://loinc.org" - ) - assert ( - inst.item[1].item[0].item[9].definition - == "http://loinc.org/fhir/DataElement/54134-2" - ) - assert inst.item[1].item[0].item[9].linkId == "1.1.10" - assert inst.item[1].item[0].item[9].text == "Race" - assert inst.item[1].item[0].linkId == "1.1" - assert inst.item[1].linkId == "1" - assert inst.item[1].text == "Your health information" - assert inst.item[2].definition == "http://loinc.org/fhir/DataElement/54114-4" - assert inst.item[2].item[0].item[0].answer[0].valueCoding.code == "LA10405-1" - assert inst.item[2].item[0].item[0].answer[0].valueCoding.display == "Daughter" - assert ( - inst.item[2].item[0].item[0].answer[0].valueCoding.system == "http://loinc.org" - ) - assert ( - inst.item[2].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54136-7" - ) - assert inst.item[2].item[0].item[0].linkId == "2.1.1.1" - assert inst.item[2].item[0].item[0].text == "Relationship to you" - assert inst.item[2].item[0].item[1].answer[0].valueString == "Susan" - assert ( - inst.item[2].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54138-3" - ) - assert inst.item[2].item[0].item[1].linkId == "2.1.1.2" - assert inst.item[2].item[0].item[1].text == "Name" - assert inst.item[2].item[0].item[2].answer[0].valueCoding.code == "LA3-6" - assert inst.item[2].item[0].item[2].answer[0].valueCoding.display == "Female" - assert ( - inst.item[2].item[0].item[2].answer[0].valueCoding.system == "http://loinc.org" - ) - assert ( - inst.item[2].item[0].item[2].definition - == "http://loinc.org/fhir/DataElement/54123-5" - ) - assert inst.item[2].item[0].item[2].linkId == "2.1.1.3" - assert inst.item[2].item[0].item[2].text == "Gender" - assert float( - inst.item[2].item[0].item[3].answer[0].item[0].item[0].answer[0].valueDecimal - ) == float(17) - assert ( - inst.item[2].item[0].item[3].answer[0].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54141-7" - ) - assert ( - inst.item[2].item[0].item[3].answer[0].item[0].item[0].linkId == "2.1.1.4.2.2" - ) - assert inst.item[2].item[0].item[3].answer[0].item[0].item[0].text == "Age" - assert inst.item[2].item[0].item[3].answer[0].item[0].linkId == "2.1.1.4.2" - assert inst.item[2].item[0].item[3].answer[0].valueCoding.code == "LA33-6" - assert inst.item[2].item[0].item[3].answer[0].valueCoding.display == "Yes" - assert ( - inst.item[2].item[0].item[3].answer[0].valueCoding.system == "http://loinc.org" - ) - assert ( - inst.item[2].item[0].item[3].definition - == "http://loinc.org/fhir/DataElement/54139-1" - ) - assert inst.item[2].item[0].item[3].linkId == "2.1.1.4" - assert inst.item[2].item[0].item[3].text == "Living?" - assert inst.item[2].item[0].item[4].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[0].item[4].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[0].item[4].answer[0].valueCoding.system == "http://loinc.org" - ) - assert ( - inst.item[2].item[0].item[4].definition - == "http://loinc.org/fhir/DataElement/54121-9" - ) - assert inst.item[2].item[0].item[4].linkId == "2.1.1.5" - assert inst.item[2].item[0].item[4].text == "Was this person born a twin?" - assert inst.item[2].item[0].item[5].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[0].item[5].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[0].item[5].answer[0].valueCoding.system == "http://loinc.org" - ) - assert ( - inst.item[2].item[0].item[5].definition - == "http://loinc.org/fhir/DataElement/54122-7" - ) - assert inst.item[2].item[0].item[5].linkId == "2.1.1.6" - assert inst.item[2].item[0].item[5].text == "Was this person adopted?" - assert inst.item[2].item[0].linkId == "2.1" - assert ( - inst.item[2].item[1].item[0].item[0].answer[0].valueCoding.code == "LA10415-0" - ) - assert ( - inst.item[2].item[1].item[0].item[0].answer[0].valueCoding.display == "Brother" - ) - assert ( - inst.item[2].item[1].item[0].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[1].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54136-7" - ) - assert inst.item[2].item[1].item[0].item[0].linkId == "2.1.1.1" - assert inst.item[2].item[1].item[0].item[0].text == "Relationship to you" - assert inst.item[2].item[1].item[0].item[1].answer[0].valueString == "Brian" - assert ( - inst.item[2].item[1].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54138-3" - ) - assert inst.item[2].item[1].item[0].item[1].linkId == "2.1.1.2" - assert inst.item[2].item[1].item[0].item[1].text == "Name" - assert inst.item[2].item[1].item[0].item[2].answer[0].valueCoding.code == "LA2-8" - assert inst.item[2].item[1].item[0].item[2].answer[0].valueCoding.display == "Male" - assert ( - inst.item[2].item[1].item[0].item[2].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[1].item[0].item[2].definition - == "http://loinc.org/fhir/DataElement/54123-5" - ) - assert inst.item[2].item[1].item[0].item[2].linkId == "2.1.1.3" - assert inst.item[2].item[1].item[0].item[2].text == "Gender" - assert float( - inst.item[2] - .item[1] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueDecimal - ) == float(32) - assert ( - inst.item[2].item[1].item[0].item[3].answer[0].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54141-7" - ) - assert ( - inst.item[2].item[1].item[0].item[3].answer[0].item[0].item[0].linkId - == "2.1.1.4.2.2" - ) - assert inst.item[2].item[1].item[0].item[3].answer[0].item[0].item[0].text == "Age" - assert inst.item[2].item[1].item[0].item[3].answer[0].item[0].linkId == "2.1.1.4.2" - assert inst.item[2].item[1].item[0].item[3].answer[0].valueCoding.code == "LA33-6" - assert inst.item[2].item[1].item[0].item[3].answer[0].valueCoding.display == "Yes" - assert ( - inst.item[2].item[1].item[0].item[3].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[1].item[0].item[3].definition - == "http://loinc.org/fhir/DataElement/54139-1" - ) - assert inst.item[2].item[1].item[0].item[3].linkId == "2.1.1.4" - assert inst.item[2].item[1].item[0].item[3].text == "Living?" - assert inst.item[2].item[1].item[0].item[4].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[1].item[0].item[4].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[1].item[0].item[4].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[1].item[0].item[4].definition - == "http://loinc.org/fhir/DataElement/54121-9" - ) - assert inst.item[2].item[1].item[0].item[4].linkId == "2.1.1.5" - assert inst.item[2].item[1].item[0].item[4].text == "Was this person born a twin?" - assert inst.item[2].item[1].item[0].item[5].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[1].item[0].item[5].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[1].item[0].item[5].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[1].item[0].item[5].definition - == "http://loinc.org/fhir/DataElement/54122-7" - ) - assert inst.item[2].item[1].item[0].item[5].linkId == "2.1.1.6" - assert inst.item[2].item[1].item[0].item[5].text == "Was this person adopted?" - assert inst.item[2].item[1].item[0].linkId == "2.1.1" - assert ( - inst.item[2].item[1].item[1].item[0].answer[0].valueCoding.code == "LA10550-4" - ) - assert ( - inst.item[2].item[1].item[1].item[0].answer[0].valueCoding.display - == "-- Other Cancer" - ) - assert ( - inst.item[2].item[1].item[1].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert inst.item[2].item[1].item[1].item[0].linkId == "2.1.2.1" - assert inst.item[2].item[1].item[1].item[0].text == "Disease or Condition" - assert ( - inst.item[2].item[1].item[1].item[1].answer[0].valueCoding.code == "LA10397-0" - ) - assert inst.item[2].item[1].item[1].item[1].answer[0].valueCoding.display == "30-39" - assert ( - inst.item[2].item[1].item[1].item[1].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert inst.item[2].item[1].item[1].item[1].linkId == "2.1.2.2" - assert inst.item[2].item[1].item[1].item[1].text == "Age at Diagnosis" - assert inst.item[2].item[1].item[1].linkId == "2.1.2" - assert ( - inst.item[2].item[1].item[1].text == "This family member's history of disease" - ) - assert inst.item[2].item[1].linkId == "2.1" - assert ( - inst.item[2].item[2].item[0].item[0].answer[0].valueCoding.code == "LA10418-4" - ) - assert ( - inst.item[2].item[2].item[0].item[0].answer[0].valueCoding.display == "Sister" - ) - assert ( - inst.item[2].item[2].item[0].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[2].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54136-7" - ) - assert inst.item[2].item[2].item[0].item[0].linkId == "2.1.1.1" - assert inst.item[2].item[2].item[0].item[0].text == "Relationship to you" - assert inst.item[2].item[2].item[0].item[1].answer[0].valueString == "Janet" - assert ( - inst.item[2].item[2].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54138-3" - ) - assert inst.item[2].item[2].item[0].item[1].linkId == "2.1.1.2" - assert inst.item[2].item[2].item[0].item[1].text == "Name" - assert inst.item[2].item[2].item[0].item[2].answer[0].valueCoding.code == "LA3-6" - assert ( - inst.item[2].item[2].item[0].item[2].answer[0].valueCoding.display == "Female" - ) - assert ( - inst.item[2].item[2].item[0].item[2].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[2].item[0].item[2].definition - == "http://loinc.org/fhir/DataElement/54123-5" - ) - assert inst.item[2].item[2].item[0].item[2].linkId == "2.1.1.3" - assert inst.item[2].item[2].item[0].item[2].text == "Gender" - assert float( - inst.item[2] - .item[2] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueDecimal - ) == float(36) - assert ( - inst.item[2].item[2].item[0].item[3].answer[0].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54141-7" - ) - assert ( - inst.item[2].item[2].item[0].item[3].answer[0].item[0].item[0].linkId - == "2.1.1.4.2.2" - ) - assert inst.item[2].item[2].item[0].item[3].answer[0].item[0].item[0].text == "Age" - assert inst.item[2].item[2].item[0].item[3].answer[0].item[0].linkId == "2.1.1.4.2" - assert inst.item[2].item[2].item[0].item[3].answer[0].valueCoding.code == "LA33-6" - assert inst.item[2].item[2].item[0].item[3].answer[0].valueCoding.display == "Yes" - assert ( - inst.item[2].item[2].item[0].item[3].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[2].item[0].item[3].definition - == "http://loinc.org/fhir/DataElement/54139-1" - ) - assert inst.item[2].item[2].item[0].item[3].linkId == "2.1.1.4" - assert inst.item[2].item[2].item[0].item[3].text == "Living?" - assert inst.item[2].item[2].item[0].item[4].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[2].item[0].item[4].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[2].item[0].item[4].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[2].item[0].item[4].definition - == "http://loinc.org/fhir/DataElement/54121-9" - ) - assert inst.item[2].item[2].item[0].item[4].linkId == "2.1.1.5" - assert inst.item[2].item[2].item[0].item[4].text == "Was this person born a twin?" - assert inst.item[2].item[2].item[0].item[5].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[2].item[0].item[5].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[2].item[0].item[5].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[2].item[0].item[5].definition - == "http://loinc.org/fhir/DataElement/54122-7" - ) - assert inst.item[2].item[2].item[0].item[5].linkId == "2.1.1.6" - assert inst.item[2].item[2].item[0].item[5].text == "Was this person adopted?" - assert inst.item[2].item[2].item[0].linkId == "2.1.1" - assert ( - inst.item[2].item[2].item[1].item[0].answer[0].valueCoding.code == "LA10536-3" - ) - assert ( - inst.item[2].item[2].item[1].item[0].answer[0].valueCoding.display - == "-- Breast Cancer" - ) - assert ( - inst.item[2].item[2].item[1].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert inst.item[2].item[2].item[1].item[0].linkId == "2.1.2.1" - assert inst.item[2].item[2].item[1].item[0].text == "Disease or Condition" - assert ( - inst.item[2].item[2].item[1].item[1].answer[0].valueCoding.code == "LA10397-0" - ) - assert inst.item[2].item[2].item[1].item[1].answer[0].valueCoding.display == "30-39" - assert ( - inst.item[2].item[2].item[1].item[1].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert inst.item[2].item[2].item[1].item[1].linkId == "2.1.2.2" - assert inst.item[2].item[2].item[1].item[1].text == "Age at Diagnosis" - assert inst.item[2].item[2].item[1].linkId == "2.1.2" - assert ( - inst.item[2].item[2].item[1].text == "This family member's history of disease" - ) - assert inst.item[2].item[2].linkId == "2.1" - assert ( - inst.item[2].item[3].item[0].item[0].answer[0].valueCoding.code == "LA10419-2" - ) - assert ( - inst.item[2].item[3].item[0].item[0].answer[0].valueCoding.display == "Nephew" - ) - assert ( - inst.item[2].item[3].item[0].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[3].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54136-7" - ) - assert inst.item[2].item[3].item[0].item[0].linkId == "2.1.1.1" - assert inst.item[2].item[3].item[0].item[0].text == "Relationship to you" - assert inst.item[2].item[3].item[0].item[1].answer[0].valueString == "Ian" - assert ( - inst.item[2].item[3].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54138-3" - ) - assert inst.item[2].item[3].item[0].item[1].linkId == "2.1.1.2" - assert inst.item[2].item[3].item[0].item[1].text == "Name" - assert inst.item[2].item[3].item[0].item[2].answer[0].valueCoding.code == "LA2-8" - assert inst.item[2].item[3].item[0].item[2].answer[0].valueCoding.display == "Male" - assert ( - inst.item[2].item[3].item[0].item[2].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[3].item[0].item[2].definition - == "http://loinc.org/fhir/DataElement/54123-5" - ) - assert inst.item[2].item[3].item[0].item[2].linkId == "2.1.1.3" - assert inst.item[2].item[3].item[0].item[2].text == "Gender" - assert float( - inst.item[2] - .item[3] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueDecimal - ) == float(16) - assert ( - inst.item[2].item[3].item[0].item[3].answer[0].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54141-7" - ) - assert ( - inst.item[2].item[3].item[0].item[3].answer[0].item[0].item[0].linkId - == "2.1.1.4.2.2" - ) - assert inst.item[2].item[3].item[0].item[3].answer[0].item[0].item[0].text == "Age" - assert inst.item[2].item[3].item[0].item[3].answer[0].item[0].linkId == "2.1.1.4.2" - assert inst.item[2].item[3].item[0].item[3].answer[0].valueCoding.code == "LA33-6" - assert inst.item[2].item[3].item[0].item[3].answer[0].valueCoding.display == "Yes" - assert ( - inst.item[2].item[3].item[0].item[3].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[3].item[0].item[3].definition - == "http://loinc.org/fhir/DataElement/54139-1" - ) - assert inst.item[2].item[3].item[0].item[3].linkId == "2.1.1.4" - assert inst.item[2].item[3].item[0].item[3].text == "Living?" - assert inst.item[2].item[3].item[0].item[4].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[3].item[0].item[4].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[3].item[0].item[4].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[3].item[0].item[4].definition - == "http://loinc.org/fhir/DataElement/54121-9" - ) - assert inst.item[2].item[3].item[0].item[4].linkId == "2.1.1.5" - assert inst.item[2].item[3].item[0].item[4].text == "Was this person born a twin?" - assert inst.item[2].item[3].item[0].item[5].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[3].item[0].item[5].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[3].item[0].item[5].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[3].item[0].item[5].definition - == "http://loinc.org/fhir/DataElement/54122-7" - ) - assert inst.item[2].item[3].item[0].item[5].linkId == "2.1.1.6" - assert inst.item[2].item[3].item[0].item[5].text == "Was this person adopted?" - assert inst.item[2].item[3].item[0].linkId == "2.1.1" - assert inst.item[2].item[3].linkId == "2.1" - assert ( - inst.item[2].item[4].item[0].item[0].answer[0].valueCoding.code == "LA10420-0" - ) - assert inst.item[2].item[4].item[0].item[0].answer[0].valueCoding.display == "Niece" - assert ( - inst.item[2].item[4].item[0].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[4].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54136-7" - ) - assert inst.item[2].item[4].item[0].item[0].linkId == "2.1.1.1" - assert inst.item[2].item[4].item[0].item[0].text == "Relationship to you" - assert inst.item[2].item[4].item[0].item[1].answer[0].valueString == "Helen" - assert ( - inst.item[2].item[4].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54138-3" - ) - assert inst.item[2].item[4].item[0].item[1].linkId == "2.1.1.2" - assert inst.item[2].item[4].item[0].item[1].text == "Name" - assert inst.item[2].item[4].item[0].item[2].answer[0].valueCoding.code == "LA3-6" - assert ( - inst.item[2].item[4].item[0].item[2].answer[0].valueCoding.display == "Female" - ) - assert ( - inst.item[2].item[4].item[0].item[2].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[4].item[0].item[2].definition - == "http://loinc.org/fhir/DataElement/54123-5" - ) - assert inst.item[2].item[4].item[0].item[2].linkId == "2.1.1.3" - assert inst.item[2].item[4].item[0].item[2].text == "Gender" - assert float( - inst.item[2] - .item[4] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueDecimal - ) == float(15) - assert ( - inst.item[2].item[4].item[0].item[3].answer[0].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54141-7" - ) - assert ( - inst.item[2].item[4].item[0].item[3].answer[0].item[0].item[0].linkId - == "2.1.1.4.2.2" - ) - assert inst.item[2].item[4].item[0].item[3].answer[0].item[0].item[0].text == "Age" - assert inst.item[2].item[4].item[0].item[3].answer[0].item[0].linkId == "2.1.1.4.2" - assert inst.item[2].item[4].item[0].item[3].answer[0].valueCoding.code == "LA33-6" - assert inst.item[2].item[4].item[0].item[3].answer[0].valueCoding.display == "Yes" - assert ( - inst.item[2].item[4].item[0].item[3].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[4].item[0].item[3].definition - == "http://loinc.org/fhir/DataElement/54139-1" - ) - assert inst.item[2].item[4].item[0].item[3].linkId == "2.1.1.4" - assert inst.item[2].item[4].item[0].item[3].text == "Living?" - assert inst.item[2].item[4].item[0].item[4].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[4].item[0].item[4].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[4].item[0].item[4].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[4].item[0].item[4].definition - == "http://loinc.org/fhir/DataElement/54121-9" - ) - assert inst.item[2].item[4].item[0].item[4].linkId == "2.1.1.5" - assert inst.item[2].item[4].item[0].item[4].text == "Was this person born a twin?" - assert inst.item[2].item[4].item[0].item[5].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[4].item[0].item[5].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[4].item[0].item[5].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[4].item[0].item[5].definition - == "http://loinc.org/fhir/DataElement/54122-7" - ) - assert inst.item[2].item[4].item[0].item[5].linkId == "2.1.1.6" - assert inst.item[2].item[4].item[0].item[5].text == "Was this person adopted?" - assert inst.item[2].item[4].item[0].linkId == "2.1.1" - assert inst.item[2].item[4].linkId == "2.1" - assert ( - inst.item[2].item[5].item[0].item[0].answer[0].valueCoding.code == "LA10416-8" - ) - assert ( - inst.item[2].item[5].item[0].item[0].answer[0].valueCoding.display == "Father" - ) - assert ( - inst.item[2].item[5].item[0].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[5].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54136-7" - ) - assert inst.item[2].item[5].item[0].item[0].linkId == "2.1.1.1" - assert inst.item[2].item[5].item[0].item[0].text == "Relationship to you" - assert inst.item[2].item[5].item[0].item[1].answer[0].valueString == "Donald" - assert ( - inst.item[2].item[5].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54138-3" - ) - assert inst.item[2].item[5].item[0].item[1].linkId == "2.1.1.2" - assert inst.item[2].item[5].item[0].item[1].text == "Name" - assert inst.item[2].item[5].item[0].item[2].answer[0].valueCoding.code == "LA2-8" - assert inst.item[2].item[5].item[0].item[2].answer[0].valueCoding.display == "Male" - assert ( - inst.item[2].item[5].item[0].item[2].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[5].item[0].item[2].definition - == "http://loinc.org/fhir/DataElement/54123-5" - ) - assert inst.item[2].item[5].item[0].item[2].linkId == "2.1.1.3" - assert inst.item[2].item[5].item[0].item[2].text == "Gender" - assert float( - inst.item[2] - .item[5] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueDecimal - ) == float(52) - assert ( - inst.item[2].item[5].item[0].item[3].answer[0].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54141-7" - ) - assert ( - inst.item[2].item[5].item[0].item[3].answer[0].item[0].item[0].linkId - == "2.1.1.4.2.2" - ) - assert inst.item[2].item[5].item[0].item[3].answer[0].item[0].item[0].text == "Age" - assert inst.item[2].item[5].item[0].item[3].answer[0].item[0].linkId == "2.1.1.4.2" - assert inst.item[2].item[5].item[0].item[3].answer[0].valueCoding.code == "LA33-6" - assert inst.item[2].item[5].item[0].item[3].answer[0].valueCoding.display == "Yes" - assert ( - inst.item[2].item[5].item[0].item[3].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[5].item[0].item[3].definition - == "http://loinc.org/fhir/DataElement/54139-1" - ) - assert inst.item[2].item[5].item[0].item[3].linkId == "2.1.1.4" - assert inst.item[2].item[5].item[0].item[3].text == "Living?" - assert inst.item[2].item[5].item[0].item[4].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[5].item[0].item[4].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[5].item[0].item[4].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[5].item[0].item[4].definition - == "http://loinc.org/fhir/DataElement/54121-9" - ) - assert inst.item[2].item[5].item[0].item[4].linkId == "2.1.1.5" - assert inst.item[2].item[5].item[0].item[4].text == "Was this person born a twin?" - assert inst.item[2].item[5].item[0].item[5].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[5].item[0].item[5].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[5].item[0].item[5].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[5].item[0].item[5].definition - == "http://loinc.org/fhir/DataElement/54122-7" - ) - assert inst.item[2].item[5].item[0].item[5].linkId == "2.1.1.6" - assert inst.item[2].item[5].item[0].item[5].text == "Was this person adopted?" - assert inst.item[2].item[5].item[0].linkId == "2.1.1" - assert inst.item[2].item[5].linkId == "2.1" - assert ( - inst.item[2].item[6].item[0].item[0].answer[0].valueCoding.code == "LA10425-9" - ) - assert ( - inst.item[2].item[6].item[0].item[0].answer[0].valueCoding.display - == "Paternal Uncle" - ) - assert ( - inst.item[2].item[6].item[0].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[6].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54136-7" - ) - assert inst.item[2].item[6].item[0].item[0].linkId == "2.1.1.1" - assert inst.item[2].item[6].item[0].item[0].text == "Relationship to you" - assert inst.item[2].item[6].item[0].item[1].answer[0].valueString == "Eric" - assert ( - inst.item[2].item[6].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54138-3" - ) - assert inst.item[2].item[6].item[0].item[1].linkId == "2.1.1.2" - assert inst.item[2].item[6].item[0].item[1].text == "Name" - assert inst.item[2].item[6].item[0].item[2].answer[0].valueCoding.code == "LA2-8" - assert inst.item[2].item[6].item[0].item[2].answer[0].valueCoding.display == "Male" - assert ( - inst.item[2].item[6].item[0].item[2].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[6].item[0].item[2].definition - == "http://loinc.org/fhir/DataElement/54123-5" - ) - assert inst.item[2].item[6].item[0].item[2].linkId == "2.1.1.3" - assert inst.item[2].item[6].item[0].item[2].text == "Gender" - assert float( - inst.item[2] - .item[6] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueDecimal - ) == float(56) - assert ( - inst.item[2].item[6].item[0].item[3].answer[0].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54141-7" - ) - assert ( - inst.item[2].item[6].item[0].item[3].answer[0].item[0].item[0].linkId - == "2.1.1.4.2.2" - ) - assert inst.item[2].item[6].item[0].item[3].answer[0].item[0].item[0].text == "Age" - assert inst.item[2].item[6].item[0].item[3].answer[0].item[0].linkId == "2.1.1.4.2" - assert inst.item[2].item[6].item[0].item[3].answer[0].valueCoding.code == "LA33-6" - assert inst.item[2].item[6].item[0].item[3].answer[0].valueCoding.display == "Yes" - assert ( - inst.item[2].item[6].item[0].item[3].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[6].item[0].item[3].definition - == "http://loinc.org/fhir/DataElement/54139-1" - ) - assert inst.item[2].item[6].item[0].item[3].linkId == "2.1.1.4" - assert inst.item[2].item[6].item[0].item[3].text == "Living?" - assert inst.item[2].item[6].item[0].item[4].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[6].item[0].item[4].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[6].item[0].item[4].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[6].item[0].item[4].definition - == "http://loinc.org/fhir/DataElement/54121-9" - ) - assert inst.item[2].item[6].item[0].item[4].linkId == "2.1.1.5" - assert inst.item[2].item[6].item[0].item[4].text == "Was this person born a twin?" - assert inst.item[2].item[6].item[0].item[5].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[6].item[0].item[5].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[6].item[0].item[5].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[6].item[0].item[5].definition - == "http://loinc.org/fhir/DataElement/54122-7" - ) - assert inst.item[2].item[6].item[0].item[5].linkId == "2.1.1.6" - assert inst.item[2].item[6].item[0].item[5].text == "Was this person adopted?" - assert inst.item[2].item[6].item[0].linkId == "2.1.1" - assert inst.item[2].item[6].linkId == "2.1" - assert ( - inst.item[2].item[7].item[0].item[0].answer[0].valueCoding.code == "LA10421-8" - ) - assert ( - inst.item[2].item[7].item[0].item[0].answer[0].valueCoding.display - == "Paternal Aunt" - ) - assert ( - inst.item[2].item[7].item[0].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[7].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54136-7" - ) - assert inst.item[2].item[7].item[0].item[0].linkId == "2.1.1.1" - assert inst.item[2].item[7].item[0].item[0].text == "Relationship to you" - assert inst.item[2].item[7].item[0].item[1].answer[0].valueString == "Fiona" - assert ( - inst.item[2].item[7].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54138-3" - ) - assert inst.item[2].item[7].item[0].item[1].linkId == "2.1.1.2" - assert inst.item[2].item[7].item[0].item[1].text == "Name" - assert inst.item[2].item[7].item[0].item[2].answer[0].valueCoding.code == "LA3-6" - assert ( - inst.item[2].item[7].item[0].item[2].answer[0].valueCoding.display == "Female" - ) - assert ( - inst.item[2].item[7].item[0].item[2].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[7].item[0].item[2].definition - == "http://loinc.org/fhir/DataElement/54123-5" - ) - assert inst.item[2].item[7].item[0].item[2].linkId == "2.1.1.3" - assert inst.item[2].item[7].item[0].item[2].text == "Gender" - assert float( - inst.item[2] - .item[7] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueDecimal - ) == float(57) - assert ( - inst.item[2].item[7].item[0].item[3].answer[0].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54141-7" - ) - assert ( - inst.item[2].item[7].item[0].item[3].answer[0].item[0].item[0].linkId - == "2.1.1.4.2.2" - ) - assert inst.item[2].item[7].item[0].item[3].answer[0].item[0].item[0].text == "Age" - assert inst.item[2].item[7].item[0].item[3].answer[0].item[0].linkId == "2.1.1.4.2" - assert inst.item[2].item[7].item[0].item[3].answer[0].valueCoding.code == "LA33-6" - assert inst.item[2].item[7].item[0].item[3].answer[0].valueCoding.display == "Yes" - assert ( - inst.item[2].item[7].item[0].item[3].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[7].item[0].item[3].definition - == "http://loinc.org/fhir/DataElement/54139-1" - ) - assert inst.item[2].item[7].item[0].item[3].linkId == "2.1.1.4" - assert inst.item[2].item[7].item[0].item[3].text == "Living?" - assert inst.item[2].item[7].item[0].item[4].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[7].item[0].item[4].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[7].item[0].item[4].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[7].item[0].item[4].definition - == "http://loinc.org/fhir/DataElement/54121-9" - ) - assert inst.item[2].item[7].item[0].item[4].linkId == "2.1.1.5" - assert inst.item[2].item[7].item[0].item[4].text == "Was this person born a twin?" - assert inst.item[2].item[7].item[0].item[5].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[7].item[0].item[5].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[7].item[0].item[5].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[7].item[0].item[5].definition - == "http://loinc.org/fhir/DataElement/54122-7" - ) - assert inst.item[2].item[7].item[0].item[5].linkId == "2.1.1.6" - assert inst.item[2].item[7].item[0].item[5].text == "Was this person adopted?" - assert inst.item[2].item[7].item[0].linkId == "2.1.1" - assert ( - inst.item[2].item[7].item[1].item[0].answer[0].valueCoding.code == "LA10543-9" - ) - assert ( - inst.item[2].item[7].item[1].item[0].answer[0].valueCoding.display - == "-- Skin Cancer" - ) - assert ( - inst.item[2].item[7].item[1].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert inst.item[2].item[7].item[1].item[0].linkId == "2.1.2.1" - assert inst.item[2].item[7].item[1].item[0].text == "Disease or Condition" - assert inst.item[2].item[7].item[1].linkId == "2.1.2" - assert ( - inst.item[2].item[7].item[1].text == "This family member's history of disease" - ) - assert inst.item[2].item[7].linkId == "2.1" - assert ( - inst.item[2].item[8].item[0].item[0].answer[0].valueCoding.code == "LA10423-4" - ) - assert ( - inst.item[2].item[8].item[0].item[0].answer[0].valueCoding.display - == "Paternal Grandfather" - ) - assert ( - inst.item[2].item[8].item[0].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[8].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54136-7" - ) - assert inst.item[2].item[8].item[0].item[0].linkId == "2.1.1.1" - assert inst.item[2].item[8].item[0].item[0].text == "Relationship to you" - assert inst.item[2].item[8].item[0].item[1].answer[0].valueString == "Bob" - assert ( - inst.item[2].item[8].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54138-3" - ) - assert inst.item[2].item[8].item[0].item[1].linkId == "2.1.1.2" - assert inst.item[2].item[8].item[0].item[1].text == "Name" - assert inst.item[2].item[8].item[0].item[2].answer[0].valueCoding.code == "LA2-8" - assert inst.item[2].item[8].item[0].item[2].answer[0].valueCoding.display == "Male" - assert ( - inst.item[2].item[8].item[0].item[2].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[8].item[0].item[2].definition - == "http://loinc.org/fhir/DataElement/54123-5" - ) - assert inst.item[2].item[8].item[0].item[2].linkId == "2.1.1.3" - assert inst.item[2].item[8].item[0].item[2].text == "Gender" - assert ( - inst.item[2] - .item[8] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.code - == "LA10537-1" - ) - assert ( - inst.item[2] - .item[8] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.display - == "-- Colon Cancer" - ) - assert ( - inst.item[2] - .item[8] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[8].item[0].item[3].answer[0].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54112-8" - ) - assert ( - inst.item[2].item[8].item[0].item[3].answer[0].item[0].item[0].linkId - == "2.1.1.4.1.1" - ) - assert ( - inst.item[2].item[8].item[0].item[3].answer[0].item[0].item[0].text - == "Cause of Death" - ) - assert ( - inst.item[2] - .item[8] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[1] - .answer[0] - .valueCoding.code - == "LA10400-2" - ) - assert ( - inst.item[2] - .item[8] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[1] - .answer[0] - .valueCoding.display - == "OVER 60" - ) - assert ( - inst.item[2] - .item[8] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[1] - .answer[0] - .valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[8].item[0].item[3].answer[0].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54113-6" - ) - assert ( - inst.item[2].item[8].item[0].item[3].answer[0].item[0].item[1].linkId - == "2.1.1.4.1.2" - ) - assert ( - inst.item[2].item[8].item[0].item[3].answer[0].item[0].item[1].text - == "Age at Death" - ) - assert inst.item[2].item[8].item[0].item[3].answer[0].item[0].linkId == "2.1.1.4.1" - assert inst.item[2].item[8].item[0].item[3].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[8].item[0].item[3].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[8].item[0].item[3].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[8].item[0].item[3].definition - == "http://loinc.org/fhir/DataElement/54139-1" - ) - assert inst.item[2].item[8].item[0].item[3].linkId == "2.1.1.4" - assert inst.item[2].item[8].item[0].item[3].text == "Living?" - assert inst.item[2].item[8].item[0].item[4].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[8].item[0].item[4].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[8].item[0].item[4].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[8].item[0].item[4].definition - == "http://loinc.org/fhir/DataElement/54121-9" - ) - assert inst.item[2].item[8].item[0].item[4].linkId == "2.1.1.5" - assert inst.item[2].item[8].item[0].item[4].text == "Was this person born a twin?" - assert inst.item[2].item[8].item[0].item[5].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[8].item[0].item[5].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[8].item[0].item[5].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[8].item[0].item[5].definition - == "http://loinc.org/fhir/DataElement/54122-7" - ) - assert inst.item[2].item[8].item[0].item[5].linkId == "2.1.1.6" - assert inst.item[2].item[8].item[0].item[5].text == "Was this person adopted?" - assert inst.item[2].item[8].item[0].linkId == "2.1.1" - assert ( - inst.item[2].item[8].item[1].item[0].answer[0].valueCoding.code == "LA10537-1" - ) - assert ( - inst.item[2].item[8].item[1].item[0].answer[0].valueCoding.display - == "-- Colon Cancer" - ) - assert ( - inst.item[2].item[8].item[1].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert inst.item[2].item[8].item[1].item[0].linkId == "2.1.2.1" - assert inst.item[2].item[8].item[1].item[0].text == "Disease or Condition" - assert ( - inst.item[2].item[8].item[1].item[1].answer[0].valueCoding.code == "LA10400-2" - ) - assert ( - inst.item[2].item[8].item[1].item[1].answer[0].valueCoding.display == "OVER 60" - ) - assert ( - inst.item[2].item[8].item[1].item[1].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert inst.item[2].item[8].item[1].item[1].linkId == "2.1.2.2" - assert inst.item[2].item[8].item[1].item[1].text == "Age at Diagnosis" - assert inst.item[2].item[8].item[1].linkId == "2.1.2" - assert ( - inst.item[2].item[8].item[1].text == "This family member's history of disease" - ) - assert inst.item[2].item[8].linkId == "2.1" - assert ( - inst.item[2].item[9].item[0].item[0].answer[0].valueCoding.code == "LA10424-2" - ) - assert ( - inst.item[2].item[9].item[0].item[0].answer[0].valueCoding.display - == "Paternal Grandmother" - ) - assert ( - inst.item[2].item[9].item[0].item[0].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[9].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54136-7" - ) - assert inst.item[2].item[9].item[0].item[0].linkId == "2.1.1.1" - assert inst.item[2].item[9].item[0].item[0].text == "Relationship to you" - assert inst.item[2].item[9].item[0].item[1].answer[0].valueString == "Claire" - assert ( - inst.item[2].item[9].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54138-3" - ) - assert inst.item[2].item[9].item[0].item[1].linkId == "2.1.1.2" - assert inst.item[2].item[9].item[0].item[1].text == "Name" - assert inst.item[2].item[9].item[0].item[2].answer[0].valueCoding.code == "LA3-6" - assert ( - inst.item[2].item[9].item[0].item[2].answer[0].valueCoding.display == "Female" - ) - assert ( - inst.item[2].item[9].item[0].item[2].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[9].item[0].item[2].definition - == "http://loinc.org/fhir/DataElement/54123-5" - ) - assert inst.item[2].item[9].item[0].item[2].linkId == "2.1.1.3" - assert inst.item[2].item[9].item[0].item[2].text == "Gender" - assert ( - inst.item[2] - .item[9] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .item[0] - .answer[0] - .valueString - == "Lou Gehrigs" - ) - assert ( - inst.item[2] - .item[9] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .item[0] - .linkId - == "2.1.1.4.1.1.1" - ) - assert ( - inst.item[2] - .item[9] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .item[0] - .text - == "Please specify" - ) - assert ( - inst.item[2] - .item[9] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.code - == "LA10589-2" - ) - assert ( - inst.item[2] - .item[9] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.display - == "-- Other/Unexpected" - ) - assert ( - inst.item[2] - .item[9] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[0] - .answer[0] - .valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[9].item[0].item[3].answer[0].item[0].item[0].definition - == "http://loinc.org/fhir/DataElement/54112-8" - ) - assert ( - inst.item[2].item[9].item[0].item[3].answer[0].item[0].item[0].linkId - == "2.1.1.4.1.1" - ) - assert ( - inst.item[2].item[9].item[0].item[3].answer[0].item[0].item[0].text - == "Cause of Death" - ) - assert ( - inst.item[2] - .item[9] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[1] - .answer[0] - .valueCoding.code - == "LA10400-2" - ) - assert ( - inst.item[2] - .item[9] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[1] - .answer[0] - .valueCoding.display - == "OVER 60" - ) - assert ( - inst.item[2] - .item[9] - .item[0] - .item[3] - .answer[0] - .item[0] - .item[1] - .answer[0] - .valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[9].item[0].item[3].answer[0].item[0].item[1].definition - == "http://loinc.org/fhir/DataElement/54113-6" - ) - assert ( - inst.item[2].item[9].item[0].item[3].answer[0].item[0].item[1].linkId - == "2.1.1.4.1.2" - ) - assert ( - inst.item[2].item[9].item[0].item[3].answer[0].item[0].item[1].text - == "Age at Death" - ) - assert inst.item[2].item[9].item[0].item[3].answer[0].item[0].linkId == "2.1.1.4.1" - assert inst.item[2].item[9].item[0].item[3].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[9].item[0].item[3].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[9].item[0].item[3].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[9].item[0].item[3].definition - == "http://loinc.org/fhir/DataElement/54139-1" - ) - assert inst.item[2].item[9].item[0].item[3].linkId == "2.1.1.4" - assert inst.item[2].item[9].item[0].item[3].text == "Living?" - assert inst.item[2].item[9].item[0].item[4].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[9].item[0].item[4].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[9].item[0].item[4].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[9].item[0].item[4].definition - == "http://loinc.org/fhir/DataElement/54121-9" - ) - assert inst.item[2].item[9].item[0].item[4].linkId == "2.1.1.5" - assert inst.item[2].item[9].item[0].item[4].text == "Was this person born a twin?" - assert inst.item[2].item[9].item[0].item[5].answer[0].valueCoding.code == "LA32-8" - assert inst.item[2].item[9].item[0].item[5].answer[0].valueCoding.display == "No" - assert ( - inst.item[2].item[9].item[0].item[5].answer[0].valueCoding.system - == "http://loinc.org" - ) - assert ( - inst.item[2].item[9].item[0].item[5].definition - == "http://loinc.org/fhir/DataElement/54122-7" - ) - assert inst.item[2].item[9].item[0].item[5].linkId == "2.1.1.6" - assert inst.item[2].item[9].item[0].item[5].text == "Was this person adopted?" - assert inst.item[2].item[9].item[0].linkId == "2.1.1" - assert inst.item[2].item[9].linkId == "2.1" - assert inst.item[2].linkId == "2" - assert inst.item[2].text == "Family member health information" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.questionnaire == "Questionnaire/ussg-fht" - assert inst.status == "in-progress" - assert inst.subject.reference == "http://hl7.org/fhir/Patient/proband" - assert inst.subject.type == "Patient" - assert inst.text.status == "generated" - - -def test_questionnaireresponse_2(base_settings): - """No. 2 tests collection for QuestionnaireResponse. - Test File: questionnaireresponse-example-ussg-fht-answers.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "questionnaireresponse-example-ussg-fht-answers.json" - ) - inst = questionnaireresponse.QuestionnaireResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "QuestionnaireResponse" == inst.resource_type - - impl_questionnaireresponse_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "QuestionnaireResponse" == data["resourceType"] - - inst2 = questionnaireresponse.QuestionnaireResponse(**data) - impl_questionnaireresponse_2(inst2) - - -def impl_questionnaireresponse_3(inst): - assert inst.author.reference == "Practitioner/f201" - assert inst.authored == fhirtypes.DateTime.validate("2013-06-18T00:00:00+01:00") - assert inst.id == "f201" - assert inst.item[0].item[0].answer[0].valueString == "I am allergic to house dust" - assert inst.item[0].item[0].linkId == "1.1" - assert inst.item[0].item[0].text == "Do you have allergies?" - assert inst.item[0].linkId == "1" - assert inst.item[1].item[0].answer[0].valueString == "Male" - assert inst.item[1].item[0].linkId == "2.1" - assert inst.item[1].item[0].text == "What is your gender?" - assert inst.item[1].item[1].answer[0].valueDate == fhirtypes.Date.validate( - "1960-03-13" - ) - assert inst.item[1].item[1].linkId == "2.2" - assert inst.item[1].item[1].text == "What is your date of birth?" - assert inst.item[1].item[2].answer[0].valueString == "The Netherlands" - assert inst.item[1].item[2].linkId == "2.3" - assert inst.item[1].item[2].text == "What is your country of birth?" - assert inst.item[1].item[3].answer[0].valueString == "married" - assert inst.item[1].item[3].linkId == "2.4" - assert inst.item[1].item[3].text == "What is your marital status?" - assert inst.item[1].linkId == "2" - assert inst.item[1].text == "General questions" - assert inst.item[2].item[0].answer[0].valueString == "No" - assert inst.item[2].item[0].linkId == "3.1" - assert inst.item[2].item[0].text == "Do you smoke?" - assert inst.item[2].item[1].answer[0].valueString == "No, but I used to drink" - assert inst.item[2].item[1].linkId == "3.2" - assert inst.item[2].item[1].text == "Do you drink alchohol?" - assert inst.item[2].linkId == "3" - assert inst.item[2].text == "Intoxications" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.source.reference == "Practitioner/f201" - assert inst.status == "completed" - assert inst.subject.display == "Roel" - assert inst.subject.reference == "Patient/f201" - assert inst.text.status == "generated" - - -def test_questionnaireresponse_3(base_settings): - """No. 3 tests collection for QuestionnaireResponse. - Test File: questionnaireresponse-example-f201-lifelines.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "questionnaireresponse-example-f201-lifelines.json" - ) - inst = questionnaireresponse.QuestionnaireResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "QuestionnaireResponse" == inst.resource_type - - impl_questionnaireresponse_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "QuestionnaireResponse" == data["resourceType"] - - inst2 = questionnaireresponse.QuestionnaireResponse(**data) - impl_questionnaireresponse_3(inst2) - - -def impl_questionnaireresponse_4(inst): - assert inst.author.reference == "http://hl7.org/fhir/Practitioner/example" - assert inst.author.type == "Practitioner" - assert inst.authored == fhirtypes.DateTime.validate("2013-02-19T14:15:00+10:00") - assert inst.id == "bb" - assert inst.item[0].item[0].item[0].answer[0].valueString == "Cathy Jones" - assert inst.item[0].item[0].item[0].linkId == "nameOfChild" - assert inst.item[0].item[0].item[0].text == "Name of child" - assert inst.item[0].item[0].item[1].answer[0].valueCoding.code == "f" - assert inst.item[0].item[0].item[1].linkId == "sex" - assert inst.item[0].item[0].item[1].text == "Sex" - assert inst.item[0].item[0].linkId == "group" - assert float(inst.item[0].item[1].item[0].answer[0].valueDecimal) == float(3.25) - assert inst.item[0].item[1].item[0].linkId == "birthWeight" - assert inst.item[0].item[1].item[0].text == "Birth weight (kg)" - assert float(inst.item[0].item[1].item[1].answer[0].valueDecimal) == float(44.3) - assert inst.item[0].item[1].item[1].linkId == "birthLength" - assert inst.item[0].item[1].item[1].text == "Birth length (cm)" - assert inst.item[0].item[1].item[2].answer[0].item[0].item[0].answer[ - 0 - ].valueDate == fhirtypes.Date.validate("1972-11-30") - assert ( - inst.item[0].item[1].item[2].answer[0].item[0].item[0].linkId == "vitaminKDose1" - ) - assert inst.item[0].item[1].item[2].answer[0].item[0].item[0].text == "1st dose" - assert inst.item[0].item[1].item[2].answer[0].item[0].item[1].answer[ - 0 - ].valueDate == fhirtypes.Date.validate("1972-12-11") - assert ( - inst.item[0].item[1].item[2].answer[0].item[0].item[1].linkId == "vitaminKDose2" - ) - assert inst.item[0].item[1].item[2].answer[0].item[0].item[1].text == "2nd dose" - assert inst.item[0].item[1].item[2].answer[0].item[0].linkId == "vitaminKgivenDoses" - assert inst.item[0].item[1].item[2].answer[0].valueCoding.code == "INJECTION" - assert inst.item[0].item[1].item[2].linkId == "vitaminKgiven" - assert inst.item[0].item[1].item[2].text == "Vitamin K given" - assert inst.item[0].item[1].item[3].answer[0].item[0].answer[ - 0 - ].valueDate == fhirtypes.Date.validate("1972-12-04") - assert inst.item[0].item[1].item[3].answer[0].item[0].linkId == "hepBgivenDate" - assert inst.item[0].item[1].item[3].answer[0].item[0].text == "Date given" - assert inst.item[0].item[1].item[3].answer[0].valueBoolean is True - assert inst.item[0].item[1].item[3].linkId == "hepBgiven" - assert inst.item[0].item[1].item[3].text == "Hep B given y / n" - assert ( - inst.item[0].item[1].item[4].answer[0].valueString - == "Already able to speak Chinese" - ) - assert inst.item[0].item[1].item[4].linkId == "abnormalitiesAtBirth" - assert inst.item[0].item[1].item[4].text == "Abnormalities noted at birth" - assert inst.item[0].item[1].linkId == "neonatalInformation" - assert inst.item[0].item[1].text == "Neonatal Information" - assert inst.item[0].linkId == "birthDetails" - assert inst.item[0].text == "Birth details - To be completed by health professional" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "completed" - assert inst.subject.reference == "http://hl7.org/fhir/Patient/1" - assert inst.subject.type == "Patient" - assert inst.text.status == "generated" - - -def test_questionnaireresponse_4(base_settings): - """No. 4 tests collection for QuestionnaireResponse. - Test File: questionnaireresponse-example-bluebook.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "questionnaireresponse-example-bluebook.json" - ) - inst = questionnaireresponse.QuestionnaireResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "QuestionnaireResponse" == inst.resource_type - - impl_questionnaireresponse_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "QuestionnaireResponse" == data["resourceType"] - - inst2 = questionnaireresponse.QuestionnaireResponse(**data) - impl_questionnaireresponse_4(inst2) - - -def impl_questionnaireresponse_5(inst): - assert inst.authored == fhirtypes.DateTime.validate("2014-12-11T04:44:16Z") - assert inst.id == "gcs" - assert inst.item[0].answer[0].valueCoding.code == "LA6560-2" - assert inst.item[0].answer[0].valueCoding.display == "Confused" - assert ( - inst.item[0].answer[0].valueCoding.extension[0].url - == "http://hl7.org/fhir/StructureDefinition/ordinalValue" - ) - assert float(inst.item[0].answer[0].valueCoding.extension[0].valueDecimal) == float( - 4 - ) - assert inst.item[0].answer[0].valueCoding.system == "http://loinc.org" - assert inst.item[0].linkId == "1.1" - assert inst.item[1].answer[0].valueCoding.code == "LA6566-9" - assert inst.item[1].answer[0].valueCoding.display == "Localizing pain" - assert ( - inst.item[1].answer[0].valueCoding.extension[0].url - == "http://hl7.org/fhir/StructureDefinition/ordinalValue" - ) - assert float(inst.item[1].answer[0].valueCoding.extension[0].valueDecimal) == float( - 5 - ) - assert inst.item[1].answer[0].valueCoding.system == "http://loinc.org" - assert inst.item[1].linkId == "1.2" - assert inst.item[2].answer[0].valueCoding.code == "LA6556-0" - assert inst.item[2].answer[0].valueCoding.display == "Eyes open spontaneously" - assert ( - inst.item[2].answer[0].valueCoding.extension[0].url - == "http://hl7.org/fhir/StructureDefinition/ordinalValue" - ) - assert float(inst.item[2].answer[0].valueCoding.extension[0].valueDecimal) == float( - 4 - ) - assert inst.item[2].answer[0].valueCoding.system == "http://loinc.org" - assert inst.item[2].linkId == "1.3" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.questionnaire == "Questionnaire/gcs" - assert inst.source.reference == "Practitioner/f007" - assert inst.status == "completed" - assert inst.subject.display == "Peter James Chalmers" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_questionnaireresponse_5(base_settings): - """No. 5 tests collection for QuestionnaireResponse. - Test File: questionnaireresponse-example-gcs.json - """ - filename = ( - base_settings["unittest_data_dir"] / "questionnaireresponse-example-gcs.json" - ) - inst = questionnaireresponse.QuestionnaireResponse.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "QuestionnaireResponse" == inst.resource_type - - impl_questionnaireresponse_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "QuestionnaireResponse" == data["resourceType"] - - inst2 = questionnaireresponse.QuestionnaireResponse(**data) - impl_questionnaireresponse_5(inst2) diff --git a/fhir/resources/tests/test_relatedperson.py b/fhir/resources/tests/test_relatedperson.py deleted file mode 100644 index 5e38f3d5..00000000 --- a/fhir/resources/tests/test_relatedperson.py +++ /dev/null @@ -1,277 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/RelatedPerson -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import relatedperson - - -def impl_relatedperson_1(inst): - assert inst.address[0].city == "PleasantVille" - assert inst.address[0].line[0] == "534 Erewhon St" - assert inst.address[0].postalCode == "3999" - assert inst.address[0].state == "Vic" - assert inst.address[0].use == "home" - assert inst.gender == "male" - assert inst.id == "peter" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Chalmers" - assert inst.name[0].given[0] == "Peter" - assert inst.name[0].given[1] == "James" - assert inst.name[0].use == "official" - assert inst.patient.reference == "Patient/animal" - assert inst.period.start == fhirtypes.DateTime.validate("2012-03-11") - assert inst.photo[0].contentType == "image/jpeg" - assert inst.photo[0].url == "http://example.com/Binary/f012" - assert inst.relationship[0].coding[0].code == "C" - assert ( - inst.relationship[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0131" - ) - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "(03) 5555 6473" - assert inst.text.status == "generated" - - -def test_relatedperson_1(base_settings): - """No. 1 tests collection for RelatedPerson. - Test File: relatedperson-example-peter.json - """ - filename = base_settings["unittest_data_dir"] / "relatedperson-example-peter.json" - inst = relatedperson.RelatedPerson.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RelatedPerson" == inst.resource_type - - impl_relatedperson_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RelatedPerson" == data["resourceType"] - - inst2 = relatedperson.RelatedPerson(**data) - impl_relatedperson_1(inst2) - - -def impl_relatedperson_2(inst): - assert inst.gender == "female" - assert inst.id == "f001" - assert inst.identifier[0].system == "urn:oid:2.16.840.1.113883.2.4.6.3" - assert inst.identifier[0].type.text == "BSN" - assert inst.identifier[0].use == "official" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Abels" - assert inst.name[0].given[0] == "Sarah" - assert inst.name[0].use == "usual" - assert inst.patient.reference == "Patient/f001" - assert inst.relationship[0].coding[0].code == "SIGOTHR" - assert ( - inst.relationship[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "mobile" - assert inst.telecom[0].value == "0690383372" - assert inst.telecom[1].system == "email" - assert inst.telecom[1].use == "home" - assert inst.telecom[1].value == "s.abels@kpn.nl" - assert inst.text.status == "generated" - - -def test_relatedperson_2(base_settings): - """No. 2 tests collection for RelatedPerson. - Test File: relatedperson-example-f001-sarah.json - """ - filename = ( - base_settings["unittest_data_dir"] / "relatedperson-example-f001-sarah.json" - ) - inst = relatedperson.RelatedPerson.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RelatedPerson" == inst.resource_type - - impl_relatedperson_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RelatedPerson" == data["resourceType"] - - inst2 = relatedperson.RelatedPerson(**data) - impl_relatedperson_2(inst2) - - -def impl_relatedperson_3(inst): - assert inst.active is True - assert inst.address[0].line[0] == "2222 Home Street" - assert inst.address[0].use == "home" - assert inst.birthDate == fhirtypes.Date.validate("1973-05-31") - assert inst.gender == "female" - assert inst.id == "newborn-mom" - assert inst.identifier[0].system == "http://hl7.org/fhir/sid/us-ssn" - assert inst.identifier[0].type.coding[0].code == "SS" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].value == "444222222" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "Everywoman" - assert inst.name[0].given[0] == "Eve" - assert inst.name[0].use == "official" - assert inst.patient.reference == "Patient/newborn" - assert inst.relationship[0].coding[0].code == "NMTH" - assert inst.relationship[0].coding[0].display == "natural mother" - assert ( - inst.relationship[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - assert inst.relationship[0].text == "Natural Mother" - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "work" - assert inst.telecom[0].value == "555-555-2003" - assert inst.text.status == "generated" - - -def test_relatedperson_3(base_settings): - """No. 3 tests collection for RelatedPerson. - Test File: relatedperson-example-newborn-mom.json - """ - filename = ( - base_settings["unittest_data_dir"] / "relatedperson-example-newborn-mom.json" - ) - inst = relatedperson.RelatedPerson.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RelatedPerson" == inst.resource_type - - impl_relatedperson_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RelatedPerson" == data["resourceType"] - - inst2 = relatedperson.RelatedPerson(**data) - impl_relatedperson_3(inst2) - - -def impl_relatedperson_4(inst): - assert inst.active is True - assert inst.address[0].city == "Paris" - assert inst.address[0].country == "FRA" - assert inst.address[0].line[0] == "43, Place du Marché Sainte Catherine" - assert inst.address[0].postalCode == "75004" - assert inst.gender == "female" - assert inst.id == "benedicte" - assert inst.identifier[0].system == "urn:oid:1.2.250.1.61" - assert inst.identifier[0].type.text == "INSEE" - assert inst.identifier[0].use == "usual" - assert inst.identifier[0].value == "272117510400399" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].family == "du Marché" - assert inst.name[0].given[0] == "Bénédicte" - assert inst.patient.reference == "Patient/example" - assert inst.photo[0].contentType == "image/jpeg" - assert inst.photo[0].url == "https://example.com/Binary/f016" - assert inst.relationship[0].coding[0].code == "N" - assert ( - inst.relationship[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0131" - ) - assert inst.relationship[0].coding[1].code == "WIFE" - assert ( - inst.relationship[0].coding[1].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].value == "+33 (237) 998327" - assert inst.text.status == "generated" - - -def test_relatedperson_4(base_settings): - """No. 4 tests collection for RelatedPerson. - Test File: relatedperson-example.json - """ - filename = base_settings["unittest_data_dir"] / "relatedperson-example.json" - inst = relatedperson.RelatedPerson.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RelatedPerson" == inst.resource_type - - impl_relatedperson_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RelatedPerson" == data["resourceType"] - - inst2 = relatedperson.RelatedPerson(**data) - impl_relatedperson_4(inst2) - - -def impl_relatedperson_5(inst): - assert inst.birthDate == fhirtypes.Date.validate("1963") - assert inst.gender == "female" - assert inst.id == "f002" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name[0].text == "Ariadne Bor-Jansma" - assert inst.name[0].use == "usual" - assert inst.patient.reference == "Patient/f201" - assert inst.period.start == fhirtypes.DateTime.validate("1975") - assert inst.photo[0].contentType == "image/jpeg" - assert inst.relationship[0].coding[0].code == "SIGOTHR" - assert ( - inst.relationship[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/v3-RoleCode" - ) - assert inst.telecom[0].system == "phone" - assert inst.telecom[0].use == "home" - assert inst.telecom[0].value == "+31201234567" - assert inst.text.status == "generated" - - -def test_relatedperson_5(base_settings): - """No. 5 tests collection for RelatedPerson. - Test File: relatedperson-example-f002-ariadne.json - """ - filename = ( - base_settings["unittest_data_dir"] / "relatedperson-example-f002-ariadne.json" - ) - inst = relatedperson.RelatedPerson.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RelatedPerson" == inst.resource_type - - impl_relatedperson_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RelatedPerson" == data["resourceType"] - - inst2 = relatedperson.RelatedPerson(**data) - impl_relatedperson_5(inst2) diff --git a/fhir/resources/tests/test_requestgroup.py b/fhir/resources/tests/test_requestgroup.py deleted file mode 100644 index 985d8ea3..00000000 --- a/fhir/resources/tests/test_requestgroup.py +++ /dev/null @@ -1,260 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/RequestGroup -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import requestgroup - - -def impl_requestgroup_1(inst): - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[0] - .extension[0] - .extension[0] - .url - == "day" - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[0] - .extension[0] - .extension[0] - .valueInteger - == 1 - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[0] - .extension[0] - .extension[1] - .url - == "day" - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[0] - .extension[0] - .extension[1] - .valueInteger - == 8 - ) - assert ( - inst.action[0].action[0].action[0].action[0].action[0].extension[0].url - == "http://hl7.org/fhir/StructureDefinition/timing-daysOfCycle" - ) - assert inst.action[0].action[0].action[0].action[0].action[0].id == "action-1" - assert ( - inst.action[0].action[0].action[0].action[0].action[0].resource.reference - == "#1111" - ) - assert ( - inst.action[0].action[0].action[0].action[0].action[0].textEquivalent - == "Gemcitabine 1250 mg/m² IV over 30 minutes on days 1 and 8" - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[1] - .extension[0] - .extension[0] - .url - == "day" - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[1] - .extension[0] - .extension[0] - .valueInteger - == 1 - ) - assert ( - inst.action[0].action[0].action[0].action[0].action[1].extension[0].url - == "http://hl7.org/fhir/StructureDefinition/timing-daysOfCycle" - ) - assert inst.action[0].action[0].action[0].action[0].action[1].id == "action-2" - assert ( - inst.action[0].action[0].action[0].action[0].action[1].relatedAction[0].actionId - == "action-1" - ) - assert ( - inst.action[0] - .action[0] - .action[0] - .action[0] - .action[1] - .relatedAction[0] - .relationship - == "concurrent-with-start" - ) - assert ( - inst.action[0].action[0].action[0].action[0].action[1].resource.reference - == "#2222" - ) - assert ( - inst.action[0].action[0].action[0].action[0].action[1].textEquivalent - == "CARBOplatin AUC 5 IV over 30 minutes on Day 1" - ) - assert inst.action[0].action[0].action[0].action[0].id == "cycle-definition-1" - assert ( - inst.action[0].action[0].action[0].action[0].textEquivalent - == "21-day cycle for 6 cycles" - ) - assert inst.action[0].action[0].action[0].action[0].timingTiming.repeat.count == 6 - assert float( - inst.action[0].action[0].action[0].action[0].timingTiming.repeat.duration - ) == float(21) - assert ( - inst.action[0].action[0].action[0].action[0].timingTiming.repeat.durationUnit - == "d" - ) - assert inst.action[0].action[0].action[0].groupingBehavior == "sentence-group" - assert inst.action[0].action[0].action[0].selectionBehavior == "exactly-one" - assert inst.action[0].action[0].selectionBehavior == "all" - assert inst.action[0].selectionBehavior == "exactly-one" - assert inst.author.reference == "Practitioner/1" - assert inst.authoredOn == fhirtypes.DateTime.validate("2017-03-06T17:31:00Z") - assert inst.contained[0].id == "1111" - assert inst.contained[1].id == "2222" - assert inst.encounter.reference == "Encounter/example" - assert inst.id == "kdn5-example" - assert inst.identifier[0].value == "requestgroup-kdn5" - assert inst.instantiatesCanonical[0] == "PlanDefinition/KDN5" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.priority == "routine" - assert inst.status == "draft" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Administer ' - "gemcitabine and carboplatin.
" - ) - assert inst.text.status == "generated" - - -def test_requestgroup_1(base_settings): - """No. 1 tests collection for RequestGroup. - Test File: requestgroup-kdn5-example.json - """ - filename = base_settings["unittest_data_dir"] / "requestgroup-kdn5-example.json" - inst = requestgroup.RequestGroup.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RequestGroup" == inst.resource_type - - impl_requestgroup_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RequestGroup" == data["resourceType"] - - inst2 = requestgroup.RequestGroup(**data) - impl_requestgroup_1(inst2) - - -def impl_requestgroup_2(inst): - assert inst.action[0].action[0].description == "Administer medication 1" - assert inst.action[0].action[0].id == "medication-action-1" - assert inst.action[0].action[0].resource.reference == "#medicationrequest-1" - assert inst.action[0].action[0].type.coding[0].code == "create" - assert inst.action[0].action[1].description == "Administer medication 2" - assert inst.action[0].action[1].id == "medication-action-2" - assert inst.action[0].action[1].relatedAction[0].actionId == "medication-action-1" - assert inst.action[0].action[1].relatedAction[0].offsetDuration.unit == "h" - assert float( - inst.action[0].action[1].relatedAction[0].offsetDuration.value - ) == float(1) - assert inst.action[0].action[1].relatedAction[0].relationship == "after-end" - assert inst.action[0].action[1].resource.reference == "#medicationrequest-2" - assert inst.action[0].action[1].type.coding[0].code == "create" - assert inst.action[0].cardinalityBehavior == "single" - assert ( - inst.action[0].description == "Administer medications at the appropriate time" - ) - assert inst.action[0].groupingBehavior == "logical-group" - assert inst.action[0].participant[0].reference == "Practitioner/1" - assert inst.action[0].precheckBehavior == "yes" - assert inst.action[0].prefix == "1" - assert inst.action[0].requiredBehavior == "must" - assert inst.action[0].selectionBehavior == "all" - assert inst.action[0].textEquivalent == ( - "Administer medication 1, followed an hour later by " "medication 2" - ) - assert inst.action[0].timingDateTime == fhirtypes.DateTime.validate( - "2017-03-06T19:00:00Z" - ) - assert inst.action[0].title == "Administer Medications" - assert inst.author.reference == "Practitioner/1" - assert inst.authoredOn == fhirtypes.DateTime.validate("2017-03-06T17:31:00Z") - assert inst.contained[0].id == "medicationrequest-1" - assert inst.contained[1].id == "medicationrequest-2" - assert inst.encounter.reference == "Encounter/example" - assert inst.groupIdentifier.system == "http://example.org/treatment-group" - assert inst.groupIdentifier.value == "00001" - assert inst.id == "example" - assert inst.identifier[0].value == "requestgroup-1" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "Additional notes about the request group" - assert inst.priority == "routine" - assert inst.reasonCode[0].text == "Treatment" - assert inst.status == "draft" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Example ' - "RequestGroup illustrating related actions to administer " - "medications in sequence with time delay.
" - ) - assert inst.text.status == "generated" - - -def test_requestgroup_2(base_settings): - """No. 2 tests collection for RequestGroup. - Test File: requestgroup-example.json - """ - filename = base_settings["unittest_data_dir"] / "requestgroup-example.json" - inst = requestgroup.RequestGroup.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RequestGroup" == inst.resource_type - - impl_requestgroup_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RequestGroup" == data["resourceType"] - - inst2 = requestgroup.RequestGroup(**data) - impl_requestgroup_2(inst2) diff --git a/fhir/resources/tests/test_researchdefinition.py b/fhir/resources/tests/test_researchdefinition.py deleted file mode 100644 index 90bf2932..00000000 --- a/fhir/resources/tests/test_researchdefinition.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ResearchDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import researchdefinition - - -def impl_researchdefinition_1(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.population.reference == "ResearchElementDefinition/example" - assert inst.status == "draft" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_researchdefinition_1(base_settings): - """No. 1 tests collection for ResearchDefinition. - Test File: researchdefinition-example.json - """ - filename = base_settings["unittest_data_dir"] / "researchdefinition-example.json" - inst = researchdefinition.ResearchDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ResearchDefinition" == inst.resource_type - - impl_researchdefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ResearchDefinition" == data["resourceType"] - - inst2 = researchdefinition.ResearchDefinition(**data) - impl_researchdefinition_1(inst2) diff --git a/fhir/resources/tests/test_researchelementdefinition.py b/fhir/resources/tests/test_researchelementdefinition.py deleted file mode 100644 index 2aa054c4..00000000 --- a/fhir/resources/tests/test_researchelementdefinition.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ResearchElementDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import researchelementdefinition - - -def impl_researchelementdefinition_1(inst): - assert ( - inst.characteristic[0].definitionCodeableConcept.text - == "Diabetic patients over 65" - ) - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "draft" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - assert inst.type == "population" - - -def test_researchelementdefinition_1(base_settings): - """No. 1 tests collection for ResearchElementDefinition. - Test File: researchelementdefinition-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "researchelementdefinition-example.json" - ) - inst = researchelementdefinition.ResearchElementDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ResearchElementDefinition" == inst.resource_type - - impl_researchelementdefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ResearchElementDefinition" == data["resourceType"] - - inst2 = researchelementdefinition.ResearchElementDefinition(**data) - impl_researchelementdefinition_1(inst2) diff --git a/fhir/resources/tests/test_researchstudy.py b/fhir/resources/tests/test_researchstudy.py deleted file mode 100644 index 13f92b03..00000000 --- a/fhir/resources/tests/test_researchstudy.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ResearchStudy -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import researchstudy - - -def impl_researchstudy_1(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "completed" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_researchstudy_1(base_settings): - """No. 1 tests collection for ResearchStudy. - Test File: researchstudy-example.json - """ - filename = base_settings["unittest_data_dir"] / "researchstudy-example.json" - inst = researchstudy.ResearchStudy.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ResearchStudy" == inst.resource_type - - impl_researchstudy_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ResearchStudy" == data["resourceType"] - - inst2 = researchstudy.ResearchStudy(**data) - impl_researchstudy_1(inst2) diff --git a/fhir/resources/tests/test_researchsubject.py b/fhir/resources/tests/test_researchsubject.py deleted file mode 100644 index 51ce7324..00000000 --- a/fhir/resources/tests/test_researchsubject.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ResearchSubject -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import researchsubject - - -def impl_researchsubject_1(inst): - assert inst.id == "example" - assert inst.identifier[0].system == "http://example.org/studysubjectids" - assert inst.identifier[0].type.text == "Subject id" - assert inst.identifier[0].value == "123" - assert inst.individual.reference == "Patient/example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "candidate" - assert inst.study.reference == "ResearchStudy/example" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_researchsubject_1(base_settings): - """No. 1 tests collection for ResearchSubject. - Test File: researchsubject-example.json - """ - filename = base_settings["unittest_data_dir"] / "researchsubject-example.json" - inst = researchsubject.ResearchSubject.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ResearchSubject" == inst.resource_type - - impl_researchsubject_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ResearchSubject" == data["resourceType"] - - inst2 = researchsubject.ResearchSubject(**data) - impl_researchsubject_1(inst2) diff --git a/fhir/resources/tests/test_riskassessment.py b/fhir/resources/tests/test_riskassessment.py deleted file mode 100644 index 358a2b10..00000000 --- a/fhir/resources/tests/test_riskassessment.py +++ /dev/null @@ -1,373 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/RiskAssessment -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import riskassessment - - -def impl_riskassessment_1(inst): - assert inst.contained[0].id == "group1" - assert inst.id == "population" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "final" - assert inst.subject.reference == "#group1" - assert inst.text.status == "generated" - - -def test_riskassessment_1(base_settings): - """No. 1 tests collection for RiskAssessment. - Test File: riskassessment-example-population.json - """ - filename = ( - base_settings["unittest_data_dir"] / "riskassessment-example-population.json" - ) - inst = riskassessment.RiskAssessment.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RiskAssessment" == inst.resource_type - - impl_riskassessment_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RiskAssessment" == data["resourceType"] - - inst2 = riskassessment.RiskAssessment(**data) - impl_riskassessment_1(inst2) - - -def impl_riskassessment_2(inst): - assert inst.basis[0].reference == "Patient/pat2" - assert inst.basis[1].reference == "DiagnosticReport/lipids" - assert inst.basis[2].reference == "Observation/blood-pressure" - assert inst.encounter.reference == "Encounter/example" - assert inst.id == "cardiac" - assert inst.identifier[0].system == "http://example.org" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "risk-assessment-cardiac" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2014-07-19T16:04:00Z" - ) - assert inst.performer.display == "http://cvdrisk.nhlbi.nih.gov/#cholesterol" - assert inst.prediction[0].outcome.text == "Heart Attack" - assert float(inst.prediction[0].probabilityDecimal) == float(0.02) - assert inst.prediction[0].whenRange.high.code == "a" - assert inst.prediction[0].whenRange.high.system == "http://unitsofmeasure.org" - assert inst.prediction[0].whenRange.high.unit == "years" - assert float(inst.prediction[0].whenRange.high.value) == float(49) - assert inst.prediction[0].whenRange.low.code == "a" - assert inst.prediction[0].whenRange.low.system == "http://unitsofmeasure.org" - assert inst.prediction[0].whenRange.low.unit == "years" - assert float(inst.prediction[0].whenRange.low.value) == float(39) - assert inst.status == "final" - assert inst.subject.reference == "Patient/pat2" - assert inst.text.status == "additional" - - -def test_riskassessment_2(base_settings): - """No. 2 tests collection for RiskAssessment. - Test File: riskassessment-example-cardiac.json - """ - filename = ( - base_settings["unittest_data_dir"] / "riskassessment-example-cardiac.json" - ) - inst = riskassessment.RiskAssessment.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RiskAssessment" == inst.resource_type - - impl_riskassessment_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RiskAssessment" == data["resourceType"] - - inst2 = riskassessment.RiskAssessment(**data) - impl_riskassessment_2(inst2) - - -def impl_riskassessment_3(inst): - assert inst.basis[0].reference == "List/prognosis" - assert inst.id == "genetic" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.method.coding[0].code == "BRCAPRO" - assert inst.note[0].text == "High degree of certainty" - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2006-01-13T23:01:00Z" - ) - assert inst.prediction[0].outcome.text == "Breast Cancer" - assert float(inst.prediction[0].probabilityDecimal) == float(0.000168) - assert inst.prediction[0].whenRange.high.code == "a" - assert inst.prediction[0].whenRange.high.system == "http://unitsofmeasure.org" - assert inst.prediction[0].whenRange.high.unit == "years" - assert float(inst.prediction[0].whenRange.high.value) == float(53) - assert inst.prediction[1].outcome.text == "Breast Cancer" - assert float(inst.prediction[1].probabilityDecimal) == float(0.000368) - assert inst.prediction[1].whenRange.high.code == "a" - assert inst.prediction[1].whenRange.high.system == "http://unitsofmeasure.org" - assert inst.prediction[1].whenRange.high.unit == "years" - assert float(inst.prediction[1].whenRange.high.value) == float(57) - assert inst.prediction[1].whenRange.low.code == "a" - assert inst.prediction[1].whenRange.low.system == "http://unitsofmeasure.org" - assert inst.prediction[1].whenRange.low.unit == "years" - assert float(inst.prediction[1].whenRange.low.value) == float(54) - assert inst.prediction[2].outcome.text == "Breast Cancer" - assert float(inst.prediction[2].probabilityDecimal) == float(0.000594) - assert inst.prediction[2].whenRange.high.code == "a" - assert inst.prediction[2].whenRange.high.system == "http://unitsofmeasure.org" - assert inst.prediction[2].whenRange.high.unit == "years" - assert float(inst.prediction[2].whenRange.high.value) == float(62) - assert inst.prediction[2].whenRange.low.code == "a" - assert inst.prediction[2].whenRange.low.system == "http://unitsofmeasure.org" - assert inst.prediction[2].whenRange.low.unit == "years" - assert float(inst.prediction[2].whenRange.low.value) == float(58) - assert inst.prediction[3].outcome.text == "Breast Cancer" - assert float(inst.prediction[3].probabilityDecimal) == float(0.000838) - assert inst.prediction[3].whenRange.high.code == "a" - assert inst.prediction[3].whenRange.high.system == "http://unitsofmeasure.org" - assert inst.prediction[3].whenRange.high.unit == "years" - assert float(inst.prediction[3].whenRange.high.value) == float(67) - assert inst.prediction[3].whenRange.low.code == "a" - assert inst.prediction[3].whenRange.low.system == "http://unitsofmeasure.org" - assert inst.prediction[3].whenRange.low.unit == "years" - assert float(inst.prediction[3].whenRange.low.value) == float(63) - assert inst.prediction[4].outcome.text == "Breast Cancer" - assert float(inst.prediction[4].probabilityDecimal) == float(0.001089) - assert inst.prediction[4].whenRange.high.code == "a" - assert inst.prediction[4].whenRange.high.system == "http://unitsofmeasure.org" - assert inst.prediction[4].whenRange.high.unit == "years" - assert float(inst.prediction[4].whenRange.high.value) == float(72) - assert inst.prediction[4].whenRange.low.code == "a" - assert inst.prediction[4].whenRange.low.system == "http://unitsofmeasure.org" - assert inst.prediction[4].whenRange.low.unit == "years" - assert float(inst.prediction[4].whenRange.low.value) == float(68) - assert inst.prediction[5].outcome.text == "Breast Cancer" - assert float(inst.prediction[5].probabilityDecimal) == float(0.001327) - assert inst.prediction[5].whenRange.high.code == "a" - assert inst.prediction[5].whenRange.high.system == "http://unitsofmeasure.org" - assert inst.prediction[5].whenRange.high.unit == "years" - assert float(inst.prediction[5].whenRange.high.value) == float(77) - assert inst.prediction[5].whenRange.low.code == "a" - assert inst.prediction[5].whenRange.low.system == "http://unitsofmeasure.org" - assert inst.prediction[5].whenRange.low.unit == "years" - assert float(inst.prediction[5].whenRange.low.value) == float(73) - assert inst.prediction[6].outcome.text == "Breast Cancer" - assert float(inst.prediction[6].probabilityDecimal) == float(0.00153) - assert inst.prediction[6].whenRange.high.code == "a" - assert inst.prediction[6].whenRange.high.system == "http://unitsofmeasure.org" - assert inst.prediction[6].whenRange.high.unit == "years" - assert float(inst.prediction[6].whenRange.high.value) == float(82) - assert inst.prediction[6].whenRange.low.code == "a" - assert inst.prediction[6].whenRange.low.system == "http://unitsofmeasure.org" - assert inst.prediction[6].whenRange.low.unit == "years" - assert float(inst.prediction[6].whenRange.low.value) == float(78) - assert inst.prediction[7].outcome.text == "Breast Cancer" - assert float(inst.prediction[7].probabilityDecimal) == float(0.001663) - assert inst.prediction[7].whenRange.high.code == "a" - assert inst.prediction[7].whenRange.high.system == "http://unitsofmeasure.org" - assert inst.prediction[7].whenRange.high.unit == "years" - assert float(inst.prediction[7].whenRange.high.value) == float(88) - assert inst.prediction[7].whenRange.low.code == "a" - assert inst.prediction[7].whenRange.low.system == "http://unitsofmeasure.org" - assert inst.prediction[7].whenRange.low.unit == "years" - assert float(inst.prediction[7].whenRange.low.value) == float(83) - assert inst.status == "final" - assert inst.subject.reference == "Patient/b248b1b2-1686-4b94-9936-37d7a5f94b51" - assert inst.text.status == "generated" - - -def test_riskassessment_3(base_settings): - """No. 3 tests collection for RiskAssessment. - Test File: riskassessment-example.json - """ - filename = base_settings["unittest_data_dir"] / "riskassessment-example.json" - inst = riskassessment.RiskAssessment.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RiskAssessment" == inst.resource_type - - impl_riskassessment_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RiskAssessment" == data["resourceType"] - - inst2 = riskassessment.RiskAssessment(**data) - impl_riskassessment_3(inst2) - - -def impl_riskassessment_4(inst): - assert inst.basedOn.reference == "ImmunizationRecommendation/example" - assert inst.basis[0].reference == "DiagnosticReport/example" - assert inst.basis[1].reference == "Observation/example" - assert inst.code.coding[0].code == "709510001" - assert inst.code.coding[0].display == "Assessment of risk for disease (procedure)" - assert inst.code.coding[0].system == "http://browser.ihtsdotools.org/" - assert inst.condition.reference == "Condition/example" - assert inst.encounter.display == "Encounter with patient @example" - assert inst.encounter.reference == "Encounter/example" - assert inst.id == "riskexample" - assert inst.identifier[0].system == "http://example.org" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "risk-assessment-breastcancer1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "This risk assessment is for reference only" - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate("2017-10-10") - assert inst.parent.reference == "DiagnosticReport/example" - assert inst.performer.reference == "Practitioner/example" - assert inst.prediction[0].outcome.text == "Breast Cancer" - assert float(inst.prediction[0].probabilityDecimal) == float(0.000368) - assert inst.prediction[0].whenRange.high.code == "a" - assert inst.prediction[0].whenRange.high.system == "http://unitsofmeasure.org" - assert inst.prediction[0].whenRange.high.unit == "years" - assert float(inst.prediction[0].whenRange.high.value) == float(57) - assert inst.prediction[0].whenRange.low.code == "a" - assert inst.prediction[0].whenRange.low.system == "http://unitsofmeasure.org" - assert inst.prediction[0].whenRange.low.unit == "years" - assert float(inst.prediction[0].whenRange.low.value) == float(54) - assert inst.status == "final" - assert inst.subject.reference == "Patient/example" - assert inst.text.div == ( - '
Risk assessment ' - "for reference only
" - ) - assert inst.text.status == "generated" - - -def test_riskassessment_4(base_settings): - """No. 4 tests collection for RiskAssessment. - Test File: riskassessment-riskexample.json - """ - filename = base_settings["unittest_data_dir"] / "riskassessment-riskexample.json" - inst = riskassessment.RiskAssessment.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RiskAssessment" == inst.resource_type - - impl_riskassessment_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RiskAssessment" == data["resourceType"] - - inst2 = riskassessment.RiskAssessment(**data) - impl_riskassessment_4(inst2) - - -def impl_riskassessment_5(inst): - assert inst.basis[0].reference == "Observation/example-genetics-brcapat" - assert inst.code.coding[0].code == "709510001" - assert inst.code.coding[0].display == "Assessment of risk for disease (procedure)" - assert inst.code.coding[0].system == "http://browser.ihtsdotools.org/" - assert inst.id == "breastcancer-risk" - assert inst.identifier[0].system == "http://example.org" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "risk-assessment-breastcancer1" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == ( - "This risk assessment is based on BRCA1 and BRCA2 genetic " "mutation test" - ) - assert inst.performer.reference == "Practitioner/example" - assert inst.prediction[0].outcome.text == "Unknown risk of developing breast cancer" - assert inst.status == "final" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "additional" - - -def test_riskassessment_5(base_settings): - """No. 5 tests collection for RiskAssessment. - Test File: riskassessment-example-breastcancer.json - """ - filename = ( - base_settings["unittest_data_dir"] / "riskassessment-example-breastcancer.json" - ) - inst = riskassessment.RiskAssessment.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RiskAssessment" == inst.resource_type - - impl_riskassessment_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RiskAssessment" == data["resourceType"] - - inst2 = riskassessment.RiskAssessment(**data) - impl_riskassessment_5(inst2) - - -def impl_riskassessment_6(inst): - assert inst.condition.display == "Ischemic Stroke" - assert inst.condition.reference == "Condition/stroke" - assert inst.id == "prognosis" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate("2010-11-22") - assert ( - inst.prediction[0].outcome.coding[0].code - == "249943000:363698007=72098002,260868000=6934004" - ) - assert inst.prediction[0].outcome.coding[0].system == "http://snomed.info/sct" - assert inst.prediction[0].outcome.text == "permanent weakness of the left arm" - assert inst.prediction[0].qualitativeRisk.coding[0].code == "moderate" - assert inst.prediction[0].qualitativeRisk.coding[0].display == "moderate likelihood" - assert ( - inst.prediction[0].qualitativeRisk.coding[0].system - == "http://terminology.hl7.org/CodeSystem/risk-probability" - ) - assert inst.status == "final" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "additional" - - -def test_riskassessment_6(base_settings): - """No. 6 tests collection for RiskAssessment. - Test File: riskassessment-example-prognosis.json - """ - filename = ( - base_settings["unittest_data_dir"] / "riskassessment-example-prognosis.json" - ) - inst = riskassessment.RiskAssessment.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RiskAssessment" == inst.resource_type - - impl_riskassessment_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RiskAssessment" == data["resourceType"] - - inst2 = riskassessment.RiskAssessment(**data) - impl_riskassessment_6(inst2) diff --git a/fhir/resources/tests/test_riskevidencesynthesis.py b/fhir/resources/tests/test_riskevidencesynthesis.py deleted file mode 100644 index 013fdb77..00000000 --- a/fhir/resources/tests/test_riskevidencesynthesis.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/RiskEvidenceSynthesis -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import riskevidencesynthesis - - -def impl_riskevidencesynthesis_1(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.outcome.reference == "EvidenceVariable/example" - assert inst.population.reference == "EvidenceVariable/example" - assert inst.status == "draft" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_riskevidencesynthesis_1(base_settings): - """No. 1 tests collection for RiskEvidenceSynthesis. - Test File: riskevidencesynthesis-example.json - """ - filename = base_settings["unittest_data_dir"] / "riskevidencesynthesis-example.json" - inst = riskevidencesynthesis.RiskEvidenceSynthesis.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "RiskEvidenceSynthesis" == inst.resource_type - - impl_riskevidencesynthesis_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "RiskEvidenceSynthesis" == data["resourceType"] - - inst2 = riskevidencesynthesis.RiskEvidenceSynthesis(**data) - impl_riskevidencesynthesis_1(inst2) diff --git a/fhir/resources/tests/test_schedule.py b/fhir/resources/tests/test_schedule.py deleted file mode 100644 index 3322c682..00000000 --- a/fhir/resources/tests/test_schedule.py +++ /dev/null @@ -1,176 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Schedule -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import schedule - - -def impl_schedule_1(inst): - assert inst.active is True - assert inst.actor[0].display == "Dr. Beverly Crusher" - assert inst.actor[0].reference == "Practitioner/1" - assert inst.actor[1].display == "USS Enterprise-D Sickbay" - assert inst.actor[1].reference == "Location/3" - assert inst.comment == ( - "The slots attached to this schedule are for genetic " - "counselling in the USS Enterprise-D Sickbay." - ) - assert inst.id == "exampleloc1" - assert inst.identifier[0].system == "http://example.org/scheduleid" - assert inst.identifier[0].use == "usual" - assert inst.identifier[0].value == "46" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.planningHorizon.end == fhirtypes.DateTime.validate( - "2017-12-25T09:30:00Z" - ) - assert inst.planningHorizon.start == fhirtypes.DateTime.validate( - "2017-12-25T09:15:00Z" - ) - assert inst.serviceCategory[0].coding[0].code == "17" - assert inst.serviceCategory[0].coding[0].display == "General Practice" - assert inst.serviceType[0].coding[0].code == "75" - assert inst.serviceType[0].coding[0].display == "Genetic Counselling" - assert inst.specialty[0].coding[0].code == "394580004" - assert inst.specialty[0].coding[0].display == "Clinical genetics" - assert inst.text.status == "generated" - - -def test_schedule_1(base_settings): - """No. 1 tests collection for Schedule. - Test File: schedule-provider-location1-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "schedule-provider-location1-example.json" - ) - inst = schedule.Schedule.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Schedule" == inst.resource_type - - impl_schedule_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Schedule" == data["resourceType"] - - inst2 = schedule.Schedule(**data) - impl_schedule_1(inst2) - - -def impl_schedule_2(inst): - assert inst.active is True - assert inst.actor[0].display == "Burgers UMC, South Wing, second floor" - assert inst.actor[0].reference == "Location/1" - assert inst.comment == ( - "The slots attached to this schedule should be specialized to" - " cover immunizations within the clinic" - ) - assert inst.id == "example" - assert inst.identifier[0].system == "http://example.org/scheduleid" - assert inst.identifier[0].use == "usual" - assert inst.identifier[0].value == "45" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.planningHorizon.end == fhirtypes.DateTime.validate( - "2013-12-25T09:30:00Z" - ) - assert inst.planningHorizon.start == fhirtypes.DateTime.validate( - "2013-12-25T09:15:00Z" - ) - assert inst.serviceCategory[0].coding[0].code == "17" - assert inst.serviceCategory[0].coding[0].display == "General Practice" - assert inst.serviceType[0].coding[0].code == "57" - assert inst.serviceType[0].coding[0].display == "Immunization" - assert inst.specialty[0].coding[0].code == "408480009" - assert inst.specialty[0].coding[0].display == "Clinical immunology" - assert inst.text.status == "generated" - - -def test_schedule_2(base_settings): - """No. 2 tests collection for Schedule. - Test File: schedule-example.json - """ - filename = base_settings["unittest_data_dir"] / "schedule-example.json" - inst = schedule.Schedule.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Schedule" == inst.resource_type - - impl_schedule_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Schedule" == data["resourceType"] - - inst2 = schedule.Schedule(**data) - impl_schedule_2(inst2) - - -def impl_schedule_3(inst): - assert inst.active is True - assert inst.actor[0].display == "Dr. Beverly Crusher" - assert inst.actor[0].reference == "Practitioner/1" - assert inst.actor[1].display == "Starfleet HQ Sickbay" - assert inst.actor[1].reference == "Location/2" - assert inst.comment == ( - "The slots attached to this schedule are for neurosurgery " - "operations at Starfleet HQ only." - ) - assert inst.id == "exampleloc2" - assert inst.identifier[0].system == "http://example.org/scheduleid" - assert inst.identifier[0].use == "usual" - assert inst.identifier[0].value == "47" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.planningHorizon.end == fhirtypes.DateTime.validate( - "2017-12-25T09:30:00Z" - ) - assert inst.planningHorizon.start == fhirtypes.DateTime.validate( - "2017-12-25T09:15:00Z" - ) - assert inst.serviceCategory[0].coding[0].code == "31" - assert inst.serviceCategory[0].coding[0].display == "Specialist Surgical" - assert inst.serviceType[0].coding[0].code == "221" - assert inst.serviceType[0].coding[0].display == "Surgery - General" - assert inst.specialty[0].coding[0].code == "394610002" - assert inst.specialty[0].coding[0].display == "Surgery-Neurosurgery" - assert inst.text.status == "generated" - - -def test_schedule_3(base_settings): - """No. 3 tests collection for Schedule. - Test File: schedule-provider-location2-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "schedule-provider-location2-example.json" - ) - inst = schedule.Schedule.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Schedule" == inst.resource_type - - impl_schedule_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Schedule" == data["resourceType"] - - inst2 = schedule.Schedule(**data) - impl_schedule_3(inst2) diff --git a/fhir/resources/tests/test_searchparameter.py b/fhir/resources/tests/test_searchparameter.py deleted file mode 100644 index 23207c29..00000000 --- a/fhir/resources/tests/test_searchparameter.py +++ /dev/null @@ -1,466 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SearchParameter -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import searchparameter - - -def impl_searchparameter_1(inst): - assert inst.base[0] == "Resource" - assert inst.code == "workflow" - assert inst.description == "Optional Extensions Element" - assert inst.experimental is True - assert inst.id == "valueset-extensions-ValueSet-workflow" - assert inst.name == "workflow" - assert inst.status == "draft" - assert inst.type == "token" - assert inst.url == ( - "http://hl7.org/fhir/SearchParameter/valueset-extensions-" "ValueSet-workflow" - ) - assert inst.version == "4.0.1" - assert inst.xpath == ( - "f:ValueSet/f:extension[@url='http://hl7.org/fhir/StructureDe" - "finition/valueset-workflowStatus'] | /f:#workflowStatus" - ) - assert inst.xpathUsage == "normal" - - -def test_searchparameter_1(base_settings): - """No. 1 tests collection for SearchParameter. - Test File: valueset-extensions-ValueSet-workflow.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "valueset-extensions-ValueSet-workflow.json" - ) - inst = searchparameter.SearchParameter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SearchParameter" == inst.resource_type - - impl_searchparameter_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SearchParameter" == data["resourceType"] - - inst2 = searchparameter.SearchParameter(**data) - impl_searchparameter_1(inst2) - - -def impl_searchparameter_2(inst): - assert inst.base[0] == "Task" - assert inst.code == "author" - assert inst.description == "Optional Extensions Element" - assert inst.experimental is True - assert inst.id == "codesystem-extensions-CodeSystem-author" - assert inst.name == "author" - assert inst.status == "draft" - assert inst.type == "string" - assert inst.url == ( - "http://hl7.org/fhir/SearchParameter/codesystem-extensions-" "CodeSystem-author" - ) - assert inst.version == "4.0.1" - assert inst.xpath == ( - "f:CodeSystem/f:extension[@url='http://hl7.org/fhir/Structure" - "Definition/codesystem-author'] | /f:#author" - ) - assert inst.xpathUsage == "normal" - - -def test_searchparameter_2(base_settings): - """No. 2 tests collection for SearchParameter. - Test File: codesystem-extensions-CodeSystem-author.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "codesystem-extensions-CodeSystem-author.json" - ) - inst = searchparameter.SearchParameter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SearchParameter" == inst.resource_type - - impl_searchparameter_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SearchParameter" == data["resourceType"] - - inst2 = searchparameter.SearchParameter(**data) - impl_searchparameter_2(inst2) - - -def impl_searchparameter_3(inst): - assert inst.base[0] == "Patient" - assert inst.code == "part-agree" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.description == ( - "Search by url for a participation agreement, which is stored" - " in a DocumentReference" - ) - assert inst.experimental is True - assert inst.expression == ( - "DocumentReference.extension('http://example.org/fhir/Structu" - "reDefinition/participation-agreement')" - ) - assert inst.id == "example-extension" - assert inst.name == "Example Search Parameter on an extension" - assert inst.publisher == "Health Level Seven International (FHIR Infrastructure)" - assert inst.status == "draft" - assert inst.target[0] == "DocumentReference" - assert inst.text.status == "generated" - assert inst.type == "reference" - assert inst.url == "http://hl7.org/fhir/SearchParameter/example-extension" - assert inst.xpath == ( - "f:DocumentReference/f:extension[@url='http://example.org/fhi" - "r/StructureDefinition/participation-agreement']" - ) - assert inst.xpathUsage == "normal" - - -def test_searchparameter_3(base_settings): - """No. 3 tests collection for SearchParameter. - Test File: searchparameter-example-extension.json - """ - filename = ( - base_settings["unittest_data_dir"] / "searchparameter-example-extension.json" - ) - inst = searchparameter.SearchParameter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SearchParameter" == inst.resource_type - - impl_searchparameter_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SearchParameter" == data["resourceType"] - - inst2 = searchparameter.SearchParameter(**data) - impl_searchparameter_3(inst2) - - -def impl_searchparameter_4(inst): - assert inst.base[0] == "QuestionnaireResponse" - assert inst.code == "item-subject" - assert inst.description == ( - "Allows searching for QuestionnaireResponses by item value " - "where the item has isSubject=true" - ) - assert inst.experimental is True - assert inst.expression == ( - "QuestionnaireResponse.item.where(hasExtension('http://hl7.or" - "g/fhir/StructureDefinition/questionnaireresponse-" - "isSubject')).answer.value.ofType(Reference)" - ) - assert inst.id == ( - "questionnaireresponse-extensions-QuestionnaireResponse-item-s..." - ) - assert inst.name == "item-subject" - assert inst.status == "draft" - assert inst.type == "reference" - assert inst.url == ( - "http://hl7.org/fhir/SearchParameter/questionnaireresponse-" - "extensions-QuestionnaireResponse-item-subject" - ) - assert inst.version == "4.0.1" - assert inst.xpathUsage == "normal" - - -def test_searchparameter_4(base_settings): - """No. 4 tests collection for SearchParameter. - Test File: questionnaireresponse-extensions-QuestionnaireResponse-item-subject.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "questionnaireresponse-extensions-QuestionnaireResponse-item-subject.json" - ) - inst = searchparameter.SearchParameter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SearchParameter" == inst.resource_type - - impl_searchparameter_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SearchParameter" == data["resourceType"] - - inst2 = searchparameter.SearchParameter(**data) - impl_searchparameter_4(inst2) - - -def impl_searchparameter_5(inst): - assert inst.base[0] == "Resource" - assert inst.code == "_filter" - assert inst.contact[0].name == "FHIR Project" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2018-07-26") - assert inst.description == ( - "This is the formal declaration for the _filter parameter, " - "documented at [http://hl7.org/fhir/search_filter.html](http:" - "//hl7.org/fhir/search_filter.html)" - ) - assert inst.experimental is False - assert inst.id == "filter" - assert inst.name == "FilterSearchParameter" - assert inst.publisher == "Health Level Seven International (FHIR Infrastructure)" - assert inst.purpose == ( - "Support combination searches when the simple name=value " - "basis of search cannot express what is required" - ) - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.type == "special" - assert inst.url == "http://hl7.org/fhir/SearchParameter/filter" - assert inst.version == "1" - - -def test_searchparameter_5(base_settings): - """No. 5 tests collection for SearchParameter. - Test File: searchparameter-filter.json - """ - filename = base_settings["unittest_data_dir"] / "searchparameter-filter.json" - inst = searchparameter.SearchParameter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SearchParameter" == inst.resource_type - - impl_searchparameter_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SearchParameter" == data["resourceType"] - - inst2 = searchparameter.SearchParameter(**data) - impl_searchparameter_5(inst2) - - -def impl_searchparameter_6(inst): - assert inst.base[0] == "Condition" - assert inst.chain[0] == "name" - assert inst.chain[1] == "identifier" - assert inst.code == "subject" - assert inst.contact[0].name == "[string]" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2013-10-23") - assert inst.description == "Search by condition subject" - assert inst.experimental is True - assert inst.expression == "Condition.subject" - assert inst.id == "example-reference" - assert inst.modifier[0] == "missing" - assert inst.name == "Example Search Parameter" - assert inst.publisher == "Health Level Seven International (FHIR Infrastructure)" - assert inst.purpose == "Need to search Condition by subject" - assert inst.status == "draft" - assert inst.target[0] == "Organization" - assert inst.text.status == "generated" - assert inst.type == "reference" - assert inst.url == "http://hl7.org/fhir/SearchParameter/example-reference" - assert inst.xpathUsage == "normal" - - -def test_searchparameter_6(base_settings): - """No. 6 tests collection for SearchParameter. - Test File: searchparameter-example-reference.json - """ - filename = ( - base_settings["unittest_data_dir"] / "searchparameter-example-reference.json" - ) - inst = searchparameter.SearchParameter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SearchParameter" == inst.resource_type - - impl_searchparameter_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SearchParameter" == data["resourceType"] - - inst2 = searchparameter.SearchParameter(**data) - impl_searchparameter_6(inst2) - - -def impl_searchparameter_7(inst): - assert inst.base[0] == "DiagnosticReport" - assert inst.code == "assessed-condition" - assert inst.description == "Condition assessed by genetic test" - assert inst.experimental is True - assert inst.expression == ( - "DiagnosticReport.extension('http://hl7.org/fhir/StructureDef" - "inition/DiagnosticReport-geneticsAssessedCondition')" - ) - assert inst.id == "diagnosticreport-genetic-DiagnosticReport-assessed-condition" - assert inst.name == "assessed-condition" - assert inst.status == "draft" - assert inst.type == "reference" - assert inst.url == ( - "http://hl7.org/fhir/SearchParameter/diagnosticreport-" - "genetic-DiagnosticReport-assessed-condition" - ) - assert inst.version == "4.0.1" - assert inst.xpathUsage == "normal" - - -def test_searchparameter_7(base_settings): - """No. 7 tests collection for SearchParameter. - Test File: diagnosticreport-genetic-DiagnosticReport-assessed-condition.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "diagnosticreport-genetic-DiagnosticReport-assessed-condition.json" - ) - inst = searchparameter.SearchParameter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SearchParameter" == inst.resource_type - - impl_searchparameter_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SearchParameter" == data["resourceType"] - - inst2 = searchparameter.SearchParameter(**data) - impl_searchparameter_7(inst2) - - -def impl_searchparameter_8(inst): - assert inst.base[0] == "Device" - assert inst.code == "din" - assert inst.description == "The donation identification number (DIN)" - assert inst.experimental is True - assert inst.expression == ( - "Device.extension('http://hl7.org/fhir/SearchParameter/device" - "-extensions-Device-din')" - ) - assert inst.id == "device-extensions-Device-din" - assert inst.name == "din" - assert inst.status == "draft" - assert inst.type == "token" - assert inst.url == ( - "http://hl7.org/fhir/SearchParameter/device-extensions-" "Device-din" - ) - assert inst.version == "4.0.1" - assert inst.xpathUsage == "normal" - - -def test_searchparameter_8(base_settings): - """No. 8 tests collection for SearchParameter. - Test File: device-extensions-Device-din.json - """ - filename = base_settings["unittest_data_dir"] / "device-extensions-Device-din.json" - inst = searchparameter.SearchParameter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SearchParameter" == inst.resource_type - - impl_searchparameter_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SearchParameter" == data["resourceType"] - - inst2 = searchparameter.SearchParameter(**data) - impl_searchparameter_8(inst2) - - -def impl_searchparameter_9(inst): - assert inst.base[0] == "Observation" - assert inst.code == "gene-identifier" - assert inst.description == "HGNC gene symbol and identifier" - assert inst.experimental is True - assert inst.expression == ( - "Observation.extension('http://hl7.org/fhir/StructureDefiniti" - "on/observation-geneticsGene')" - ) - assert inst.id == "observation-genetic-Observation-gene-identifier" - assert inst.name == "gene-identifier" - assert inst.status == "draft" - assert inst.type == "token" - assert inst.url == ( - "http://hl7.org/fhir/SearchParameter/observation-genetic-" - "Observation-gene-identifier" - ) - assert inst.version == "4.0.1" - assert inst.xpathUsage == "normal" - - -def test_searchparameter_9(base_settings): - """No. 9 tests collection for SearchParameter. - Test File: observation-genetic-Observation-gene-identifier.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "observation-genetic-Observation-gene-identifier.json" - ) - inst = searchparameter.SearchParameter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SearchParameter" == inst.resource_type - - impl_searchparameter_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SearchParameter" == data["resourceType"] - - inst2 = searchparameter.SearchParameter(**data) - impl_searchparameter_9(inst2) - - -def impl_searchparameter_10(inst): - assert inst.base[0] == "Patient" - assert inst.base[1] == "Task" - assert inst.code == "workflow" - assert inst.description == "Optional Extensions Element" - assert inst.experimental is True - assert inst.id == "codesystem-extensions-CodeSystem-workflow" - assert inst.name == "workflow" - assert inst.status == "draft" - assert inst.type == "token" - assert inst.url == ( - "http://hl7.org/fhir/SearchParameter/codesystem-extensions-" - "CodeSystem-workflow" - ) - assert inst.version == "4.0.1" - assert inst.xpath == ( - "f:CodeSystem/f:extension[@url='http://hl7.org/fhir/Structure" - "Definition/codesystem-workflowStatus'] | /f:#workflowStatus" - ) - assert inst.xpathUsage == "normal" - - -def test_searchparameter_10(base_settings): - """No. 10 tests collection for SearchParameter. - Test File: codesystem-extensions-CodeSystem-workflow.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "codesystem-extensions-CodeSystem-workflow.json" - ) - inst = searchparameter.SearchParameter.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SearchParameter" == inst.resource_type - - impl_searchparameter_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SearchParameter" == data["resourceType"] - - inst2 = searchparameter.SearchParameter(**data) - impl_searchparameter_10(inst2) diff --git a/fhir/resources/tests/test_servicerequest.py b/fhir/resources/tests/test_servicerequest.py deleted file mode 100644 index 92439564..00000000 --- a/fhir/resources/tests/test_servicerequest.py +++ /dev/null @@ -1,529 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ServiceRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import servicerequest - - -def impl_servicerequest_1(inst): - assert inst.asNeededCodeableConcept.text == "as needed to clear mucus" - assert inst.authoredOn == fhirtypes.DateTime.validate("2017-02-01T17:23:07Z") - assert inst.basedOn[0].reference == "CarePlan/gpvisit" - assert inst.code.coding[0].code == "34431008" - assert inst.code.coding[0].display == "Physiotherapy of chest (regime/therapy) " - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.contained[0].id == "signature" - assert inst.contained[1].id == "cystic-fibrosis" - assert inst.id == "physiotherapy" - assert inst.identifier[0].system == "http://goodhealth.org/placer-ids" - assert inst.identifier[0].type.coding[0].code == "PLAC" - assert inst.identifier[0].type.coding[0].display == "Placer Identifier" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].type.text == "Placer" - assert inst.identifier[0].value == "20170201-0001" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert float(inst.occurrenceTiming.repeat.duration) == float(15) - assert float(inst.occurrenceTiming.repeat.durationMax) == float(25) - assert inst.occurrenceTiming.repeat.durationUnit == "min" - assert inst.occurrenceTiming.repeat.frequency == 1 - assert inst.occurrenceTiming.repeat.frequencyMax == 4 - assert float(inst.occurrenceTiming.repeat.period) == float(1) - assert inst.occurrenceTiming.repeat.periodUnit == "d" - assert inst.reasonReference[0].reference == "#cystic-fibrosis" - assert inst.relevantHistory[0].display == "Author's Signature" - assert inst.relevantHistory[0].reference == "#signature" - assert inst.requester.display == "Dr Adam Careful" - assert inst.requester.reference == "Practitioner/example" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_servicerequest_1(base_settings): - """No. 1 tests collection for ServiceRequest. - Test File: servicerequest-example2.json - """ - filename = base_settings["unittest_data_dir"] / "servicerequest-example2.json" - inst = servicerequest.ServiceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ServiceRequest" == inst.resource_type - - impl_servicerequest_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ServiceRequest" == data["resourceType"] - - inst2 = servicerequest.ServiceRequest(**data) - impl_servicerequest_1(inst2) - - -def impl_servicerequest_2(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2017-02-01T17:23:07Z") - assert inst.code.coding[0].code == "359962006" - assert inst.code.coding[0].display == "Turning patient in bed (procedure)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.doNotPerform is True - assert inst.id == "do-not-turn" - assert inst.identifier[0].system == "http://goodhealth.org/placer-ids" - assert inst.identifier[0].value == "20170201-0002" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.priority == "stat" - assert inst.reasonReference[0].display == "Patient has a spinal fracture" - assert inst.requester.display == "Dr Adam Careful" - assert inst.requester.reference == "Practitioner/example" - assert inst.status == "active" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_servicerequest_2(base_settings): - """No. 2 tests collection for ServiceRequest. - Test File: servicerequest-example3.json - """ - filename = base_settings["unittest_data_dir"] / "servicerequest-example3.json" - inst = servicerequest.ServiceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ServiceRequest" == inst.resource_type - - impl_servicerequest_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ServiceRequest" == data["resourceType"] - - inst2 = servicerequest.ServiceRequest(**data) - impl_servicerequest_2(inst2) - - -def impl_servicerequest_3(inst): - assert inst.code.coding[0].code == "LIPID" - assert inst.code.coding[0].system == "http://acme.org/tests" - assert inst.code.text == "Lipid Panel" - assert inst.contained[0].id == "fasting" - assert inst.contained[1].id == "serum" - assert inst.encounter.reference == "Encounter/example" - assert inst.id == "lipid" - assert inst.identifier[0].system == "urn:oid:1.3.4.5.6.7" - assert inst.identifier[0].type.coding[0].code == "PLAC" - assert ( - inst.identifier[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0203" - ) - assert inst.identifier[0].type.text == "Placer" - assert inst.identifier[0].value == "2345234234234" - assert inst.intent == "original-order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "patient is afraid of needles" - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2013-05-02T16:16:00-07:00" - ) - assert inst.performer[0].reference == "Practitioner/f202" - assert inst.reasonCode[0].coding[0].code == "V173" - assert inst.reasonCode[0].coding[0].display == "Fam hx-ischem heart dis" - assert inst.reasonCode[0].coding[0].system == "http://hl7.org/fhir/sid/icd-9" - assert inst.requester.reference == "Practitioner/example" - assert inst.specimen[0].display == "Serum specimen" - assert inst.specimen[0].reference == "#serum" - assert inst.status == "active" - assert inst.subject.reference == "Patient/example" - assert inst.supportingInfo[0].display == "Fasting status" - assert inst.supportingInfo[0].reference == "#fasting" - assert inst.text.status == "generated" - - -def test_servicerequest_3(base_settings): - """No. 3 tests collection for ServiceRequest. - Test File: servicerequest-example-lipid.json - """ - filename = base_settings["unittest_data_dir"] / "servicerequest-example-lipid.json" - inst = servicerequest.ServiceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ServiceRequest" == inst.resource_type - - impl_servicerequest_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ServiceRequest" == data["resourceType"] - - inst2 = servicerequest.ServiceRequest(**data) - impl_servicerequest_3(inst2) - - -def impl_servicerequest_4(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2017-03-05") - assert inst.code.coding[0].code == "76164006" - assert inst.code.coding[0].display == "Biopsy of colon (procedure)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Biopsy of colon" - assert inst.id == "colon-biopsy" - assert inst.identifier[0].value == "12345" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.performer[0].display == "Dr Adam Careful" - assert inst.performer[0].reference == "Practitioner/example" - assert inst.requester.display == "Dr. Beverly Crusher" - assert ( - inst.requester.reference == "Practitioner/3ad0687e-f477-468c-afd5-fcc2bf897809" - ) - assert inst.requisition.system == "http://bumc.org/requisitions" - assert inst.requisition.value == "req12345" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_servicerequest_4(base_settings): - """No. 4 tests collection for ServiceRequest. - Test File: servicerequest-example-colonoscopy-bx.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "servicerequest-example-colonoscopy-bx.json" - ) - inst = servicerequest.ServiceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ServiceRequest" == inst.resource_type - - impl_servicerequest_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ServiceRequest" == data["resourceType"] - - inst2 = servicerequest.ServiceRequest(**data) - impl_servicerequest_4(inst2) - - -def impl_servicerequest_5(inst): - assert inst.code.coding[0].code == "229115003" - assert inst.code.coding[0].display == "Bench Press (regime/therapy) " - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.id == "benchpress" - assert inst.intent == "plan" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceTiming.repeat.count == 20 - assert inst.occurrenceTiming.repeat.countMax == 30 - assert inst.occurrenceTiming.repeat.frequency == 3 - assert float(inst.occurrenceTiming.repeat.period) == float(1) - assert inst.occurrenceTiming.repeat.periodUnit == "wk" - assert inst.patientInstruction == ( - "Start with 30kg 10-15 repetitions for three sets and " - "increase in increments of 5kg when you feel ready" - ) - assert inst.status == "active" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_servicerequest_5(base_settings): - """No. 5 tests collection for ServiceRequest. - Test File: servicerequest-example4.json - """ - filename = base_settings["unittest_data_dir"] / "servicerequest-example4.json" - inst = servicerequest.ServiceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ServiceRequest" == inst.resource_type - - impl_servicerequest_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ServiceRequest" == data["resourceType"] - - inst2 = servicerequest.ServiceRequest(**data) - impl_servicerequest_5(inst2) - - -def impl_servicerequest_6(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2016-08-16") - assert inst.category[0].coding[0].code == "311401005" - assert inst.category[0].coding[0].display == "Patient education (procedure)" - assert inst.category[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].text == "Education" - assert inst.code.coding[0].code == "48023004" - assert ( - inst.code.coding[0].display - == "Breast self-examination technique education (procedure)" - ) - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Health education - breast examination" - assert inst.id == "education" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate("2014-08-16") - assert inst.performer[0].display == "Pamela Educator, RN" - assert inst.reasonCode[0].text == "early detection of breast mass" - assert inst.requester.display == "Angela Care, MD" - assert inst.status == "completed" - assert inst.subject.display == "Jane Doe" - assert inst.text.status == "generated" - - -def test_servicerequest_6(base_settings): - """No. 6 tests collection for ServiceRequest. - Test File: servicerequest-example-edu.json - """ - filename = base_settings["unittest_data_dir"] / "servicerequest-example-edu.json" - inst = servicerequest.ServiceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ServiceRequest" == inst.resource_type - - impl_servicerequest_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ServiceRequest" == data["resourceType"] - - inst2 = servicerequest.ServiceRequest(**data) - impl_servicerequest_6(inst2) - - -def impl_servicerequest_7(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2018-02-20") - assert inst.code.coding[0].code == "40617009" - assert inst.code.coding[0].display == "Artificial respiration (procedure)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Mechanical Ventilation" - assert inst.id == "vent" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.orderDetail[0].coding[0].code == "243144002" - assert ( - inst.orderDetail[0].coding[0].display - == "Patient triggered inspiratory assistance (procedure)" - ) - assert inst.orderDetail[0].coding[0].system == "http://snomed.info/sct" - assert inst.orderDetail[0].text == "IPPB" - assert inst.orderDetail[1].text == ( - " Initial Settings : Sens: -1 cm H20 Pressure 15 cm H2O " - "moderate flow: Monitor VS every 15 minutes x 4 at the start" - " of mechanical ventilation, then routine for unit OR every 5" - " hr" - ) - assert inst.performer[0].display == "Dr Cecil Surgeon" - assert inst.performer[0].reference == "Practitioner/example" - assert inst.reasonCode[0].text == "chronic obstructive lung disease (COLD)" - assert inst.requester.display == "Dr. Beverly Crusher" - assert ( - inst.requester.reference == "Practitioner/3ad0687e-f477-468c-afd5-fcc2bf897809" - ) - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_servicerequest_7(base_settings): - """No. 7 tests collection for ServiceRequest. - Test File: servicerequest-example-ventilation.json - """ - filename = ( - base_settings["unittest_data_dir"] / "servicerequest-example-ventilation.json" - ) - inst = servicerequest.ServiceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ServiceRequest" == inst.resource_type - - impl_servicerequest_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ServiceRequest" == data["resourceType"] - - inst2 = servicerequest.ServiceRequest(**data) - impl_servicerequest_7(inst2) - - -def impl_servicerequest_8(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2017-03-05") - assert inst.basedOn[0].display == "Maternity care plan" - assert inst.basedOn[0].reference == "CarePlan/preg" - assert inst.code.coding[0].code == "62013009" - assert inst.code.coding[0].display == "Ambulating patient (procedure)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Ambulation" - assert inst.id == "ambulation" - assert inst.identifier[0].value == "45678" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.reasonReference[0].display == "Blood Pressure" - assert inst.reasonReference[0].reference == "Observation/blood-pressure" - assert inst.requester.display == "Dr. Beverly Crusher" - assert ( - inst.requester.reference == "Practitioner/3ad0687e-f477-468c-afd5-fcc2bf897809" - ) - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_servicerequest_8(base_settings): - """No. 8 tests collection for ServiceRequest. - Test File: servicerequest-example-ambulation.json - """ - filename = ( - base_settings["unittest_data_dir"] / "servicerequest-example-ambulation.json" - ) - inst = servicerequest.ServiceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ServiceRequest" == inst.resource_type - - impl_servicerequest_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ServiceRequest" == data["resourceType"] - - inst2 = servicerequest.ServiceRequest(**data) - impl_servicerequest_8(inst2) - - -def impl_servicerequest_9(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2016-09-20") - assert inst.bodySite[0].coding[0].code == "36701003" - assert inst.bodySite[0].coding[0].display == "Both knees (body structure)" - assert inst.bodySite[0].coding[0].system == "http://snomed.info/sct" - assert inst.bodySite[0].text == "Both knees" - assert inst.category[0].coding[0].code == "386053000" - assert inst.category[0].coding[0].display == "Evaluation procedure (procedure)" - assert inst.category[0].coding[0].system == "http://snomed.info/sct" - assert inst.category[0].text == "Evaluation" - assert inst.code.coding[0].code == "710830005" - assert ( - inst.code.coding[0].display - == "Assessment of passive range of motion (procedure)" - ) - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.code.text == "Assessment of passive range of motion" - assert inst.id == "physical-therapy" - assert inst.intent == "order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate("2016-09-27") - assert inst.performer[0].display == "Paul Therapist, PT" - assert ( - inst.reasonCode[0].text - == "assessment of mobility limitations due to osteoarthritis" - ) - assert inst.requester.display == "Ollie Ortho, MD" - assert inst.status == "completed" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - - -def test_servicerequest_9(base_settings): - """No. 9 tests collection for ServiceRequest. - Test File: servicerequest-example-pt.json - """ - filename = base_settings["unittest_data_dir"] / "servicerequest-example-pt.json" - inst = servicerequest.ServiceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ServiceRequest" == inst.resource_type - - impl_servicerequest_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ServiceRequest" == data["resourceType"] - - inst2 = servicerequest.ServiceRequest(**data) - impl_servicerequest_9(inst2) - - -def impl_servicerequest_10(inst): - assert inst.code.coding[0].code == "24627-2" - assert inst.code.coding[0].system == "http://loinc.org" - assert inst.code.text == "Chest CT" - assert inst.id == "di" - assert inst.intent == "original-order" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate( - "2013-05-08T09:33:27+07:00" - ) - assert inst.reasonCode[0].text == "Check for metastatic disease" - assert inst.requester.display == "Dr. Adam Careful" - assert inst.requester.reference == "Practitioner/example" - assert inst.status == "active" - assert inst.subject.reference == "Patient/dicom" - assert inst.text.status == "generated" - - -def test_servicerequest_10(base_settings): - """No. 10 tests collection for ServiceRequest. - Test File: servicerequest-example-di.json - """ - filename = base_settings["unittest_data_dir"] / "servicerequest-example-di.json" - inst = servicerequest.ServiceRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ServiceRequest" == inst.resource_type - - impl_servicerequest_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ServiceRequest" == data["resourceType"] - - inst2 = servicerequest.ServiceRequest(**data) - impl_servicerequest_10(inst2) diff --git a/fhir/resources/tests/test_slot.py b/fhir/resources/tests/test_slot.py deleted file mode 100644 index c4290fee..00000000 --- a/fhir/resources/tests/test_slot.py +++ /dev/null @@ -1,182 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Slot -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import slot - - -def impl_slot_1(inst): - assert inst.comment == ( - "Assessments should be performed before requesting " - "appointments in this slot." - ) - assert inst.end == fhirtypes.Instant.validate("2013-12-25T09:15:00Z") - assert inst.id == "1" - assert inst.identifier[0].system == "http://example.org/identifiers/slots" - assert inst.identifier[0].value == "123132" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.overbooked is True - assert inst.schedule.reference == "Schedule/example" - assert inst.serviceCategory[0].coding[0].code == "17" - assert inst.serviceCategory[0].coding[0].display == "General Practice" - assert inst.start == fhirtypes.Instant.validate("2013-12-25T09:00:00Z") - assert inst.status == "busy" - assert inst.text.status == "generated" - - -def test_slot_1(base_settings): - """No. 1 tests collection for Slot. - Test File: slot-example-busy.json - """ - filename = base_settings["unittest_data_dir"] / "slot-example-busy.json" - inst = slot.Slot.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Slot" == inst.resource_type - - impl_slot_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Slot" == data["resourceType"] - - inst2 = slot.Slot(**data) - impl_slot_1(inst2) - - -def impl_slot_2(inst): - assert inst.appointmentType.coding[0].code == "WALKIN" - assert ( - inst.appointmentType.coding[0].display - == "A previously unscheduled walk-in visit" - ) - assert ( - inst.appointmentType.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0276" - ) - assert inst.comment == ( - "Assessments should be performed before requesting " - "appointments in this slot." - ) - assert inst.end == fhirtypes.Instant.validate("2013-12-25T09:30:00Z") - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.schedule.reference == "Schedule/example" - assert inst.serviceCategory[0].coding[0].code == "17" - assert inst.serviceCategory[0].coding[0].display == "General Practice" - assert inst.serviceType[0].coding[0].code == "57" - assert inst.serviceType[0].coding[0].display == "Immunization" - assert inst.specialty[0].coding[0].code == "408480009" - assert inst.specialty[0].coding[0].display == "Clinical immunology" - assert inst.start == fhirtypes.Instant.validate("2013-12-25T09:15:00Z") - assert inst.status == "free" - assert inst.text.status == "generated" - - -def test_slot_2(base_settings): - """No. 2 tests collection for Slot. - Test File: slot-example.json - """ - filename = base_settings["unittest_data_dir"] / "slot-example.json" - inst = slot.Slot.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Slot" == inst.resource_type - - impl_slot_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Slot" == data["resourceType"] - - inst2 = slot.Slot(**data) - impl_slot_2(inst2) - - -def impl_slot_3(inst): - assert inst.comment == "Dr Careful is out of the office" - assert inst.end == fhirtypes.Instant.validate("2013-12-25T09:45:00Z") - assert inst.id == "3" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.schedule.reference == "Schedule/example" - assert inst.serviceCategory[0].coding[0].code == "17" - assert inst.serviceCategory[0].coding[0].display == "General Practice" - assert inst.start == fhirtypes.Instant.validate("2013-12-25T09:30:00Z") - assert inst.status == "busy-unavailable" - assert inst.text.status == "generated" - - -def test_slot_3(base_settings): - """No. 3 tests collection for Slot. - Test File: slot-example-unavailable.json - """ - filename = base_settings["unittest_data_dir"] / "slot-example-unavailable.json" - inst = slot.Slot.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Slot" == inst.resource_type - - impl_slot_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Slot" == data["resourceType"] - - inst2 = slot.Slot(**data) - impl_slot_3(inst2) - - -def impl_slot_4(inst): - assert inst.comment == "Dr Careful is out of the office" - assert inst.end == fhirtypes.Instant.validate("2013-12-25T10:00:00Z") - assert inst.id == "2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.schedule.reference == "Schedule/example" - assert inst.serviceCategory[0].coding[0].code == "17" - assert inst.serviceCategory[0].coding[0].display == "General Practice" - assert inst.start == fhirtypes.Instant.validate("2013-12-25T09:45:00Z") - assert inst.status == "busy-tentative" - assert inst.text.status == "generated" - - -def test_slot_4(base_settings): - """No. 4 tests collection for Slot. - Test File: slot-example-tentative.json - """ - filename = base_settings["unittest_data_dir"] / "slot-example-tentative.json" - inst = slot.Slot.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Slot" == inst.resource_type - - impl_slot_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Slot" == data["resourceType"] - - inst2 = slot.Slot(**data) - impl_slot_4(inst2) diff --git a/fhir/resources/tests/test_specimen.py b/fhir/resources/tests/test_specimen.py deleted file mode 100644 index c1906c35..00000000 --- a/fhir/resources/tests/test_specimen.py +++ /dev/null @@ -1,279 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Specimen -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import specimen - - -def impl_specimen_1(inst): - assert inst.accessionIdentifier.system == "http://lab.acme.org/specimens/2011" - assert inst.accessionIdentifier.value == "X352356-ISO1" - assert inst.collection.collectedDateTime == fhirtypes.DateTime.validate( - "2015-08-16T07:03:00Z" - ) - assert inst.collection.collector.reference == "Practitioner/f202" - assert inst.collection.method.coding[0].code == "BAP" - assert ( - inst.collection.method.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0488" - ) - assert inst.contained[0].id == "stool" - assert inst.id == "isolate" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "Patient dropped off specimen" - assert inst.parent[0].reference == "#stool" - assert inst.receivedTime == fhirtypes.DateTime.validate("2015-08-18T07:03:00Z") - assert inst.status == "available" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "429951000124103" - assert inst.type.coding[0].display == "Bacterial isolate specimen" - assert inst.type.coding[0].system == "http://snomed.info/sct" - - -def test_specimen_1(base_settings): - """No. 1 tests collection for Specimen. - Test File: specimen-example-isolate.json - """ - filename = base_settings["unittest_data_dir"] / "specimen-example-isolate.json" - inst = specimen.Specimen.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Specimen" == inst.resource_type - - impl_specimen_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Specimen" == data["resourceType"] - - inst2 = specimen.Specimen(**data) - impl_specimen_1(inst2) - - -def impl_specimen_2(inst): - assert inst.accessionIdentifier.system == "https://vetmed.iastate.edu/vdl" - assert inst.accessionIdentifier.value == "20171120-1234" - assert inst.collection.collectedDateTime == fhirtypes.DateTime.validate( - "2017-11-14" - ) - assert inst.collection.collector.display == "James Herriot, FRCVS" - assert inst.container[0].type.coding[0].code == "RTT" - assert inst.container[0].type.coding[0].display == "Red Top Tube" - assert inst.container[0].type.coding[0].system == "https://vetmed.iastate.edu/vdl" - assert inst.container[0].type.text == "Red Top Blood Collection Tube" - assert inst.id == "pooled-serum" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "Pooled serum sample from 30 individuals" - assert inst.subject.reference == "Group/herd1" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "Serum sample, pooled" - assert inst.type.coding[0].display == "Serum sample, pooled" - assert inst.type.coding[0].system == "https://vetmed.iastate.edu/vdl" - assert inst.type.text == "Pooled serum sample" - - -def test_specimen_2(base_settings): - """No. 2 tests collection for Specimen. - Test File: specimen-example-pooled-serum.json - """ - filename = base_settings["unittest_data_dir"] / "specimen-example-pooled-serum.json" - inst = specimen.Specimen.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Specimen" == inst.resource_type - - impl_specimen_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Specimen" == data["resourceType"] - - inst2 = specimen.Specimen(**data) - impl_specimen_2(inst2) - - -def impl_specimen_3(inst): - assert inst.accessionIdentifier.system == "http://lab.acme.org/specimens/2015" - assert inst.accessionIdentifier.value == "X352356" - assert inst.collection.collectedDateTime == fhirtypes.DateTime.validate( - "2015-08-18T07:03:00Z" - ) - assert inst.collection.collector.reference == "Practitioner/f202" - assert inst.container[0].capacity.unit == "mls" - assert float(inst.container[0].capacity.value) == float(50) - assert inst.container[0].specimenQuantity.unit == "mls" - assert float(inst.container[0].specimenQuantity.value) == float(10) - assert inst.container[0].type.text == "Non-sterile specimen container" - assert inst.id == "vma-urine" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.processing[0].additive[0].display == "6 N HCl" - assert inst.processing[0].description == "Acidify to pH < 3.0 with 6 N HCl." - assert inst.processing[0].procedure.coding[0].code == "ACID" - assert ( - inst.processing[0].procedure.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0373" - ) - assert inst.processing[0].timeDateTime == fhirtypes.DateTime.validate( - "2015-08-18T08:10:00Z" - ) - assert inst.receivedTime == fhirtypes.DateTime.validate("2015-08-18T07:03:00Z") - assert inst.status == "available" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "RANDU" - assert inst.type.coding[0].display == "Urine, Random" - assert inst.type.coding[0].system == "http://terminology.hl7.org/CodeSystem/v2-0487" - - -def test_specimen_3(base_settings): - """No. 3 tests collection for Specimen. - Test File: specimen-example-urine.json - """ - filename = base_settings["unittest_data_dir"] / "specimen-example-urine.json" - inst = specimen.Specimen.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Specimen" == inst.resource_type - - impl_specimen_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Specimen" == data["resourceType"] - - inst2 = specimen.Specimen(**data) - impl_specimen_3(inst2) - - -def impl_specimen_4(inst): - assert inst.accessionIdentifier.system == "http://acme.com/labs/accession-ids" - assert inst.accessionIdentifier.value == "20150816-00124" - assert inst.collection.collectedDateTime == fhirtypes.DateTime.validate( - "2015-08-16T06:40:17Z" - ) - assert inst.collection.collector.reference == "Practitioner/f202" - assert inst.container[0].type.coding[0].code == "SST" - assert inst.container[0].type.coding[0].display == "Serum Separator Tube" - assert inst.container[0].type.coding[0].system == "http://acme.com/labs" - assert inst.id == "sst" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.request[0].reference == "ServiceRequest/ft4" - assert inst.subject.reference == "Patient/pat2" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "119364003" - assert inst.type.coding[0].display == "Serum sample" - assert inst.type.coding[0].system == "http://snomed.info/sct" - - -def test_specimen_4(base_settings): - """No. 4 tests collection for Specimen. - Test File: specimen-example-serum.json - """ - filename = base_settings["unittest_data_dir"] / "specimen-example-serum.json" - inst = specimen.Specimen.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Specimen" == inst.resource_type - - impl_specimen_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Specimen" == data["resourceType"] - - inst2 = specimen.Specimen(**data) - impl_specimen_4(inst2) - - -def impl_specimen_5(inst): - assert inst.accessionIdentifier.system == "http://lab.acme.org/specimens/2011" - assert inst.accessionIdentifier.value == "X352356" - assert inst.collection.bodySite.coding[0].code == "49852007" - assert ( - inst.collection.bodySite.coding[0].display - == "Structure of median cubital vein (body structure)" - ) - assert inst.collection.bodySite.coding[0].system == "http://snomed.info/sct" - assert inst.collection.bodySite.text == "Right median cubital vein" - assert inst.collection.collectedDateTime == fhirtypes.DateTime.validate( - "2011-05-30T06:15:00Z" - ) - assert inst.collection.collector.reference == "Practitioner/example" - assert inst.collection.method.coding[0].code == "LNV" - assert ( - inst.collection.method.coding[0].system - == "http://terminology.hl7.org/CodeSystem/v2-0488" - ) - assert inst.collection.quantity.unit == "mL" - assert float(inst.collection.quantity.value) == float(6) - assert inst.contained[0].id == "hep" - assert inst.container[0].additiveReference.reference == "#hep" - assert inst.container[0].capacity.unit == "mL" - assert float(inst.container[0].capacity.value) == float(10) - assert inst.container[0].description == "Green Gel tube" - assert inst.container[0].identifier[0].value == "48736-15394-75465" - assert inst.container[0].specimenQuantity.unit == "mL" - assert float(inst.container[0].specimenQuantity.value) == float(6) - assert inst.container[0].type.text == "Vacutainer" - assert inst.id == "101" - assert inst.identifier[0].system == "http://ehr.acme.org/identifiers/collections" - assert inst.identifier[0].value == "23234352356" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.note[0].text == "Specimen is grossly lipemic" - assert inst.receivedTime == fhirtypes.DateTime.validate("2011-03-04T07:03:00Z") - assert inst.request[0].reference == "ServiceRequest/example" - assert inst.status == "available" - assert inst.subject.display == "Peter Patient" - assert inst.subject.reference == "Patient/example" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "122555007" - assert inst.type.coding[0].display == "Venous blood specimen" - assert inst.type.coding[0].system == "http://snomed.info/sct" - - -def test_specimen_5(base_settings): - """No. 5 tests collection for Specimen. - Test File: specimen-example.json - """ - filename = base_settings["unittest_data_dir"] / "specimen-example.json" - inst = specimen.Specimen.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Specimen" == inst.resource_type - - impl_specimen_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Specimen" == data["resourceType"] - - inst2 = specimen.Specimen(**data) - impl_specimen_5(inst2) diff --git a/fhir/resources/tests/test_specimendefinition.py b/fhir/resources/tests/test_specimendefinition.py deleted file mode 100644 index 51c9ef92..00000000 --- a/fhir/resources/tests/test_specimendefinition.py +++ /dev/null @@ -1,229 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SpecimenDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import specimendefinition - - -def impl_specimendefinition_1(inst): - assert inst.id == "2364" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patientPreparation[0].text == "12 hour fasting" - assert inst.patientPreparation[1].coding[0].code == "263678003" - assert inst.patientPreparation[1].coding[0].display == "At rest" - assert inst.patientPreparation[1].coding[0].system == "http://snomed.info/sct" - assert inst.text.status == "generated" - assert inst.timeAspect == "preferrably morning time" - assert inst.typeCollected.coding[0].code == "122555007" - assert inst.typeCollected.coding[0].display == "Venous blood specimen" - assert inst.typeCollected.coding[0].system == "http://snomed.info/sct" - assert inst.typeTested[0].container.cap.coding[0].code == "yellow" - assert inst.typeTested[0].container.cap.coding[0].display == "yellow cap" - assert ( - inst.typeTested[0].container.cap.coding[0].system == "urn:iso:std:iso:6710:2017" - ) - assert inst.typeTested[0].container.material.coding[0].code == "61088005" - assert inst.typeTested[0].container.material.coding[0].display == "plastic" - assert ( - inst.typeTested[0].container.material.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.typeTested[0].container.minimumVolumeQuantity.code == "mL" - assert ( - inst.typeTested[0].container.minimumVolumeQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.typeTested[0].container.minimumVolumeQuantity.unit == "ml" - assert float(inst.typeTested[0].container.minimumVolumeQuantity.value) == float(2) - assert inst.typeTested[0].container.type.coding[0].code == "702281005" - assert inst.typeTested[0].container.type.coding[0].display == ( - "Evacuated blood collection tube, thrombin/clot activator/gel" " separator" - ) - assert ( - inst.typeTested[0].container.type.coding[0].system == "http://snomed.info/sct" - ) - assert inst.typeTested[0].handling[0].maxDuration.code == "min" - assert ( - inst.typeTested[0].handling[0].maxDuration.system == "http://unitsofmeasure.org" - ) - assert inst.typeTested[0].handling[0].maxDuration.unit == "minute" - assert float(inst.typeTested[0].handling[0].maxDuration.value) == float(60) - assert ( - inst.typeTested[0].handling[0].temperatureQualifier.text - == "Ambient temperature" - ) - assert inst.typeTested[0].handling[0].temperatureRange.high.code == "Cel" - assert ( - inst.typeTested[0].handling[0].temperatureRange.high.system - == "http://unitsofmeasure.org" - ) - assert inst.typeTested[0].handling[0].temperatureRange.high.unit == "°C" - assert float(inst.typeTested[0].handling[0].temperatureRange.high.value) == float( - 25 - ) - assert inst.typeTested[0].handling[0].temperatureRange.low.code == "Cel" - assert ( - inst.typeTested[0].handling[0].temperatureRange.low.system - == "http://unitsofmeasure.org" - ) - assert inst.typeTested[0].handling[0].temperatureRange.low.unit == "°C" - assert float(inst.typeTested[0].handling[0].temperatureRange.low.value) == float(15) - assert inst.typeTested[0].handling[1].maxDuration.code == "h" - assert ( - inst.typeTested[0].handling[1].maxDuration.system == "http://unitsofmeasure.org" - ) - assert inst.typeTested[0].handling[1].maxDuration.unit == "hour" - assert float(inst.typeTested[0].handling[1].maxDuration.value) == float(8) - assert ( - inst.typeTested[0].handling[1].temperatureQualifier.text - == "Refrigerated temperature" - ) - assert inst.typeTested[0].handling[1].temperatureRange.high.code == "Cel" - assert ( - inst.typeTested[0].handling[1].temperatureRange.high.system - == "http://unitsofmeasure.org" - ) - assert inst.typeTested[0].handling[1].temperatureRange.high.unit == "°C" - assert float(inst.typeTested[0].handling[1].temperatureRange.high.value) == float(8) - assert inst.typeTested[0].handling[1].temperatureRange.low.code == "Cel" - assert ( - inst.typeTested[0].handling[1].temperatureRange.low.system - == "http://unitsofmeasure.org" - ) - assert inst.typeTested[0].handling[1].temperatureRange.low.unit == "°C" - assert float(inst.typeTested[0].handling[1].temperatureRange.low.value) == float(2) - assert inst.typeTested[0].preference == "preferred" - assert inst.typeTested[0].type.coding[0].code == "119364003" - assert inst.typeTested[0].type.coding[0].display == "Serum specimen" - assert inst.typeTested[0].type.coding[0].system == "http://snomed.info/sct" - assert inst.typeTested[1].container.cap.coding[0].code == "green" - assert inst.typeTested[1].container.cap.coding[0].display == "green cap" - assert ( - inst.typeTested[1].container.cap.coding[0].system == "urn:iso:std:iso:6710:2017" - ) - assert inst.typeTested[1].container.material.coding[0].code == "32039001" - assert inst.typeTested[1].container.material.coding[0].display == "glass" - assert ( - inst.typeTested[1].container.material.coding[0].system - == "http://snomed.info/sct" - ) - assert inst.typeTested[1].container.minimumVolumeQuantity.code == "mL" - assert ( - inst.typeTested[1].container.minimumVolumeQuantity.system - == "http://unitsofmeasure.org" - ) - assert inst.typeTested[1].container.minimumVolumeQuantity.unit == "ml" - assert float(inst.typeTested[1].container.minimumVolumeQuantity.value) == float(2) - assert inst.typeTested[1].container.type.coding[0].code == "767390000" - assert inst.typeTested[1].container.type.coding[0].display == ( - "Evacuated blood collection tube with heparin lithium and gel" " separator" - ) - assert ( - inst.typeTested[1].container.type.coding[0].system == "http://snomed.info/sct" - ) - assert inst.typeTested[1].handling[0].maxDuration.code == "min" - assert ( - inst.typeTested[1].handling[0].maxDuration.system == "http://unitsofmeasure.org" - ) - assert inst.typeTested[1].handling[0].maxDuration.unit == "minute" - assert float(inst.typeTested[1].handling[0].maxDuration.value) == float(60) - assert ( - inst.typeTested[1].handling[0].temperatureQualifier.text - == "Ambient temperature" - ) - assert inst.typeTested[1].handling[0].temperatureRange.high.code == "Cel" - assert ( - inst.typeTested[1].handling[0].temperatureRange.high.system - == "http://unitsofmeasure.org" - ) - assert inst.typeTested[1].handling[0].temperatureRange.high.unit == "°C" - assert float(inst.typeTested[1].handling[0].temperatureRange.high.value) == float( - 25 - ) - assert inst.typeTested[1].handling[0].temperatureRange.low.code == "Cel" - assert ( - inst.typeTested[1].handling[0].temperatureRange.low.system - == "http://unitsofmeasure.org" - ) - assert inst.typeTested[1].handling[0].temperatureRange.low.unit == "°C" - assert float(inst.typeTested[1].handling[0].temperatureRange.low.value) == float(15) - assert inst.typeTested[1].handling[1].maxDuration.code == "h" - assert ( - inst.typeTested[1].handling[1].maxDuration.system == "http://unitsofmeasure.org" - ) - assert inst.typeTested[1].handling[1].maxDuration.unit == "hour" - assert float(inst.typeTested[1].handling[1].maxDuration.value) == float(8) - assert ( - inst.typeTested[1].handling[1].temperatureQualifier.text - == "Refrigerated temperature" - ) - assert inst.typeTested[1].handling[1].temperatureRange.high.code == "Cel" - assert ( - inst.typeTested[1].handling[1].temperatureRange.high.system - == "http://unitsofmeasure.org" - ) - assert inst.typeTested[1].handling[1].temperatureRange.high.unit == "°C" - assert float(inst.typeTested[1].handling[1].temperatureRange.high.value) == float(8) - assert inst.typeTested[1].handling[1].temperatureRange.low.code == "Cel" - assert ( - inst.typeTested[1].handling[1].temperatureRange.low.system - == "http://unitsofmeasure.org" - ) - assert inst.typeTested[1].handling[1].temperatureRange.low.unit == "°C" - assert float(inst.typeTested[1].handling[1].temperatureRange.low.value) == float(2) - assert inst.typeTested[1].preference == "alternate" - assert inst.typeTested[1].rejectionCriterion[0].coding[0].code == "insufficient" - assert ( - inst.typeTested[1].rejectionCriterion[0].coding[0].display - == "insufficient specimen volume" - ) - assert ( - inst.typeTested[1].rejectionCriterion[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/rejection-criteria" - ) - assert inst.typeTested[1].rejectionCriterion[1].coding[0].code == "hemolized" - assert ( - inst.typeTested[1].rejectionCriterion[1].coding[0].display - == "hemolized specimen" - ) - assert ( - inst.typeTested[1].rejectionCriterion[1].coding[0].system - == "http://terminology.hl7.org/CodeSystem/rejection-criteria" - ) - assert inst.typeTested[1].type.coding[0].code == "119361006" - assert inst.typeTested[1].type.coding[0].display == "Plasma specimen" - assert inst.typeTested[1].type.coding[0].system == "http://snomed.info/sct" - - -def test_specimendefinition_1(base_settings): - """No. 1 tests collection for SpecimenDefinition. - Test File: specimendefinition-example-serum-plasma.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "specimendefinition-example-serum-plasma.json" - ) - inst = specimendefinition.SpecimenDefinition.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SpecimenDefinition" == inst.resource_type - - impl_specimendefinition_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SpecimenDefinition" == data["resourceType"] - - inst2 = specimendefinition.SpecimenDefinition(**data) - impl_specimendefinition_1(inst2) diff --git a/fhir/resources/tests/test_structuremap.py b/fhir/resources/tests/test_structuremap.py deleted file mode 100644 index 047f4644..00000000 --- a/fhir/resources/tests/test_structuremap.py +++ /dev/null @@ -1,177 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/StructureMap -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import structuremap - - -def impl_structuremap_1(inst): - assert inst.group[0].input[0].mode == "source" - assert inst.group[0].input[0].name == "source" - assert inst.group[0].input[0].type == "ActivityDefinition" - assert inst.group[0].input[1].mode == "target" - assert inst.group[0].input[1].name == "target" - assert inst.group[0].input[1].type == "SupplyRequest" - assert inst.group[0].name == "main" - assert inst.group[0].rule[0].name == "status" - assert inst.group[0].rule[0].source[0].context == "source" - assert inst.group[0].rule[0].source[0].element == "id" - assert inst.group[0].rule[0].source[0].variable == "a" - assert inst.group[0].rule[0].target[0].context == "target" - assert inst.group[0].rule[0].target[0].contextType == "variable" - assert inst.group[0].rule[0].target[0].element == "status" - assert inst.group[0].rule[0].target[0].parameter[0].valueString == "'draft'" - assert inst.group[0].rule[0].target[0].transform == "evaluate" - assert inst.group[0].rule[1].name == "category" - assert inst.group[0].rule[1].source[0].context == "source" - assert inst.group[0].rule[1].source[0].element == "id" - assert inst.group[0].rule[1].source[0].variable == "a" - assert inst.group[0].rule[1].target[0].context == "target" - assert inst.group[0].rule[1].target[0].contextType == "variable" - assert inst.group[0].rule[1].target[0].element == "category" - assert inst.group[0].rule[1].target[0].parameter[0].valueString == "'non-stock'" - assert inst.group[0].rule[1].target[0].transform == "evaluate" - assert inst.group[0].rule[2].name == "priority" - assert inst.group[0].rule[2].source[0].context == "source" - assert inst.group[0].rule[2].source[0].element == "id" - assert inst.group[0].rule[2].source[0].variable == "a" - assert inst.group[0].rule[2].target[0].context == "target" - assert inst.group[0].rule[2].target[0].contextType == "variable" - assert inst.group[0].rule[2].target[0].element == "priority" - assert inst.group[0].rule[2].target[0].parameter[0].valueString == "'routine'" - assert inst.group[0].rule[2].target[0].transform == "evaluate" - assert inst.group[0].rule[3].name == "quantity" - assert inst.group[0].rule[3].source[0].context == "source" - assert inst.group[0].rule[3].source[0].element == "quantity" - assert inst.group[0].rule[3].source[0].variable == "a" - assert inst.group[0].rule[3].target[0].context == "target" - assert inst.group[0].rule[3].target[0].contextType == "variable" - assert inst.group[0].rule[3].target[0].element == "category" - assert inst.group[0].rule[3].target[0].transform == "copy" - assert inst.group[0].rule[4].name == "item" - assert inst.group[0].rule[4].source[0].context == "source" - assert inst.group[0].rule[4].source[0].element == "code" - assert inst.group[0].rule[4].source[0].variable == "a" - assert inst.group[0].rule[4].target[0].context == "target" - assert inst.group[0].rule[4].target[0].contextType == "variable" - assert inst.group[0].rule[4].target[0].element == "orderedItem.itemCodeableConcept" - assert inst.group[0].rule[4].target[0].transform == "copy" - assert inst.group[0].rule[5].name == "when" - assert inst.group[0].rule[5].source[0].context == "source" - assert inst.group[0].rule[5].source[0].element == "id" - assert inst.group[0].rule[5].source[0].variable == "a" - assert inst.group[0].rule[5].target[0].context == "target" - assert inst.group[0].rule[5].target[0].contextType == "variable" - assert inst.group[0].rule[5].target[0].element == "occurrenceDateTime" - assert inst.group[0].rule[5].target[0].parameter[0].valueString == "now()" - assert inst.group[0].rule[5].target[0].transform == "evaluate" - assert inst.group[0].rule[6].name == "authoredOn" - assert inst.group[0].rule[6].source[0].context == "source" - assert inst.group[0].rule[6].source[0].element == "id" - assert inst.group[0].rule[6].source[0].variable == "a" - assert inst.group[0].rule[6].target[0].context == "target" - assert inst.group[0].rule[6].target[0].contextType == "variable" - assert inst.group[0].rule[6].target[0].element == "authoredOn" - assert inst.group[0].rule[6].target[0].parameter[0].valueString == "now()" - assert inst.group[0].rule[6].target[0].transform == "evaluate" - assert inst.group[0].typeMode == "none" - assert inst.id == "supplyrequest-transform" - assert inst.name == "Transform from an ActivityDefinition to a SupplyRequest" - assert inst.status == "draft" - assert inst.structure[0].mode == "source" - assert ( - inst.structure[0].url - == "http://hl7.org/fhir/StructureDefinition/activitydefinition" - ) - assert inst.structure[1].mode == "target" - assert ( - inst.structure[1].url == "http://hl7.org/fhir/StructureDefinition/supplyrequest" - ) - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/StructureMap/supplyrequest-transform" - - -def test_structuremap_1(base_settings): - """No. 1 tests collection for StructureMap. - Test File: structuremap-supplyrequest-transform.json - """ - filename = ( - base_settings["unittest_data_dir"] / "structuremap-supplyrequest-transform.json" - ) - inst = structuremap.StructureMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "StructureMap" == inst.resource_type - - impl_structuremap_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "StructureMap" == data["resourceType"] - - inst2 = structuremap.StructureMap(**data) - impl_structuremap_1(inst2) - - -def impl_structuremap_2(inst): - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2017-03-09") - assert inst.description == "Example Structure Map" - assert inst.group[0].documentation == "test -> testValue" - assert inst.group[0].input[0].mode == "source" - assert inst.group[0].input[0].name == "test" - assert inst.group[0].name == "Examples" - assert inst.group[0].rule[0].name == "rule1" - assert inst.group[0].rule[0].source[0].context == "Source" - assert inst.group[0].rule[0].source[0].element == "test" - assert inst.group[0].rule[0].source[0].type == "SourceClassA" - assert inst.group[0].rule[0].source[0].variable == "t" - assert inst.group[0].rule[0].target[0].context == "Destination" - assert inst.group[0].rule[0].target[0].contextType == "variable" - assert inst.group[0].rule[0].target[0].element == "testValue" - assert inst.group[0].rule[0].target[0].transform == "copy" - assert inst.group[0].typeMode == "none" - assert inst.id == "example" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:37843577-95fb-4adb-84c0-8837188a7bf3" - assert inst.jurisdiction[0].coding[0].code == "009" - assert inst.jurisdiction[0].coding[0].display == "Oceania" - assert ( - inst.jurisdiction[0].coding[0].system - == "http://unstats.un.org/unsd/methods/m49/m49.htm" - ) - assert inst.name == "ExampleMap" - assert inst.publisher == "HL7 FHIR Standard" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "Example Map" - assert inst.url == "http://hl7.org/fhir/StructureMap/example" - assert inst.version == "0.1" - - -def test_structuremap_2(base_settings): - """No. 2 tests collection for StructureMap. - Test File: structuremap-example.json - """ - filename = base_settings["unittest_data_dir"] / "structuremap-example.json" - inst = structuremap.StructureMap.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "StructureMap" == inst.resource_type - - impl_structuremap_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "StructureMap" == data["resourceType"] - - inst2 = structuremap.StructureMap(**data) - impl_structuremap_2(inst2) diff --git a/fhir/resources/tests/test_subscription.py b/fhir/resources/tests/test_subscription.py deleted file mode 100644 index f123deaa..00000000 --- a/fhir/resources/tests/test_subscription.py +++ /dev/null @@ -1,105 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Subscription -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import subscription - - -def impl_subscription_1(inst): - assert ( - inst.channel.endpoint - == "https://biliwatch.com/customers/mount-auburn-miu/on-result" - ) - assert inst.channel.header[0] == "Authorization: Bearer secret-token-abc-123" - assert inst.channel.payload == "application/fhir+json" - assert inst.channel.type == "rest-hook" - assert inst.contact[0].system == "phone" - assert inst.contact[0].value == "ext 4123" - assert inst.criteria == "Observation?code=http://loinc.org|1975-2" - assert inst.end == fhirtypes.Instant.validate("2021-01-01T00:00:00Z") - assert inst.error == "Socket Error 10060 - can't connect to host" - assert inst.id == "example-error" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.reason == "Monitor new neonatal function" - assert inst.status == "error" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_subscription_1(base_settings): - """No. 1 tests collection for Subscription. - Test File: subscription-example-error.json - """ - filename = base_settings["unittest_data_dir"] / "subscription-example-error.json" - inst = subscription.Subscription.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Subscription" == inst.resource_type - - impl_subscription_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Subscription" == data["resourceType"] - - inst2 = subscription.Subscription(**data) - impl_subscription_1(inst2) - - -def impl_subscription_2(inst): - assert ( - inst.channel.endpoint - == "https://biliwatch.com/customers/mount-auburn-miu/on-result" - ) - assert inst.channel.header[0] == "Authorization: Bearer secret-token-abc-123" - assert inst.channel.payload == "application/fhir+json" - assert inst.channel.type == "rest-hook" - assert inst.contact[0].system == "phone" - assert inst.contact[0].value == "ext 4123" - assert inst.criteria == "Observation?code=http://loinc.org|1975-2" - assert inst.end == fhirtypes.Instant.validate("2021-01-01T00:00:00Z") - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.reason == "Monitor new neonatal function" - assert inst.status == "requested" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_subscription_2(base_settings): - """No. 2 tests collection for Subscription. - Test File: subscription-example.json - """ - filename = base_settings["unittest_data_dir"] / "subscription-example.json" - inst = subscription.Subscription.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Subscription" == inst.resource_type - - impl_subscription_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Subscription" == data["resourceType"] - - inst2 = subscription.Subscription(**data) - impl_subscription_2(inst2) diff --git a/fhir/resources/tests/test_substance.py b/fhir/resources/tests/test_substance.py deleted file mode 100644 index e02ae077..00000000 --- a/fhir/resources/tests/test_substance.py +++ /dev/null @@ -1,284 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Substance -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import substance - - -def impl_substance_1(inst): - assert inst.category[0].coding[0].code == "chemical" - assert inst.category[0].coding[0].display == "Chemical" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/substance-category" - ) - assert inst.code.coding[0].code == "333346007" - assert inst.code.coding[0].display == "Silver nitrate 20% solution (product)" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.description == "Solution for silver nitrate stain" - assert inst.id == "f204" - assert inst.identifier[0].system == "http://acme.org/identifiers/substances" - assert inst.identifier[0].value == "15970" - assert inst.instance[0].expiry == fhirtypes.DateTime.validate("2018-01-01") - assert ( - inst.instance[0].identifier.system - == "http://acme.org/identifiers/substances/lot" - ) - assert inst.instance[0].identifier.value == "AB94687" - assert inst.instance[0].quantity.code == "mL" - assert inst.instance[0].quantity.system == "http://unitsofmeasure.org" - assert inst.instance[0].quantity.unit == "mL" - assert float(inst.instance[0].quantity.value) == float(100) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_substance_1(base_settings): - """No. 1 tests collection for Substance. - Test File: substance-example-silver-nitrate-product.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "substance-example-silver-nitrate-product.json" - ) - inst = substance.Substance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Substance" == inst.resource_type - - impl_substance_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Substance" == data["resourceType"] - - inst2 = substance.Substance(**data) - impl_substance_1(inst2) - - -def impl_substance_2(inst): - assert inst.category[0].coding[0].code == "drug" - assert inst.category[0].coding[0].display == "Drug or Medicament" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/substance-category" - ) - assert inst.code.coding[0].code == "392259005" - assert inst.code.coding[0].display == ( - "Amoxicillin + clavulanate potassium 875mg/125mg tablet " "(product)" - ) - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.contained[0].id == "ingr1" - assert inst.contained[1].id == "ingr2" - assert inst.description == "Augmentin 875" - assert inst.id == "f205" - assert inst.ingredient[0].quantity.denominator.code == "mg" - assert inst.ingredient[0].quantity.denominator.system == "http://unitsofmeasure.org" - assert inst.ingredient[0].quantity.denominator.unit == "mg" - assert float(inst.ingredient[0].quantity.denominator.value) == float(1000) - assert inst.ingredient[0].quantity.numerator.code == "mg" - assert inst.ingredient[0].quantity.numerator.system == "http://unitsofmeasure.org" - assert inst.ingredient[0].quantity.numerator.unit == "mg" - assert float(inst.ingredient[0].quantity.numerator.value) == float(875) - assert inst.ingredient[0].substanceReference.reference == "#ingr1" - assert inst.ingredient[1].quantity.denominator.code == "mg" - assert inst.ingredient[1].quantity.denominator.system == "http://unitsofmeasure.org" - assert inst.ingredient[1].quantity.denominator.unit == "mg" - assert float(inst.ingredient[1].quantity.denominator.value) == float(1000) - assert inst.ingredient[1].quantity.numerator.code == "mg" - assert inst.ingredient[1].quantity.numerator.system == "http://unitsofmeasure.org" - assert inst.ingredient[1].quantity.numerator.unit == "mg" - assert float(inst.ingredient[1].quantity.numerator.value) == float(125) - assert inst.ingredient[1].substanceReference.reference == "#ingr2" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_substance_2(base_settings): - """No. 2 tests collection for Substance. - Test File: substance-example-amoxicillin-clavulanate.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "substance-example-amoxicillin-clavulanate.json" - ) - inst = substance.Substance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Substance" == inst.resource_type - - impl_substance_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Substance" == data["resourceType"] - - inst2 = substance.Substance(**data) - impl_substance_2(inst2) - - -def impl_substance_3(inst): - assert inst.category[0].coding[0].code == "chemical" - assert inst.category[0].coding[0].display == "Chemical" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/substance-category" - ) - assert inst.code.coding[0].code == "88480006" - assert inst.code.coding[0].display == "Potassium" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.id == "f203" - assert inst.identifier[0].system == "http://acme.org/identifiers/substances" - assert inst.identifier[0].value == "1234" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_substance_3(base_settings): - """No. 3 tests collection for Substance. - Test File: substance-example-f203-potassium.json - """ - filename = ( - base_settings["unittest_data_dir"] / "substance-example-f203-potassium.json" - ) - inst = substance.Substance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Substance" == inst.resource_type - - impl_substance_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Substance" == data["resourceType"] - - inst2 = substance.Substance(**data) - impl_substance_3(inst2) - - -def impl_substance_4(inst): - assert inst.code.coding[0].code == "406466009" - assert inst.code.coding[0].display == "House dust allergen" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.id == "f201" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_substance_4(base_settings): - """No. 4 tests collection for Substance. - Test File: substance-example-f201-dust.json - """ - filename = base_settings["unittest_data_dir"] / "substance-example-f201-dust.json" - inst = substance.Substance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Substance" == inst.resource_type - - impl_substance_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Substance" == data["resourceType"] - - inst2 = substance.Substance(**data) - impl_substance_4(inst2) - - -def impl_substance_5(inst): - assert inst.category[0].coding[0].code == "allergen" - assert inst.category[0].coding[0].display == "Allergen" - assert ( - inst.category[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/substance-category" - ) - assert inst.code.text == "apitoxin (Honey Bee Venom)" - assert inst.id == "example" - assert inst.identifier[0].system == "http://acme.org/identifiers/substances" - assert inst.identifier[0].value == "1463" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_substance_5(base_settings): - """No. 5 tests collection for Substance. - Test File: substance-example.json - """ - filename = base_settings["unittest_data_dir"] / "substance-example.json" - inst = substance.Substance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Substance" == inst.resource_type - - impl_substance_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Substance" == data["resourceType"] - - inst2 = substance.Substance(**data) - impl_substance_5(inst2) - - -def impl_substance_6(inst): - assert inst.code.coding[0].code == "3092008" - assert inst.code.coding[0].display == "Staphylococcus Aureus" - assert inst.code.coding[0].system == "http://snomed.info/sct" - assert inst.id == "f202" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.status == "generated" - - -def test_substance_6(base_settings): - """No. 6 tests collection for Substance. - Test File: substance-example-f202-staphylococcus.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "substance-example-f202-staphylococcus.json" - ) - inst = substance.Substance.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Substance" == inst.resource_type - - impl_substance_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Substance" == data["resourceType"] - - inst2 = substance.Substance(**data) - impl_substance_6(inst2) diff --git a/fhir/resources/tests/test_substancespecification.py b/fhir/resources/tests/test_substancespecification.py deleted file mode 100644 index c3124eb7..00000000 --- a/fhir/resources/tests/test_substancespecification.py +++ /dev/null @@ -1,229 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SubstanceSpecification -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import substancespecification - - -def impl_substancespecification_1(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.div == ( - '

Generated ' - "Narrative with Details

id: " - "example

" - ) - assert inst.text.status == "generated" - - -def test_substancespecification_1(base_settings): - """No. 1 tests collection for SubstanceSpecification. - Test File: substancesourcematerial-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "substancesourcematerial-example.json" - ) - inst = substancespecification.SubstanceSpecification.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SubstanceSpecification" == inst.resource_type - - impl_substancespecification_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SubstanceSpecification" == data["resourceType"] - - inst2 = substancespecification.SubstanceSpecification(**data) - impl_substancespecification_1(inst2) - - -def impl_substancespecification_2(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.div == ( - '

Generated ' - "Narrative with Details

id: " - "example

" - ) - assert inst.text.status == "generated" - - -def test_substancespecification_2(base_settings): - """No. 2 tests collection for SubstanceSpecification. - Test File: substanceprotein-example.json - """ - filename = base_settings["unittest_data_dir"] / "substanceprotein-example.json" - inst = substancespecification.SubstanceSpecification.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SubstanceSpecification" == inst.resource_type - - impl_substancespecification_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SubstanceSpecification" == data["resourceType"] - - inst2 = substancespecification.SubstanceSpecification(**data) - impl_substancespecification_2(inst2) - - -def impl_substancespecification_3(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.div == ( - '

Generated ' - "Narrative with Details

id: " - "example

" - ) - assert inst.text.status == "generated" - - -def test_substancespecification_3(base_settings): - """No. 3 tests collection for SubstanceSpecification. - Test File: substancepolymer-example.json - """ - filename = base_settings["unittest_data_dir"] / "substancepolymer-example.json" - inst = substancespecification.SubstanceSpecification.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SubstanceSpecification" == inst.resource_type - - impl_substancespecification_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SubstanceSpecification" == data["resourceType"] - - inst2 = substancespecification.SubstanceSpecification(**data) - impl_substancespecification_3(inst2) - - -def impl_substancespecification_4(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.div == ( - '

Generated ' - "Narrative with Details

id: " - "example

" - ) - assert inst.text.status == "generated" - - -def test_substancespecification_4(base_settings): - """No. 4 tests collection for SubstanceSpecification. - Test File: substancespecification-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "substancespecification-example.json" - ) - inst = substancespecification.SubstanceSpecification.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SubstanceSpecification" == inst.resource_type - - impl_substancespecification_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SubstanceSpecification" == data["resourceType"] - - inst2 = substancespecification.SubstanceSpecification(**data) - impl_substancespecification_4(inst2) - - -def impl_substancespecification_5(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.div == ( - '

Generated ' - "Narrative with Details

id: " - "example

" - ) - assert inst.text.status == "generated" - - -def test_substancespecification_5(base_settings): - """No. 5 tests collection for SubstanceSpecification. - Test File: substancereferenceinformation-example.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "substancereferenceinformation-example.json" - ) - inst = substancespecification.SubstanceSpecification.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SubstanceSpecification" == inst.resource_type - - impl_substancespecification_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SubstanceSpecification" == data["resourceType"] - - inst2 = substancespecification.SubstanceSpecification(**data) - impl_substancespecification_5(inst2) - - -def impl_substancespecification_6(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.text.div == ( - '

Generated ' - "Narrative with Details

id: " - "example

" - ) - assert inst.text.status == "generated" - - -def test_substancespecification_6(base_settings): - """No. 6 tests collection for SubstanceSpecification. - Test File: substancenucleicacid-example.json - """ - filename = base_settings["unittest_data_dir"] / "substancenucleicacid-example.json" - inst = substancespecification.SubstanceSpecification.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SubstanceSpecification" == inst.resource_type - - impl_substancespecification_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SubstanceSpecification" == data["resourceType"] - - inst2 = substancespecification.SubstanceSpecification(**data) - impl_substancespecification_6(inst2) diff --git a/fhir/resources/tests/test_supplydelivery.py b/fhir/resources/tests/test_supplydelivery.py deleted file mode 100644 index 88aca588..00000000 --- a/fhir/resources/tests/test_supplydelivery.py +++ /dev/null @@ -1,103 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SupplyDelivery -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import supplydelivery - - -def impl_supplydelivery_1(inst): - assert inst.basedOn[0].reference == "SupplyRequest/simpleorder" - assert inst.destination.display == "Location 1" - assert inst.id == "simpledelivery" - assert inst.identifier[0].value == "Order10284" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate("2016-12-31") - assert inst.partOf[0].display == "Central Supply Restock" - assert inst.status == "completed" - assert inst.suppliedItem.itemCodeableConcept.coding[0].code == "BlueTubes" - assert ( - inst.suppliedItem.itemCodeableConcept.coding[0].display - == "Blood collect tubes blue cap" - ) - assert float(inst.suppliedItem.quantity.value) == float(10) - assert inst.supplier.display == "Vendor1" - assert inst.text.status == "generated" - assert inst.type.coding[0].code == "device" - assert ( - inst.type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/supply-item-type" - ) - assert inst.type.text == "Blood collect tubes blue cap" - - -def test_supplydelivery_1(base_settings): - """No. 1 tests collection for SupplyDelivery. - Test File: supplydelivery-example.json - """ - filename = base_settings["unittest_data_dir"] / "supplydelivery-example.json" - inst = supplydelivery.SupplyDelivery.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SupplyDelivery" == inst.resource_type - - impl_supplydelivery_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SupplyDelivery" == data["resourceType"] - - inst2 = supplydelivery.SupplyDelivery(**data) - impl_supplydelivery_1(inst2) - - -def impl_supplydelivery_2(inst): - assert inst.destination.display == "Home care dept" - assert inst.id == "pumpdelivery" - assert inst.identifier[0].assigner.display == "SupplierDeliveryNr" - assert inst.identifier[0].value == "98398459409" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.display == "Mr. Belpit" - assert inst.receiver[0].display == "Nurse Smith" - assert inst.status == "in-progress" - assert inst.supplier.display == "ACME distribution" - assert inst.text.div == ( - '
[Put rendering ' "here]
" - ) - assert inst.text.status == "generated" - - -def test_supplydelivery_2(base_settings): - """No. 2 tests collection for SupplyDelivery. - Test File: supplydelivery-example-pumpdelivery.json - """ - filename = ( - base_settings["unittest_data_dir"] / "supplydelivery-example-pumpdelivery.json" - ) - inst = supplydelivery.SupplyDelivery.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SupplyDelivery" == inst.resource_type - - impl_supplydelivery_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SupplyDelivery" == data["resourceType"] - - inst2 = supplydelivery.SupplyDelivery(**data) - impl_supplydelivery_2(inst2) diff --git a/fhir/resources/tests/test_supplyrequest.py b/fhir/resources/tests/test_supplyrequest.py deleted file mode 100644 index 150a16c7..00000000 --- a/fhir/resources/tests/test_supplyrequest.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/SupplyRequest -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import supplyrequest - - -def impl_supplyrequest_1(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2016-12-31") - assert inst.category.coding[0].code == "central" - assert inst.category.coding[0].display == "Central Stock Resupply" - assert inst.deliverFrom.display == "Location 1" - assert inst.deliverTo.display == "GoodHealth Clinic Receiving" - assert inst.id == "simpleorder" - assert inst.identifier[0].value == "Order10284" - assert inst.itemCodeableConcept.coding[0].code == "BlueTubes" - assert inst.itemCodeableConcept.coding[0].display == "Blood collect tubes blue cap" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.occurrenceDateTime == fhirtypes.DateTime.validate("2016-12-31") - assert inst.priority == "asap" - assert float(inst.quantity.value) == float(10) - assert inst.reasonCode[0].coding[0].code == "stock_low" - assert inst.reasonCode[0].coding[0].display == "Refill due to low stock" - assert inst.requester.display == "Henry Seven" - assert inst.status == "active" - assert inst.supplier[0].display == "Vendor1" - assert inst.text.status == "generated" - - -def test_supplyrequest_1(base_settings): - """No. 1 tests collection for SupplyRequest. - Test File: supplyrequest-example-simpleorder.json - """ - filename = ( - base_settings["unittest_data_dir"] / "supplyrequest-example-simpleorder.json" - ) - inst = supplyrequest.SupplyRequest.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "SupplyRequest" == inst.resource_type - - impl_supplyrequest_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "SupplyRequest" == data["resourceType"] - - inst2 = supplyrequest.SupplyRequest(**data) - impl_supplyrequest_1(inst2) diff --git a/fhir/resources/tests/test_task.py b/fhir/resources/tests/test_task.py deleted file mode 100644 index e245fb2d..00000000 --- a/fhir/resources/tests/test_task.py +++ /dev/null @@ -1,666 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Task -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import task - - -def impl_task_1(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2016-10-31T08:25:05+10:00") - assert inst.basedOn[0].display == "General Wellness Careplan" - assert inst.businessStatus.text == "test completed and posted" - assert inst.code.text == "Lipid Panel" - assert inst.description == ( - "Create order for getting specimen, Set up inhouse testing, " - "generate order for any sendouts and submit with specimen" - ) - assert inst.encounter.display == "Example In-Patient Encounter" - assert inst.encounter.reference == "Encounter/example" - assert inst.executionPeriod.end == fhirtypes.DateTime.validate( - "2016-10-31T18:45:05+10:00" - ) - assert inst.executionPeriod.start == fhirtypes.DateTime.validate( - "2016-10-31T08:25:05+10:00" - ) - assert inst.focus.display == "Lipid Panel Request" - assert inst.focus.reference == "ServiceRequest/lipid" - assert inst.for_fhir.display == "Peter James Chalmers" - assert inst.for_fhir.reference == "Patient/example" - assert inst.groupIdentifier.system == "http:/goodhealth.org/accession/identifiers" - assert inst.groupIdentifier.use == "official" - assert inst.groupIdentifier.value == "G20170201-001" - assert inst.id == "example6" - assert inst.identifier[0].system == "http:/goodhealth.org/identifiers" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "20170201-001" - assert inst.intent == "order" - assert inst.lastModified == fhirtypes.DateTime.validate("2016-10-31T18:45:05+10:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.output[0].type.text == "DiagnosticReport generated" - assert inst.output[0].valueReference.reference == "DiagnosticReport/lipids" - assert inst.output[1].type.text == "collected specimen" - assert inst.output[1].valueReference.reference == "Specimen/101" - assert inst.owner.display == "Clinical Laboratory @ Acme Hospital" - assert inst.owner.reference == "Organization/1832473e-2fe0-452d-abe9-3cdb9879522f" - assert inst.performerType[0].coding[0].code == "performer" - assert inst.performerType[0].coding[0].display == "Performer" - assert ( - inst.performerType[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/task-performer-type" - ) - assert inst.performerType[0].text == "Performer" - assert inst.priority == "routine" - assert inst.reasonCode.text == ( - "The Task.reason should only be included if there is no " - "Task.focus or if it differs from the reason indicated on the" - " focus" - ) - assert inst.requester.display == "Dr Adam Careful" - assert inst.requester.reference == "Practitioner/example" - assert inst.restriction.period.end == fhirtypes.DateTime.validate( - "2016-11-02T09:45:05+10:00" - ) - assert inst.restriction.repetitions == 1 - assert inst.status == "completed" - assert inst.text.status == "generated" - - -def test_task_1(base_settings): - """No. 1 tests collection for Task. - Test File: task-example6.json - """ - filename = base_settings["unittest_data_dir"] / "task-example6.json" - inst = task.Task.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Task" == inst.resource_type - - impl_task_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Task" == data["resourceType"] - - inst2 = task.Task(**data) - impl_task_1(inst2) - - -def impl_task_2(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2018-10-12T08:25:05+10:00") - assert inst.code.coding[0].code == "poll" - assert ( - inst.code.coding[0].system - == "http://terminology.hl7.org/CodeSystem/financialtaskcode" - ) - assert inst.id == "fm-example2" - assert inst.identifier[0].system == "http:/happyvalley.com/task" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "20181012-005" - assert inst.input[0].type.coding[0].code == "include" - assert ( - inst.input[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/financialtaskinputtype" - ) - assert inst.input[0].valueCode == "ClaimResponse" - assert inst.input[1].type.coding[0].code == "period" - assert ( - inst.input[1].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/financialtaskinputtype" - ) - assert inst.input[1].valuePeriod.end == fhirtypes.DateTime.validate("2018-10-12") - assert inst.input[1].valuePeriod.start == fhirtypes.DateTime.validate("2018-10-01") - assert inst.intent == "order" - assert inst.lastModified == fhirtypes.DateTime.validate("2018-10-12T08:25:05+10:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.owner.identifier.system == "http://nationalinsurers.com/identifiers" - assert inst.owner.identifier.value == "12345" - assert inst.priority == "stat" - assert inst.requester.display == "Happy Valley Clinic" - assert inst.requester.reference == "Organization/example" - assert inst.status == "requested" - assert inst.text.status == "generated" - - -def test_task_2(base_settings): - """No. 2 tests collection for Task. - Test File: task-example-fm-poll.json - """ - filename = base_settings["unittest_data_dir"] / "task-example-fm-poll.json" - inst = task.Task.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Task" == inst.resource_type - - impl_task_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Task" == data["resourceType"] - - inst2 = task.Task(**data) - impl_task_2(inst2) - - -def impl_task_3(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2016-10-31T08:25:05+10:00") - assert inst.basedOn[0].display == "General Wellness Careplan" - assert inst.businessStatus.text == "waiting for specimen" - assert inst.code.text == "Lipid Panel" - assert inst.contained[0].id == "signature" - assert inst.description == ( - "Create order for getting specimen, Set up inhouse testing, " - "generate order for any sendouts and submit with specimen" - ) - assert inst.encounter.display == "Example In-Patient Encounter" - assert inst.encounter.reference == "Encounter/example" - assert inst.executionPeriod.start == fhirtypes.DateTime.validate( - "2016-10-31T08:25:05+10:00" - ) - assert inst.focus.display == "Lipid Panel Request" - assert inst.focus.reference == "ServiceRequest/lipid" - assert inst.for_fhir.display == "Peter James Chalmers" - assert inst.for_fhir.reference == "Patient/example" - assert inst.groupIdentifier.system == "http:/goodhealth.org/accession/identifiers" - assert inst.groupIdentifier.use == "official" - assert inst.groupIdentifier.value == "G20170201-001" - assert inst.id == "example1" - assert inst.identifier[0].system == "http:/goodhealth.org/identifiers" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "20170201-001" - assert inst.intent == "order" - assert inst.lastModified == fhirtypes.DateTime.validate("2016-10-31T09:45:05+10:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.owner.display == "Clinical Laboratory @ Acme Hospital" - assert inst.owner.reference == "Organization/1832473e-2fe0-452d-abe9-3cdb9879522f" - assert inst.performerType[0].coding[0].code == "performer" - assert inst.performerType[0].coding[0].display == "Performer" - assert ( - inst.performerType[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/task-performer-type" - ) - assert inst.performerType[0].text == "Performer" - assert inst.priority == "routine" - assert inst.reasonCode.text == ( - "The Task.reason should only be included if there is no " - "Task.focus or if it differs from the reason indicated on the" - " focus" - ) - assert inst.relevantHistory[0].display == "Author's Signature" - assert inst.relevantHistory[0].reference == "#signature" - assert inst.requester.display == "Dr Adam Careful" - assert inst.requester.reference == "Practitioner/example" - assert inst.restriction.period.end == fhirtypes.DateTime.validate( - "2016-11-02T09:45:05+10:00" - ) - assert inst.restriction.repetitions == 1 - assert inst.status == "in-progress" - assert inst.text.status == "generated" - - -def test_task_3(base_settings): - """No. 3 tests collection for Task. - Test File: task-example1.json - """ - filename = base_settings["unittest_data_dir"] / "task-example1.json" - inst = task.Task.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Task" == inst.resource_type - - impl_task_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Task" == data["resourceType"] - - inst2 = task.Task(**data) - impl_task_3(inst2) - - -def impl_task_4(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2018-10-04T08:25:05+10:00") - assert inst.code.coding[0].code == "reprocess" - assert ( - inst.code.coding[0].system - == "http://terminology.hl7.org/CodeSystem/financialtaskcode" - ) - assert inst.focus.identifier.system == "http://happyvalley.com/claim" - assert inst.focus.identifier.value == "1501" - assert inst.id == "fm-example4" - assert inst.identifier[0].system == "http:/happyvalley.com/task" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "20181012-006" - assert inst.input[0].type.coding[0].code == "origresponse" - assert ( - inst.input[0].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/financialtaskinputtype" - ) - assert ( - inst.input[0].valueReference.identifier.system - == "http://nationalinsurers.com/claimresponse" - ) - assert inst.input[0].valueReference.identifier.value == "CR201810040001234" - assert inst.input[1].type.coding[0].code == "reference" - assert ( - inst.input[1].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/financialtaskinputtype" - ) - assert inst.input[1].valueString == "BR12345" - assert inst.input[2].type.coding[0].code == "item" - assert ( - inst.input[2].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/financialtaskinputtype" - ) - assert inst.input[2].valuePositiveInt == 2 - assert inst.input[3].type.coding[0].code == "item" - assert ( - inst.input[3].type.coding[0].system - == "http://terminology.hl7.org/CodeSystem/financialtaskinputtype" - ) - assert inst.input[3].valuePositiveInt == 3 - assert inst.intent == "order" - assert inst.lastModified == fhirtypes.DateTime.validate("2018-10-04T08:25:05+10:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.owner.identifier.system == "http://nationalinsurers.com/identifiers" - assert inst.owner.identifier.value == "12345" - assert inst.priority == "stat" - assert inst.requester.display == "Happy Valley Clinic" - assert inst.requester.reference == "Organization/example" - assert inst.status == "requested" - assert inst.text.status == "generated" - - -def test_task_4(base_settings): - """No. 4 tests collection for Task. - Test File: task-example-fm-reprocess.json - """ - filename = base_settings["unittest_data_dir"] / "task-example-fm-reprocess.json" - inst = task.Task.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Task" == inst.resource_type - - impl_task_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Task" == data["resourceType"] - - inst2 = task.Task(**data) - impl_task_4(inst2) - - -def impl_task_5(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2016-03-10T22:39:32-04:00") - assert inst.code.text == "Refill Request" - assert inst.focus.reference == "MedicationRequest/medrx002" - assert inst.for_fhir.reference == "Patient/f001" - assert inst.id == "example3" - assert inst.intent == "order" - assert inst.lastModified == fhirtypes.DateTime.validate("2016-03-10T22:39:32-04:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.owner.reference == "Practitioner/example" - assert inst.requester.reference == "Patient/example" - assert inst.status == "draft" - assert inst.text.status == "generated" - - -def test_task_5(base_settings): - """No. 5 tests collection for Task. - Test File: task-example3.json - """ - filename = base_settings["unittest_data_dir"] / "task-example3.json" - inst = task.Task.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Task" == inst.resource_type - - impl_task_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Task" == data["resourceType"] - - inst2 = task.Task(**data) - impl_task_5(inst2) - - -def impl_task_6(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2018-10-04T08:25:05+10:00") - assert inst.code.coding[0].code == "status" - assert ( - inst.code.coding[0].system - == "http://terminology.hl7.org/CodeSystem/financialtaskcode" - ) - assert inst.focus.identifier.system == "http://happyvalley.com/claim" - assert inst.focus.identifier.value == "1500" - assert inst.id == "fm-example6" - assert inst.identifier[0].system == "http:/happyvalley.com/task" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "20181012-001" - assert inst.identifier[1].system == "http://nationalinsurers.com/identifiers/12345" - assert inst.identifier[1].use == "official" - assert inst.identifier[1].value == "123GB5674" - assert inst.intent == "order" - assert inst.lastModified == fhirtypes.DateTime.validate("2018-10-04T08:25:05+10:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.output[0].type.coding[0].code == "status" - assert ( - inst.output[0].type.coding[0].system - == "http://hl7.org/financial-taskoutputtype" - ) - assert inst.output[0].valueCode == "complete" - assert inst.owner.identifier.system == "http://nationalinsurers.com/identifiers" - assert inst.owner.identifier.value == "12345" - assert inst.priority == "stat" - assert inst.requester.display == "Happy Valley Clinic" - assert inst.requester.reference == "Organization/example" - assert inst.status == "completed" - assert inst.text.status == "generated" - - -def test_task_6(base_settings): - """No. 6 tests collection for Task. - Test File: task-example-fm-status-resp.json - """ - filename = base_settings["unittest_data_dir"] / "task-example-fm-status-resp.json" - inst = task.Task.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Task" == inst.resource_type - - impl_task_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Task" == data["resourceType"] - - inst2 = task.Task(**data) - impl_task_6(inst2) - - -def impl_task_7(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2016-10-31T08:45:05+10:00") - assert inst.businessStatus.text == "waiting for patient" - assert inst.code.text == "Specimen Collection" - assert inst.encounter.display == "Example In-Patient Encounter" - assert inst.encounter.reference == "Encounter/example" - assert inst.executionPeriod.start == fhirtypes.DateTime.validate( - "2016-10-31T08:45:05+10:00" - ) - assert inst.focus.display == "BloodDraw ServiceRequest" - assert inst.for_fhir.display == "Peter James Chalmers" - assert inst.for_fhir.reference == "Patient/example" - assert inst.groupIdentifier.system == "http:/goodhealth.org/accession/identifiers" - assert inst.groupIdentifier.use == "official" - assert inst.groupIdentifier.value == "G20170201-001" - assert inst.id == "example2" - assert inst.identifier[0].system == "http:/goodhealth.org/identifiers" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "20170201-002" - assert inst.intent == "filler-order" - assert inst.lastModified == fhirtypes.DateTime.validate("2016-10-31T09:45:05+10:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.owner.display == "Clinical Laboratory @ Acme Hospital" - assert inst.owner.reference == "Organization/1832473e-2fe0-452d-abe9-3cdb9879522f" - assert inst.partOf[0].display == "Lipid Panel" - assert inst.partOf[0].reference == "Task/example1" - assert inst.performerType[0].coding[0].code == "performer" - assert inst.performerType[0].coding[0].display == "Performer" - assert ( - inst.performerType[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/task-performer-type" - ) - assert inst.performerType[0].text == "Performer" - assert inst.priority == "routine" - assert inst.requester.display == "Clinical Laboratory @ Acme Hospital" - assert ( - inst.requester.reference == "Organization/1832473e-2fe0-452d-abe9-3cdb9879522f" - ) - assert inst.restriction.period.end == fhirtypes.DateTime.validate( - "2016-11-01T09:45:05+10:00" - ) - assert inst.restriction.repetitions == 1 - assert inst.status == "accepted" - assert inst.text.status == "generated" - - -def test_task_7(base_settings): - """No. 7 tests collection for Task. - Test File: task-example2.json - """ - filename = base_settings["unittest_data_dir"] / "task-example2.json" - inst = task.Task.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Task" == inst.resource_type - - impl_task_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Task" == data["resourceType"] - - inst2 = task.Task(**data) - impl_task_7(inst2) - - -def impl_task_8(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2018-10-04T08:25:05+10:00") - assert inst.code.coding[0].code == "release" - assert ( - inst.code.coding[0].system - == "http://terminology.hl7.org/CodeSystem/financialtaskcode" - ) - assert inst.focus.identifier.system == "http://happyvalley.com/claim" - assert inst.focus.identifier.value == "1501" - assert inst.id == "fm-example3" - assert inst.identifier[0].system == "http:/happyvalley.com/task" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "20181012-001" - assert inst.input[0].type.coding[0].code == "origresponse" - assert ( - inst.input[0].type.coding[0].system == "http://hl7.org/financial-taskinputtype" - ) - assert ( - inst.input[0].valueReference.identifier.system - == "http://nationalinsurers.com/claimresponse" - ) - assert inst.input[0].valueReference.identifier.value == "CR201810040001234" - assert inst.intent == "order" - assert inst.lastModified == fhirtypes.DateTime.validate("2018-10-04T08:25:05+10:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.owner.identifier.system == "http://nationalinsurers.com/identifiers" - assert inst.owner.identifier.value == "12345" - assert inst.priority == "stat" - assert inst.requester.display == "Happy Valley Clinic" - assert inst.requester.reference == "Organization/example" - assert inst.status == "requested" - assert inst.text.status == "generated" - - -def test_task_8(base_settings): - """No. 8 tests collection for Task. - Test File: task-example-fm-release.json - """ - filename = base_settings["unittest_data_dir"] / "task-example-fm-release.json" - inst = task.Task.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Task" == inst.resource_type - - impl_task_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Task" == data["resourceType"] - - inst2 = task.Task(**data) - impl_task_8(inst2) - - -def impl_task_9(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2018-10-04T08:25:05+10:00") - assert inst.code.coding[0].code == "cancel" - assert ( - inst.code.coding[0].system - == "http://terminology.hl7.org/CodeSystem/financialtaskcode" - ) - assert inst.focus.identifier.system == "http://happyvalley.com/claim" - assert inst.focus.identifier.value == "1500" - assert inst.id == "fm-example1" - assert inst.identifier[0].system == "http:/happyvalley.com/task" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "20181012-001" - assert inst.intent == "order" - assert inst.lastModified == fhirtypes.DateTime.validate("2018-10-04T08:25:05+10:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.owner.identifier.system == "http://nationalinsurers.com/identifiers" - assert inst.owner.identifier.value == "12345" - assert inst.priority == "stat" - assert inst.requester.display == "Happy Valley Clinic" - assert inst.requester.reference == "Organization/example" - assert inst.status == "requested" - assert inst.text.status == "generated" - - -def test_task_9(base_settings): - """No. 9 tests collection for Task. - Test File: task-example-fm-cancel.json - """ - filename = base_settings["unittest_data_dir"] / "task-example-fm-cancel.json" - inst = task.Task.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Task" == inst.resource_type - - impl_task_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Task" == data["resourceType"] - - inst2 = task.Task(**data) - impl_task_9(inst2) - - -def impl_task_10(inst): - assert inst.authoredOn == fhirtypes.DateTime.validate("2016-10-31T08:25:05+10:00") - assert inst.basedOn[0].display == "General Wellness Careplan" - assert inst.businessStatus.text == "specimen received, test in progress" - assert inst.code.text == "Lipid Panel" - assert inst.description == ( - "Create order for getting specimen, Set up inhouse testing, " - "generate order for any sendouts and submit with specimen" - ) - assert inst.encounter.display == "Example In-Patient Encounter" - assert inst.encounter.reference == "Encounter/example" - assert inst.executionPeriod.start == fhirtypes.DateTime.validate( - "2016-10-31T08:25:05+10:00" - ) - assert inst.focus.display == "Lipid Panel Request" - assert inst.focus.reference == "ServiceRequest/lipid" - assert inst.for_fhir.display == "Peter James Chalmers" - assert inst.for_fhir.reference == "Patient/example" - assert inst.groupIdentifier.system == "http:/goodhealth.org/accession/identifiers" - assert inst.groupIdentifier.use == "official" - assert inst.groupIdentifier.value == "G20170201-001" - assert inst.id == "example5" - assert inst.identifier[0].system == "http:/goodhealth.org/identifiers" - assert inst.identifier[0].use == "official" - assert inst.identifier[0].value == "20170201-001" - assert inst.intent == "order" - assert inst.lastModified == fhirtypes.DateTime.validate("2016-10-31T16:45:05+10:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.output[0].type.text == "collected specimen" - assert inst.output[0].valueReference.reference == "Specimen/101" - assert inst.owner.display == "Clinical Laboratory @ Acme Hospital" - assert inst.owner.reference == "Organization/1832473e-2fe0-452d-abe9-3cdb9879522f" - assert inst.performerType[0].coding[0].code == "performer" - assert inst.performerType[0].coding[0].display == "Performer" - assert ( - inst.performerType[0].coding[0].system - == "http://terminology.hl7.org/CodeSystem/task-performer-type" - ) - assert inst.performerType[0].text == "Performer" - assert inst.priority == "routine" - assert inst.reasonCode.text == ( - "The Task.reason should only be included if there is no " - "Task.focus or if it differs from the reason indicated on the" - " focus" - ) - assert inst.requester.display == "Dr Adam Careful" - assert inst.requester.reference == "Practitioner/example" - assert inst.restriction.period.end == fhirtypes.DateTime.validate( - "2016-11-02T09:45:05+10:00" - ) - assert inst.restriction.repetitions == 1 - assert inst.status == "in-progress" - assert inst.text.status == "generated" - - -def test_task_10(base_settings): - """No. 10 tests collection for Task. - Test File: task-example5.json - """ - filename = base_settings["unittest_data_dir"] / "task-example5.json" - inst = task.Task.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "Task" == inst.resource_type - - impl_task_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "Task" == data["resourceType"] - - inst2 = task.Task(**data) - impl_task_10(inst2) diff --git a/fhir/resources/tests/test_terminologycapabilities.py b/fhir/resources/tests/test_terminologycapabilities.py deleted file mode 100644 index 8d0dc9a4..00000000 --- a/fhir/resources/tests/test_terminologycapabilities.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/TerminologyCapabilities -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import terminologycapabilities - - -def impl_terminologycapabilities_1(inst): - assert inst.codeSearch == "explicit" - assert inst.contact[0].name == "System Administrator" - assert inst.contact[0].telecom[0].system == "email" - assert inst.contact[0].telecom[0].value == "wile@acme.org" - assert inst.date == fhirtypes.DateTime.validate("2012-01-04") - assert inst.description == ( - "This is the FHIR capability statement for the main EHR at " - "ACME for the private interface - it does not describe the " - "public interface" - ) - assert inst.experimental is True - assert inst.id == "example" - assert inst.implementation.description == "Acme Terminology Server" - assert inst.implementation.url == "http://example.org/tx" - assert inst.kind == "instance" - assert inst.name == "ACME-EHR" - assert inst.publisher == "ACME Corporation" - assert inst.software.name == "TxServer" - assert inst.software.version == "0.1.2" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "ACME EHR capability statement" - assert inst.url == "urn:uuid:68D043B5-9ECF-4559-A57A-396E0D452311" - assert inst.version == "20130510" - - -def test_terminologycapabilities_1(base_settings): - """No. 1 tests collection for TerminologyCapabilities. - Test File: terminologycapabilities-example.json - """ - filename = ( - base_settings["unittest_data_dir"] / "terminologycapabilities-example.json" - ) - inst = terminologycapabilities.TerminologyCapabilities.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "TerminologyCapabilities" == inst.resource_type - - impl_terminologycapabilities_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "TerminologyCapabilities" == data["resourceType"] - - inst2 = terminologycapabilities.TerminologyCapabilities(**data) - impl_terminologycapabilities_1(inst2) diff --git a/fhir/resources/tests/test_testreport.py b/fhir/resources/tests/test_testreport.py deleted file mode 100644 index b8b65afd..00000000 --- a/fhir/resources/tests/test_testreport.py +++ /dev/null @@ -1,163 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/TestReport -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import testreport - - -def impl_testreport_1(inst): - assert inst.id == "testreport-example" - assert inst.identifier.system == "urn:ietf:rfc:3986" - assert inst.identifier.value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9878" - assert inst.issued == fhirtypes.DateTime.validate("2016-10-07T08:25:34-05:00") - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.name == "TestReport Example for TestScript Example" - assert inst.participant[0].display == "Crucible" - assert inst.participant[0].type == "test-engine" - assert inst.participant[0].uri == "http://projectcrucible.org" - assert inst.participant[1].display == "HealthIntersections STU3" - assert inst.participant[1].type == "server" - assert inst.participant[1].uri == "http://fhir3.healthintersections.com.au/open" - assert inst.result == "pass" - assert float(inst.score) == float(100.0) - assert ( - inst.setup.action[0].operation.detail - == "http://projectcrucible.org/permalink/1" - ) - assert inst.setup.action[0].operation.message == "DELETE Patient" - assert inst.setup.action[0].operation.result == "pass" - assert ( - inst.setup.action[1].assert_fhir.detail - == "http://projectcrucible.org/permalink/1" - ) - assert inst.setup.action[1].assert_fhir.message == "HTTP 204" - assert inst.setup.action[1].assert_fhir.result == "pass" - assert ( - inst.setup.action[2].operation.detail - == "http://projectcrucible.org/permalink/1" - ) - assert ( - inst.setup.action[2].operation.message == "POST Patient/fixture-patient-create" - ) - assert inst.setup.action[2].operation.result == "pass" - assert ( - inst.setup.action[3].assert_fhir.detail - == "http://projectcrucible.org/permalink/1" - ) - assert inst.setup.action[3].assert_fhir.message == "HTTP 201" - assert inst.setup.action[3].assert_fhir.result == "pass" - assert inst.status == "completed" - assert ( - inst.teardown.action[0].operation.detail - == "http://projectcrucible.org/permalink/3" - ) - assert ( - inst.teardown.action[0].operation.message - == "DELETE Patient/fixture-patient-create." - ) - assert inst.teardown.action[0].operation.result == "pass" - assert inst.testScript.reference == "TestScript/testscript-example" - assert ( - inst.test[0].action[0].operation.detail - == "http://projectcrucible.org/permalink/2" - ) - assert ( - inst.test[0].action[0].operation.message == "GET Patient/fixture-patient-create" - ) - assert inst.test[0].action[0].operation.result == "pass" - assert ( - inst.test[0].action[1].assert_fhir.detail - == "http://projectcrucible.org/permalink/2" - ) - assert inst.test[0].action[1].assert_fhir.message == "HTTP 200" - assert inst.test[0].action[1].assert_fhir.result == "pass" - assert ( - inst.test[0].action[2].assert_fhir.detail - == "http://projectcrucible.org/permalink/2" - ) - assert inst.test[0].action[2].assert_fhir.message == "Last-Modified Present" - assert inst.test[0].action[2].assert_fhir.result == "pass" - assert ( - inst.test[0].action[3].assert_fhir.detail - == "http://projectcrucible.org/permalink/2" - ) - assert inst.test[0].action[3].assert_fhir.message == "Response is Patient" - assert inst.test[0].action[3].assert_fhir.result == "pass" - assert ( - inst.test[0].action[4].assert_fhir.detail - == "http://projectcrucible.org/permalink/2" - ) - assert inst.test[0].action[4].assert_fhir.message == "Response validates" - assert inst.test[0].action[4].assert_fhir.result == "pass" - assert ( - inst.test[0].action[5].assert_fhir.detail - == "http://projectcrucible.org/permalink/2" - ) - assert ( - inst.test[0].action[5].assert_fhir.message == "Patient.name.family 'Chalmers'" - ) - assert inst.test[0].action[5].assert_fhir.result == "pass" - assert ( - inst.test[0].action[6].assert_fhir.detail - == "http://projectcrucible.org/permalink/2" - ) - assert inst.test[0].action[6].assert_fhir.message == "Patient.name.given 'Peter'" - assert inst.test[0].action[6].assert_fhir.result == "pass" - assert ( - inst.test[0].action[7].assert_fhir.detail - == "http://projectcrucible.org/permalink/2" - ) - assert ( - inst.test[0].action[7].assert_fhir.message == "Patient.name.family 'Chalmers'" - ) - assert inst.test[0].action[7].assert_fhir.result == "pass" - assert ( - inst.test[0].action[8].assert_fhir.detail - == "http://projectcrucible.org/permalink/2" - ) - assert ( - inst.test[0].action[8].assert_fhir.message == "Patient.name.family 'Chalmers'" - ) - assert inst.test[0].action[8].assert_fhir.result == "pass" - assert ( - inst.test[0].action[9].assert_fhir.detail - == "http://projectcrucible.org/permalink/2" - ) - assert inst.test[0].action[9].assert_fhir.message == "Patient expected values." - assert inst.test[0].action[9].assert_fhir.result == "pass" - assert inst.test[0].description == "Read a Patient and validate response." - assert inst.test[0].id == "01-ReadPatient" - assert inst.test[0].name == "Read Patient" - assert inst.tester == "HL7 Execution Engine" - assert inst.text.status == "generated" - - -def test_testreport_1(base_settings): - """No. 1 tests collection for TestReport. - Test File: testreport-example.json - """ - filename = base_settings["unittest_data_dir"] / "testreport-example.json" - inst = testreport.TestReport.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "TestReport" == inst.resource_type - - impl_testreport_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "TestReport" == data["resourceType"] - - inst2 = testreport.TestReport(**data) - impl_testreport_1(inst2) diff --git a/fhir/resources/tests/test_testscript.py b/fhir/resources/tests/test_testscript.py deleted file mode 100644 index 0b6e8f56..00000000 --- a/fhir/resources/tests/test_testscript.py +++ /dev/null @@ -1,1259 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/TestScript -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import testscript - - -def impl_testscript_1(inst): - assert inst.contact[0].name == "Support" - assert inst.contact[0].telecom[0].system == "email" - assert inst.contact[0].telecom[0].use == "work" - assert inst.contact[0].telecom[0].value == "support@HL7.org" - assert inst.copyright == "© HL7.org 2011+" - assert inst.date == fhirtypes.DateTime.validate("2017-01-18") - assert inst.destination[0].index == 1 - assert inst.destination[0].profile.code == "FHIR-Server" - assert inst.destination[1].index == 2 - assert inst.destination[1].profile.code == "FHIR-Server" - assert inst.experimental is True - assert inst.id == "testscript-example-multisystem" - assert inst.identifier.system == "urn:ietf:rfc:3986" - assert inst.identifier.value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9878" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America (the)" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.metadata.capability[0].capabilities == "CapabilityStatement/example" - assert inst.metadata.capability[0].description == "Patient Read Operation" - assert inst.metadata.capability[0].destination == 1 - assert inst.metadata.capability[0].link[0] == "http://hl7.org/fhir/http.html#read" - assert inst.metadata.capability[0].origin[0] == 1 - assert inst.metadata.capability[0].required is True - assert inst.metadata.capability[0].validated is False - assert inst.metadata.capability[1].capabilities == "CapabilityStatement/example" - assert inst.metadata.capability[1].description == "Patient Read Operation" - assert inst.metadata.capability[1].destination == 2 - assert inst.metadata.capability[1].link[0] == "http://hl7.org/fhir/http.html#read" - assert inst.metadata.capability[1].origin[0] == 1 - assert inst.metadata.capability[1].required is True - assert inst.metadata.capability[1].validated is False - assert inst.metadata.link[0].description == ( - "Demographics and other administrative information about an " - "individual or animal receiving care or other health-related " - "services." - ) - assert inst.metadata.link[0].url == "http://hl7.org/fhir/patient.html" - assert inst.name == "testscript-example-multisystem" - assert inst.origin[0].index == 1 - assert inst.origin[0].profile.code == "FHIR-Client" - assert inst.publisher == "HL7" - assert inst.purpose == "Patient Read Operation" - assert inst.status == "draft" - assert inst.test[0].action[0].operation.accept == "xml" - assert inst.test[0].action[0].operation.contentType == "xml" - assert inst.test[0].action[0].operation.description == ( - "Read a Patient from the first destination test system and " - "perform basic validation." - ) - assert inst.test[0].action[0].operation.destination == 1 - assert inst.test[0].action[0].operation.encodeRequestUrl is True - assert inst.test[0].action[0].operation.origin == 1 - assert inst.test[0].action[0].operation.params == "/${Dest1PatientResourceId}" - assert inst.test[0].action[0].operation.requestId == "request-read-patient-01" - assert inst.test[0].action[0].operation.resource == "Patient" - assert inst.test[0].action[0].operation.type.code == "read" - assert inst.test[0].action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert inst.test[0].action[1].assert_fhir.description == ( - "Confirm that the request method GET was sent by the client " - "system under test." - ) - assert inst.test[0].action[1].assert_fhir.requestMethod == "get" - assert inst.test[0].action[1].assert_fhir.warningOnly is False - assert ( - inst.test[0].action[2].assert_fhir.description - == "Confirm that the client requested an Accept of xml." - ) - assert inst.test[0].action[2].assert_fhir.direction == "request" - assert inst.test[0].action[2].assert_fhir.headerField == "Accept" - assert inst.test[0].action[2].assert_fhir.operator == "contains" - assert inst.test[0].action[2].assert_fhir.value == "xml" - assert inst.test[0].action[2].assert_fhir.warningOnly is False - assert ( - inst.test[0].action[3].assert_fhir.description - == "Confirm that the returned HTTP status is 200(OK)." - ) - assert inst.test[0].action[3].assert_fhir.direction == "response" - assert inst.test[0].action[3].assert_fhir.response == "okay" - assert inst.test[0].action[3].assert_fhir.warningOnly is False - assert inst.test[0].action[4].assert_fhir.contentType == "xml" - assert ( - inst.test[0].action[4].assert_fhir.description - == "Confirm that the returned format is XML." - ) - assert inst.test[0].action[4].assert_fhir.direction == "response" - assert inst.test[0].action[4].assert_fhir.warningOnly is False - assert ( - inst.test[0].action[5].assert_fhir.description - == "Confirm that the returned resource type is Patient." - ) - assert inst.test[0].action[5].assert_fhir.direction == "response" - assert inst.test[0].action[5].assert_fhir.resource == "Patient" - assert inst.test[0].action[5].assert_fhir.warningOnly is False - assert inst.test[0].description == ( - "Read a Patient from the first destination test system using " - "the user defined dynamic variable ${Dest1PatientResourceId}." - " Perform basic validation." - ) - assert inst.test[0].id == "01-ReadPatient-Destination1" - assert inst.test[0].name == "ReadPatient-Destination1" - assert inst.test[1].action[0].operation.accept == "xml" - assert inst.test[1].action[0].operation.contentType == "xml" - assert inst.test[1].action[0].operation.description == ( - "Read a Patient from the second destination test system and " - "perform basic validation." - ) - assert inst.test[1].action[0].operation.destination == 2 - assert inst.test[1].action[0].operation.encodeRequestUrl is True - assert inst.test[1].action[0].operation.origin == 1 - assert inst.test[1].action[0].operation.params == "/${Dest2PatientResourceId}" - assert inst.test[1].action[0].operation.requestHeader[0].field == "Accept-Charset" - assert inst.test[1].action[0].operation.requestHeader[0].value == "utf-8" - assert inst.test[1].action[0].operation.resource == "Patient" - assert inst.test[1].action[0].operation.type.code == "read" - assert inst.test[1].action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.test[1].action[1].assert_fhir.description - == "Confirm that the client requested an Accept of xml." - ) - assert inst.test[1].action[1].assert_fhir.direction == "request" - assert inst.test[1].action[1].assert_fhir.headerField == "Accept" - assert inst.test[1].action[1].assert_fhir.operator == "contains" - assert inst.test[1].action[1].assert_fhir.value == "xml" - assert inst.test[1].action[1].assert_fhir.warningOnly is False - assert ( - inst.test[1].action[2].assert_fhir.description - == "Confirm that the returned HTTP status is 200(OK)." - ) - assert inst.test[1].action[2].assert_fhir.direction == "response" - assert inst.test[1].action[2].assert_fhir.response == "okay" - assert inst.test[1].action[2].assert_fhir.warningOnly is False - assert inst.test[1].action[3].assert_fhir.contentType == "xml" - assert ( - inst.test[1].action[3].assert_fhir.description - == "Confirm that the returned format is XML." - ) - assert inst.test[1].action[3].assert_fhir.direction == "response" - assert inst.test[1].action[3].assert_fhir.warningOnly is False - assert ( - inst.test[1].action[4].assert_fhir.description - == "Confirm that the returned resource type is Patient." - ) - assert inst.test[1].action[4].assert_fhir.direction == "response" - assert inst.test[1].action[4].assert_fhir.resource == "Patient" - assert inst.test[1].action[4].assert_fhir.warningOnly is False - assert inst.test[1].description == ( - "Read a Patient from the second destination test system using" - " the user defined dynamic variable " - "${Dest2PatientResourceId}. Perform basic validation." - ) - assert inst.test[1].id == "02-ReadPatient-Destination2" - assert inst.test[1].name == "ReadPatient-Destination2" - assert inst.text.status == "generated" - assert inst.title == "Multisystem Test Script" - assert inst.url == ( - "http://hl7.org/fhir/TestScript/testscript-example-" "multisystem" - ) - assert inst.variable[0].defaultValue == "example" - assert inst.variable[0].name == "Dest1PatientResourceId" - assert inst.variable[1].defaultValue == "example" - assert inst.variable[1].name == "Dest2PatientResourceId" - assert inst.version == "1.0" - - -def test_testscript_1(base_settings): - """No. 1 tests collection for TestScript. - Test File: testscript-example-multisystem.json - """ - filename = ( - base_settings["unittest_data_dir"] / "testscript-example-multisystem.json" - ) - inst = testscript.TestScript.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "TestScript" == inst.resource_type - - impl_testscript_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "TestScript" == data["resourceType"] - - inst2 = testscript.TestScript(**data) - impl_testscript_1(inst2) - - -def impl_testscript_2(inst): - assert inst.contact[0].name == "Support" - assert inst.contact[0].telecom[0].system == "email" - assert inst.contact[0].telecom[0].use == "work" - assert inst.contact[0].telecom[0].value == "support@HL7.org" - assert inst.copyright == "© HL7.org 2011+" - assert inst.date == fhirtypes.DateTime.validate("2017-01-18") - assert inst.experimental is True - assert inst.fixture[0].autocreate is False - assert inst.fixture[0].autodelete is False - assert inst.fixture[0].id == "fixture-patient-create" - assert inst.fixture[0].resource.display == "Peter Chalmers" - assert inst.fixture[0].resource.reference == "Patient/example" - assert inst.fixture[1].autocreate is False - assert inst.fixture[1].autodelete is False - assert inst.fixture[1].id == "fixture-patient-update" - assert inst.fixture[1].resource.display == "Donald Duck" - assert inst.fixture[1].resource.reference == "Patient/pat1" - assert inst.id == "testscript-example-history" - assert inst.identifier.system == "urn:ietf:rfc:3986" - assert inst.identifier.value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9877" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America (the)" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.metadata.capability[0].capabilities == "CapabilityStatement/example" - assert ( - inst.metadata.capability[0].description - == "Patient Update, Delete and History (Instance) Operations" - ) - assert inst.metadata.capability[0].link[0] == "http://hl7.org/fhir/http.html#update" - assert inst.metadata.capability[0].link[1] == "http://hl7.org/fhir/http.html#delete" - assert ( - inst.metadata.capability[0].link[2] == "http://hl7.org/fhir/http.html#history" - ) - assert inst.metadata.capability[0].required is True - assert inst.metadata.capability[0].validated is False - assert inst.metadata.link[0].description == ( - "Demographics and other administrative information about an " - "individual or animal receiving care or other health-related " - "services." - ) - assert inst.metadata.link[0].url == "http://hl7.org/fhir/patient.html" - assert inst.name == "TestScript Example History" - assert inst.profile[0].id == "bundle-profile" - assert inst.profile[0].reference == "http://hl7.org/fhir/StructureDefinition/Bundle" - assert inst.publisher == "HL7" - assert inst.purpose == ( - "Patient (Conditional) Create, Update, Delete and History " - "(Instance) Operations" - ) - assert inst.setup.action[0].operation.accept == "json" - assert inst.setup.action[0].operation.description == ( - "Execute a delete operation to insure the patient does not " - "exist on the server." - ) - assert inst.setup.action[0].operation.encodeRequestUrl is True - assert inst.setup.action[0].operation.label == "SetupDeletePatient" - assert inst.setup.action[0].operation.params == "/${createResourceId}" - assert inst.setup.action[0].operation.resource == "Patient" - assert inst.setup.action[0].operation.type.code == "delete" - assert inst.setup.action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert inst.setup.action[1].assert_fhir.description == ( - "Confirm that the returned HTTP status is 200(OK) or 204(No " "Content)." - ) - assert inst.setup.action[1].assert_fhir.direction == "response" - assert inst.setup.action[1].assert_fhir.operator == "in" - assert inst.setup.action[1].assert_fhir.responseCode == "200,204" - assert inst.setup.action[1].assert_fhir.warningOnly is False - assert inst.setup.action[2].operation.accept == "json" - assert inst.setup.action[2].operation.contentType == "json" - assert inst.setup.action[2].operation.description == ( - "Create patient resource on test server using the contents of" - " fixture-patient-create" - ) - assert inst.setup.action[2].operation.encodeRequestUrl is True - assert inst.setup.action[2].operation.label == "SetupCreatePatient" - assert inst.setup.action[2].operation.params == "/${createResourceId}" - assert inst.setup.action[2].operation.resource == "Patient" - assert inst.setup.action[2].operation.sourceId == "fixture-patient-create" - assert inst.setup.action[2].operation.type.code == "update" - assert inst.setup.action[2].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.setup.action[3].assert_fhir.description - == "Confirm that the returned HTTP status is 201(Created)." - ) - assert inst.setup.action[3].assert_fhir.direction == "response" - assert inst.setup.action[3].assert_fhir.responseCode == "201" - assert inst.setup.action[3].assert_fhir.warningOnly is False - assert inst.setup.action[4].operation.accept == "json" - assert inst.setup.action[4].operation.contentType == "json" - assert inst.setup.action[4].operation.description == ( - "Update patient resource on test server using the contents of" - " fixture-patient-update" - ) - assert inst.setup.action[4].operation.encodeRequestUrl is True - assert inst.setup.action[4].operation.label == "SetupUpdatePatient" - assert inst.setup.action[4].operation.params == "/${createResourceId}" - assert inst.setup.action[4].operation.resource == "Patient" - assert inst.setup.action[4].operation.sourceId == "fixture-patient-update" - assert inst.setup.action[4].operation.type.code == "update" - assert inst.setup.action[4].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.setup.action[5].assert_fhir.description - == "Confirm that the returned HTTP status is 200(OK)." - ) - assert inst.setup.action[5].assert_fhir.direction == "response" - assert inst.setup.action[5].assert_fhir.responseCode == "200" - assert inst.setup.action[5].assert_fhir.warningOnly is False - assert inst.status == "draft" - assert inst.test[0].action[0].operation.accept == "json" - assert inst.test[0].action[0].operation.contentType == "json" - assert inst.test[0].action[0].operation.description == ( - "Get the Patient history on the test server using the id from" - " fixture-patient-create." - ) - assert inst.test[0].action[0].operation.encodeRequestUrl is True - assert inst.test[0].action[0].operation.resource == "Patient" - assert inst.test[0].action[0].operation.targetId == "fixture-patient-create" - assert inst.test[0].action[0].operation.type.code == "history" - assert inst.test[0].action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.test[0].action[1].assert_fhir.description - == "Confirm that the returned HTTP status is 200(OK)." - ) - assert inst.test[0].action[1].assert_fhir.direction == "response" - assert inst.test[0].action[1].assert_fhir.response == "okay" - assert inst.test[0].action[1].assert_fhir.warningOnly is False - assert ( - inst.test[0].action[2].assert_fhir.description - == "Confirm that the returned resource type is Bundle." - ) - assert inst.test[0].action[2].assert_fhir.resource == "Bundle" - assert inst.test[0].action[2].assert_fhir.warningOnly is False - assert inst.test[0].action[3].assert_fhir.description == ( - "Confirm that the returned Bundle conforms to the base FHIR " "specification." - ) - assert inst.test[0].action[3].assert_fhir.validateProfileId == "bundle-profile" - assert inst.test[0].action[3].assert_fhir.warningOnly is False - assert ( - inst.test[0].action[4].assert_fhir.description - == "Confirm that the returned Bundle type equals 'history'." - ) - assert inst.test[0].action[4].assert_fhir.operator == "equals" - assert inst.test[0].action[4].assert_fhir.path == "fhir:Bundle/fhir:type/@value" - assert inst.test[0].action[4].assert_fhir.value == "history" - assert inst.test[0].action[4].assert_fhir.warningOnly is False - assert ( - inst.test[0].description - == "Get the history for a known Patient and validate response." - ) - assert inst.test[0].id == "01-HistoryPatient" - assert inst.test[0].name == "History Patient" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/TestScript/testscript-example-history" - assert inst.variable[0].name == "createResourceId" - assert inst.variable[0].path == "Patient/id" - assert inst.variable[0].sourceId == "fixture-patient-create" - assert inst.version == "1.0" - - -def test_testscript_2(base_settings): - """No. 2 tests collection for TestScript. - Test File: testscript-example-history.json - """ - filename = base_settings["unittest_data_dir"] / "testscript-example-history.json" - inst = testscript.TestScript.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "TestScript" == inst.resource_type - - impl_testscript_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "TestScript" == data["resourceType"] - - inst2 = testscript.TestScript(**data) - impl_testscript_2(inst2) - - -def impl_testscript_3(inst): - assert inst.contact[0].name == "Support" - assert inst.contact[0].telecom[0].system == "email" - assert inst.contact[0].telecom[0].use == "work" - assert inst.contact[0].telecom[0].value == "support@HL7.org" - assert inst.copyright == "© HL7.org 2011+" - assert inst.date == fhirtypes.DateTime.validate("2017-01-18") - assert inst.description == ( - "TestScript example resource with setup to delete if present " - "and create a new instance of a Patient; and single test " - "definition to update that Patient with various asserts." - ) - assert inst.experimental is True - assert inst.fixture[0].autocreate is False - assert inst.fixture[0].autodelete is False - assert inst.fixture[0].id == "fixture-patient-create" - assert inst.fixture[0].resource.display == "Peter Chalmers" - assert inst.fixture[0].resource.reference == "Patient/example" - assert inst.fixture[1].autocreate is False - assert inst.fixture[1].autodelete is False - assert inst.fixture[1].id == "fixture-patient-update" - assert inst.fixture[1].resource.display == "Donald Duck" - assert inst.fixture[1].resource.reference == "Patient/pat1" - assert inst.id == "testscript-example-update" - assert inst.identifier.system == "urn:ietf:rfc:3986" - assert inst.identifier.value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9882" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America (the)" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.metadata.capability[0].capabilities == "CapabilityStatement/example" - assert ( - inst.metadata.capability[0].description - == "Patient Update and Delete Operations" - ) - assert inst.metadata.capability[0].link[0] == "http://hl7.org/fhir/http.html#update" - assert inst.metadata.capability[0].link[1] == "http://hl7.org/fhir/http.html#delete" - assert inst.metadata.capability[0].required is True - assert inst.metadata.capability[0].validated is False - assert inst.metadata.link[0].description == ( - "Demographics and other administrative information about an " - "individual or animal receiving care or other health-related " - "services." - ) - assert inst.metadata.link[0].url == "http://hl7.org/fhir/patient.html" - assert inst.name == "TestScript Example Update" - assert inst.profile[0].id == "patient-profile" - assert ( - inst.profile[0].reference == "http://hl7.org/fhir/StructureDefinition/Patient" - ) - assert inst.publisher == "HL7" - assert inst.purpose == "Patient (Conditional) Create, Update, Delete Operations" - assert inst.setup.action[0].operation.accept == "xml" - assert inst.setup.action[0].operation.description == ( - "Execute a delete operation to insure the patient does not " - "exist on the server." - ) - assert inst.setup.action[0].operation.encodeRequestUrl is True - assert inst.setup.action[0].operation.label == "SetupDeletePatient" - assert inst.setup.action[0].operation.params == "/${createResourceId}" - assert inst.setup.action[0].operation.resource == "Patient" - assert inst.setup.action[0].operation.type.code == "delete" - assert inst.setup.action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert inst.setup.action[1].assert_fhir.description == ( - "Confirm that the returned HTTP status is 200(OK) or 204(No " "Content)." - ) - assert inst.setup.action[1].assert_fhir.direction == "response" - assert inst.setup.action[1].assert_fhir.operator == "in" - assert inst.setup.action[1].assert_fhir.responseCode == "200,204" - assert inst.setup.action[1].assert_fhir.warningOnly is False - assert inst.setup.action[2].operation.accept == "xml" - assert inst.setup.action[2].operation.contentType == "xml" - assert inst.setup.action[2].operation.description == ( - "Create patient resource on test server using the contents of" - " fixture-patient-create" - ) - assert inst.setup.action[2].operation.encodeRequestUrl is True - assert inst.setup.action[2].operation.label == "SetupCreatePatient" - assert inst.setup.action[2].operation.params == "/${createResourceId}" - assert inst.setup.action[2].operation.resource == "Patient" - assert inst.setup.action[2].operation.sourceId == "fixture-patient-create" - assert inst.setup.action[2].operation.type.code == "update" - assert inst.setup.action[2].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.setup.action[3].assert_fhir.description - == "Confirm that the returned HTTP status is 201(Created)." - ) - assert inst.setup.action[3].assert_fhir.direction == "response" - assert inst.setup.action[3].assert_fhir.responseCode == "201" - assert inst.setup.action[3].assert_fhir.warningOnly is False - assert inst.status == "draft" - assert inst.test[0].action[0].operation.accept == "xml" - assert inst.test[0].action[0].operation.contentType == "xml" - assert inst.test[0].action[0].operation.description == ( - "Update patient resource on test server using the contents of" - " fixture-patient-update" - ) - assert inst.test[0].action[0].operation.encodeRequestUrl is True - assert inst.test[0].action[0].operation.label == "SetupUpdatePatient" - assert inst.test[0].action[0].operation.params == "/${createResourceId}" - assert inst.test[0].action[0].operation.resource == "Patient" - assert inst.test[0].action[0].operation.sourceId == "fixture-patient-update" - assert inst.test[0].action[0].operation.type.code == "update" - assert inst.test[0].action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.test[0].action[1].assert_fhir.description - == "Confirm that the returned HTTP status is 200(OK)." - ) - assert inst.test[0].action[1].assert_fhir.response == "okay" - assert inst.test[0].action[1].assert_fhir.warningOnly is False - assert inst.test[0].action[2].assert_fhir.contentType == "xml" - assert ( - inst.test[0].action[2].assert_fhir.description - == "Confirm that the returned format is XML." - ) - assert inst.test[0].action[2].assert_fhir.warningOnly is False - assert inst.test[0].action[3].assert_fhir.description == ( - "Confirm that the returned HTTP Header Last-Modified is " - "present. Warning only as the server might not support " - "versioning." - ) - assert inst.test[0].action[3].assert_fhir.headerField == "Last-Modified" - assert inst.test[0].action[3].assert_fhir.operator == "notEmpty" - assert inst.test[0].action[3].assert_fhir.warningOnly is True - assert inst.test[0].description == "Update a Patient and validate response." - assert inst.test[0].id == "01-UpdatePatient" - assert inst.test[0].name == "Update Patient" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/TestScript/testscript-example-update" - assert inst.variable[0].name == "createResourceId" - assert inst.variable[0].path == "Patient/id" - assert inst.variable[0].sourceId == "fixture-patient-create" - assert inst.version == "1.0" - - -def test_testscript_3(base_settings): - """No. 3 tests collection for TestScript. - Test File: testscript-example-update.json - """ - filename = base_settings["unittest_data_dir"] / "testscript-example-update.json" - inst = testscript.TestScript.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "TestScript" == inst.resource_type - - impl_testscript_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "TestScript" == data["resourceType"] - - inst2 = testscript.TestScript(**data) - impl_testscript_3(inst2) - - -def impl_testscript_4(inst): - assert inst.contact[0].name == "Support" - assert inst.contact[0].telecom[0].system == "email" - assert inst.contact[0].telecom[0].use == "work" - assert inst.contact[0].telecom[0].value == "support@HL7.org" - assert inst.copyright == "© HL7.org 2011+" - assert inst.date == fhirtypes.DateTime.validate("2017-01-18") - assert inst.description == ( - "TestScript example resource with simple Patient search test." - " The read tests will utilize user defined dynamic variables " - "that will hold the Patient search parameter values." - ) - assert inst.experimental is True - assert inst.fixture[0].autocreate is False - assert inst.fixture[0].autodelete is False - assert inst.fixture[0].id == "fixture-patient-create" - assert inst.fixture[0].resource.display == "Peter Chalmers" - assert inst.fixture[0].resource.reference == "Patient/example" - assert inst.id == "testscript-example-search" - assert inst.identifier.system == "urn:ietf:rfc:3986" - assert inst.identifier.value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9881" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America (the)" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.metadata.capability[0].capabilities == "CapabilityStatement/example" - assert inst.metadata.capability[0].description == "Patient Search Operation" - assert inst.metadata.capability[0].link[0] == "http://hl7.org/fhir/http.html#search" - assert inst.metadata.capability[0].required is True - assert inst.metadata.capability[0].validated is False - assert inst.metadata.link[0].description == ( - "Demographics and other administrative information about an " - "individual or animal receiving care or other health-related " - "services." - ) - assert inst.metadata.link[0].url == "http://hl7.org/fhir/patient.html" - assert inst.name == "TestScript Example Search" - assert inst.profile[0].id == "bundle-profile" - assert inst.profile[0].reference == "http://hl7.org/fhir/StructureDefinition/Bundle" - assert inst.publisher == "HL7" - assert inst.purpose == "Patient Search Operation" - assert inst.setup.action[0].operation.accept == "xml" - assert ( - inst.setup.action[0].operation.description - == "Test simple search to verify server support." - ) - assert inst.setup.action[0].operation.encodeRequestUrl is True - assert ( - inst.setup.action[0].operation.params - == "?family=DONTEXPECTAMATCH&given=DONTEXPECTAMATCH" - ) - assert inst.setup.action[0].operation.resource == "Patient" - assert inst.setup.action[0].operation.type.code == "search" - assert inst.setup.action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert inst.setup.action[1].assert_fhir.description == ( - "Confirm that the request url contains the family search " "parameter." - ) - assert inst.setup.action[1].assert_fhir.direction == "request" - assert inst.setup.action[1].assert_fhir.operator == "contains" - assert inst.setup.action[1].assert_fhir.requestURL == "family" - assert inst.setup.action[1].assert_fhir.warningOnly is False - assert ( - inst.setup.action[2].assert_fhir.description - == "Confirm that the returned HTTP status is 200(OK)." - ) - assert inst.setup.action[2].assert_fhir.direction == "response" - assert inst.setup.action[2].assert_fhir.responseCode == "200" - assert inst.setup.action[2].assert_fhir.warningOnly is False - assert ( - inst.setup.action[3].assert_fhir.description - == "Confirm that the returned resource type is Bundle." - ) - assert inst.setup.action[3].assert_fhir.resource == "Bundle" - assert inst.setup.action[3].assert_fhir.warningOnly is False - assert inst.setup.action[4].assert_fhir.description == ( - "Confirm that the returned Bundle correctly defines the " "navigation links." - ) - assert inst.setup.action[4].assert_fhir.navigationLinks is True - assert inst.setup.action[4].assert_fhir.warningOnly is False - assert inst.status == "draft" - assert inst.test[0].action[0].operation.accept == "xml" - assert inst.test[0].action[0].operation.contentType == "xml" - assert inst.test[0].action[0].operation.description == ( - "Create a Patient resource and capture the returned HTTP " "Header Location." - ) - assert inst.test[0].action[0].operation.encodeRequestUrl is True - assert inst.test[0].action[0].operation.resource == "Patient" - assert inst.test[0].action[0].operation.responseId == "PatientCreateResponse" - assert inst.test[0].action[0].operation.sourceId == "fixture-patient-create" - assert inst.test[0].action[0].operation.type.code == "create" - assert inst.test[0].action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.test[0].action[1].assert_fhir.description - == "Confirm that the returned HTTP status is 201(Created)." - ) - assert inst.test[0].action[1].assert_fhir.response == "created" - assert inst.test[0].action[1].assert_fhir.warningOnly is False - assert ( - inst.test[0].action[2].assert_fhir.description - == "Confirm that the returned HTTP Header Location is present." - ) - assert inst.test[0].action[2].assert_fhir.direction == "response" - assert inst.test[0].action[2].assert_fhir.headerField == "Location" - assert inst.test[0].action[2].assert_fhir.operator == "notEmpty" - assert inst.test[0].action[2].assert_fhir.warningOnly is False - assert inst.test[0].action[3].operation.accept == "xml" - assert inst.test[0].action[3].operation.description == ( - "Read the created Patient using the captured Location URL " "value." - ) - assert inst.test[0].action[3].operation.encodeRequestUrl is True - assert inst.test[0].action[3].operation.type.code == "read" - assert inst.test[0].action[3].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert inst.test[0].action[3].operation.url == "${PatientCreateLocation}" - assert ( - inst.test[0].action[4].assert_fhir.description - == "Confirm that the returned HTTP status is 200(OK)." - ) - assert inst.test[0].action[4].assert_fhir.response == "okay" - assert inst.test[0].action[4].assert_fhir.warningOnly is False - assert ( - inst.test[0].action[5].assert_fhir.description - == "Confirm that the returned resource type is Patient." - ) - assert inst.test[0].action[5].assert_fhir.resource == "Patient" - assert inst.test[0].action[5].assert_fhir.warningOnly is False - assert inst.test[0].description == ( - "Create a Patient resource and capture the returned HTTP " - "Header Location. Then search for (read) that Patient using " - "the Location URL value and validate the response." - ) - assert inst.test[0].id == "01-PatientCreateSearch" - assert inst.test[0].name == "Patient Create Search" - assert inst.test[1].action[0].operation.accept == "xml" - assert ( - inst.test[1].action[0].operation.description - == "Search for Patient resources on the destination test system." - ) - assert inst.test[1].action[0].operation.encodeRequestUrl is True - assert inst.test[1].action[0].operation.params == ( - "?family=${PatientSearchFamilyName}&given=${PatientSearchGive" "nName}" - ) - assert inst.test[1].action[0].operation.resource == "Patient" - assert inst.test[1].action[0].operation.type.code == "search" - assert inst.test[1].action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.test[1].action[1].assert_fhir.description - == "Confirm that the returned HTTP status is 200(OK)." - ) - assert inst.test[1].action[1].assert_fhir.response == "okay" - assert inst.test[1].action[1].assert_fhir.warningOnly is False - assert inst.test[1].action[2].assert_fhir.contentType == "xml" - assert ( - inst.test[1].action[2].assert_fhir.description - == "Confirm that the returned format is XML." - ) - assert inst.test[1].action[2].assert_fhir.warningOnly is False - assert ( - inst.test[1].action[3].assert_fhir.description - == "Confirm that the returned resource type is Bundle." - ) - assert inst.test[1].action[3].assert_fhir.resource == "Bundle" - assert inst.test[1].action[3].assert_fhir.warningOnly is False - assert inst.test[1].action[4].assert_fhir.description == ( - "Confirm that the returned Bundle conforms to the base FHIR " "specification." - ) - assert inst.test[1].action[4].assert_fhir.validateProfileId == "bundle-profile" - assert inst.test[1].action[4].assert_fhir.warningOnly is False - assert ( - inst.test[1].action[5].assert_fhir.description - == "Confirm that the returned Bundle type equals 'searchset'." - ) - assert inst.test[1].action[5].assert_fhir.operator == "equals" - assert inst.test[1].action[5].assert_fhir.path == "fhir:Bundle/fhir:type/@value" - assert inst.test[1].action[5].assert_fhir.value == "searchset" - assert inst.test[1].action[5].assert_fhir.warningOnly is False - assert inst.test[1].action[6].assert_fhir.description == ( - "Confirm that the returned Bundle total is greater than or " - "equal to the number of returned entries." - ) - assert ( - inst.test[1].action[6].assert_fhir.expression - == "Bundle.total.toInteger() >= entry.count()" - ) - assert inst.test[1].action[6].assert_fhir.warningOnly is False - assert inst.test[1].description == ( - "Search for Patient resources using the user defined dynamic " - "variables ${PatientSearchFamilyName} and " - "${PatientSearchGivenName} and validate response." - ) - assert inst.test[1].id == "02-PatientSearchDynamic" - assert inst.test[1].name == "Patient Search Dynamic" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/TestScript/testscript-example-search" - assert inst.variable[0].headerField == "Location" - assert inst.variable[0].name == "PatientCreateLocation" - assert inst.variable[0].sourceId == "PatientCreateResponse" - assert inst.variable[1].description == ( - "Enter patient search criteria for a known family name on the" " target system" - ) - assert inst.variable[1].hint == "[Family name]" - assert inst.variable[1].name == "PatientSearchFamilyName" - assert inst.variable[2].description == ( - "Enter patient search criteria for a known given name on the " "target system" - ) - assert inst.variable[2].hint == "[Given name]" - assert inst.variable[2].name == "PatientSearchGivenName" - assert ( - inst.variable[3].description - == "Evaluate the returned Patient searchset Bundle.total value" - ) - assert inst.variable[3].expression == "Bundle.total.toInteger()" - assert inst.variable[3].name == "PatientSearchBundleTotal" - assert inst.version == "1.0" - - -def test_testscript_4(base_settings): - """No. 4 tests collection for TestScript. - Test File: testscript-example-search.json - """ - filename = base_settings["unittest_data_dir"] / "testscript-example-search.json" - inst = testscript.TestScript.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "TestScript" == inst.resource_type - - impl_testscript_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "TestScript" == data["resourceType"] - - inst2 = testscript.TestScript(**data) - impl_testscript_4(inst2) - - -def impl_testscript_5(inst): - assert inst.contact[0].name == "Support" - assert inst.contact[0].telecom[0].system == "email" - assert inst.contact[0].telecom[0].use == "work" - assert inst.contact[0].telecom[0].value == "support@HL7.org" - assert inst.copyright == "© HL7.org 2011+" - assert inst.date == fhirtypes.DateTime.validate("2017-01-18") - assert inst.description == ( - "TestScript example resource with setup to delete if present " - "and create a new instance of a Patient; and single test " - "definition to read the created Patient with various asserts." - ) - assert inst.experimental is True - assert inst.fixture[0].autocreate is False - assert inst.fixture[0].autodelete is False - assert inst.fixture[0].id == "fixture-patient-create" - assert inst.fixture[0].resource.display == "Peter Chalmers" - assert inst.fixture[0].resource.reference == "Patient/example" - assert inst.fixture[1].autocreate is False - assert inst.fixture[1].autodelete is False - assert inst.fixture[1].id == "fixture-patient-minimum" - assert inst.fixture[1].resource.display == "Peter Chalmers (minimum)" - assert inst.fixture[1].resource.reference == "Patient/example" - assert inst.id == "testscript-example" - assert inst.identifier.system == "urn:ietf:rfc:3986" - assert inst.identifier.value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9876" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America (the)" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.metadata.capability[0].capabilities == "CapabilityStatement/example" - assert ( - inst.metadata.capability[0].description - == "Patient Update, Read and Delete Operations" - ) - assert inst.metadata.capability[0].link[0] == "http://hl7.org/fhir/http.html#delete" - assert inst.metadata.capability[0].link[1] == "http://hl7.org/fhir/http.html#read" - assert inst.metadata.capability[0].link[2] == "http://hl7.org/fhir/http.html#update" - assert inst.metadata.capability[0].required is True - assert inst.metadata.capability[0].validated is False - assert inst.metadata.link[0].description == ( - "Demographics and other administrative information about an " - "individual or animal receiving care or other health-related " - "services." - ) - assert inst.metadata.link[0].url == "http://hl7.org/fhir/patient.html" - assert inst.name == "TestScript Example" - assert inst.profile[0].id == "patient-profile" - assert ( - inst.profile[0].reference == "http://hl7.org/fhir/StructureDefinition/Patient" - ) - assert inst.publisher == "HL7" - assert inst.purpose == ( - "Patient Conditional Create (Update), Read and Delete " "Operations" - ) - assert inst.setup.action[0].operation.accept == "json" - assert inst.setup.action[0].operation.description == ( - "Execute a delete operation to insure the patient does not " - "exist on the server." - ) - assert inst.setup.action[0].operation.encodeRequestUrl is True - assert inst.setup.action[0].operation.label == "SetupDeletePatient" - assert inst.setup.action[0].operation.params == "/${createResourceId}" - assert inst.setup.action[0].operation.resource == "Patient" - assert inst.setup.action[0].operation.type.code == "delete" - assert inst.setup.action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert inst.setup.action[1].assert_fhir.description == ( - "Confirm that the returned HTTP status is 200(OK) or 204(No " "Content)." - ) - assert inst.setup.action[1].assert_fhir.direction == "response" - assert inst.setup.action[1].assert_fhir.operator == "in" - assert inst.setup.action[1].assert_fhir.responseCode == "200,204" - assert inst.setup.action[1].assert_fhir.warningOnly is False - assert inst.setup.action[2].operation.accept == "json" - assert inst.setup.action[2].operation.contentType == "json" - assert inst.setup.action[2].operation.description == ( - "Create patient resource on test server using the contents of" - " fixture-patient-create" - ) - assert inst.setup.action[2].operation.encodeRequestUrl is True - assert inst.setup.action[2].operation.label == "SetupCreatePatient" - assert inst.setup.action[2].operation.params == "/${createResourceId}" - assert inst.setup.action[2].operation.resource == "Patient" - assert inst.setup.action[2].operation.sourceId == "fixture-patient-create" - assert inst.setup.action[2].operation.type.code == "update" - assert inst.setup.action[2].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.setup.action[3].assert_fhir.description - == "Confirm that the returned HTTP status is 201(Created)." - ) - assert inst.setup.action[3].assert_fhir.direction == "response" - assert inst.setup.action[3].assert_fhir.responseCode == "201" - assert inst.setup.action[3].assert_fhir.warningOnly is False - assert inst.setup.action[4].operation.description == ( - "Read the created patient resource on the test server using " - "the id from fixture-patient-create. Verify contents." - ) - assert inst.setup.action[4].operation.encodeRequestUrl is True - assert inst.setup.action[4].operation.resource == "Patient" - assert inst.setup.action[4].operation.targetId == "fixture-patient-create" - assert inst.setup.action[4].operation.type.code == "read" - assert inst.setup.action[4].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.setup.action[5].assert_fhir.description - == "Confirm that the returned HTTP status is 200(OK)." - ) - assert inst.setup.action[5].assert_fhir.direction == "response" - assert inst.setup.action[5].assert_fhir.response == "okay" - assert inst.setup.action[5].assert_fhir.warningOnly is False - assert ( - inst.setup.action[6].assert_fhir.compareToSourceExpression - == "Patient.name.first().family" - ) - assert ( - inst.setup.action[6].assert_fhir.compareToSourceId == "fixture-patient-create" - ) - assert inst.setup.action[6].assert_fhir.description == ( - "Confirm that the returned Patient contains the expected " - "family name 'Chalmers'. Uses explicit compareToSourceId " - "reference to fixture-patient-create used to create the " - "Patient." - ) - assert inst.setup.action[6].assert_fhir.operator == "equals" - assert inst.setup.action[6].assert_fhir.warningOnly is False - assert inst.status == "draft" - assert inst.teardown.action[0].operation.description == ( - "Delete the patient resource on the test server using the id " - "from fixture-patient-create." - ) - assert inst.teardown.action[0].operation.encodeRequestUrl is True - assert inst.teardown.action[0].operation.resource == "Patient" - assert inst.teardown.action[0].operation.targetId == "fixture-patient-create" - assert inst.teardown.action[0].operation.type.code == "delete" - assert inst.teardown.action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert inst.test[0].action[0].operation.description == ( - "Read the patient resource on the test server using the id " - "from fixture-patient-create. Prevent URL encoding of the " - "request." - ) - assert inst.test[0].action[0].operation.encodeRequestUrl is False - assert inst.test[0].action[0].operation.resource == "Patient" - assert inst.test[0].action[0].operation.responseId == "fixture-patient-read" - assert inst.test[0].action[0].operation.targetId == "fixture-patient-create" - assert inst.test[0].action[0].operation.type.code == "read" - assert inst.test[0].action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.test[0].action[1].assert_fhir.description - == "Confirm that the returned HTTP status is 200(OK)." - ) - assert inst.test[0].action[1].assert_fhir.direction == "response" - assert inst.test[0].action[1].assert_fhir.label == "01-ReadPatientOK" - assert inst.test[0].action[1].assert_fhir.response == "okay" - assert inst.test[0].action[1].assert_fhir.warningOnly is False - assert inst.test[0].action[2].assert_fhir.description == ( - "Confirm that the returned HTTP Header Last-Modified is " - "present. Warning only as the server might not support " - "versioning." - ) - assert inst.test[0].action[2].assert_fhir.direction == "response" - assert inst.test[0].action[2].assert_fhir.headerField == "Last-Modified" - assert inst.test[0].action[2].assert_fhir.operator == "notEmpty" - assert inst.test[0].action[2].assert_fhir.warningOnly is True - assert ( - inst.test[0].action[3].assert_fhir.description - == "Confirm that the returned resource type is Patient." - ) - assert inst.test[0].action[3].assert_fhir.resource == "Patient" - assert inst.test[0].action[3].assert_fhir.warningOnly is False - assert inst.test[0].action[4].assert_fhir.description == ( - "Confirm that the returned Patient conforms to the base FHIR " "specification." - ) - assert inst.test[0].action[4].assert_fhir.validateProfileId == "patient-profile" - assert inst.test[0].action[4].assert_fhir.warningOnly is False - assert inst.test[0].action[5].assert_fhir.description == ( - "Confirm that the returned Patient contains the expected " - "family name 'Chalmers'. Uses explicit sourceId reference to " - "read responseId fixture." - ) - assert inst.test[0].action[5].assert_fhir.operator == "equals" - assert ( - inst.test[0].action[5].assert_fhir.path - == "fhir:Patient/fhir:name/fhir:family/@value" - ) - assert inst.test[0].action[5].assert_fhir.sourceId == "fixture-patient-read" - assert inst.test[0].action[5].assert_fhir.value == "Chalmers" - assert inst.test[0].action[5].assert_fhir.warningOnly is False - assert inst.test[0].action[6].assert_fhir.description == ( - "Confirm that the returned Patient contains the expected " - "given name 'Peter'. Uses explicit sourceId reference to read" - " responseId fixture." - ) - assert inst.test[0].action[6].assert_fhir.operator == "equals" - assert ( - inst.test[0].action[6].assert_fhir.path - == "fhir:Patient/fhir:name/fhir:given/@value" - ) - assert inst.test[0].action[6].assert_fhir.sourceId == "fixture-patient-read" - assert inst.test[0].action[6].assert_fhir.value == "Peter" - assert inst.test[0].action[6].assert_fhir.warningOnly is False - assert ( - inst.test[0].action[7].assert_fhir.compareToSourceId == "fixture-patient-create" - ) - assert ( - inst.test[0].action[7].assert_fhir.compareToSourcePath - == "fhir:Patient/fhir:name/fhir:family/@value" - ) - assert inst.test[0].action[7].assert_fhir.operator == "equals" - assert ( - inst.test[0].action[7].assert_fhir.path - == "fhir:Patient/fhir:name/fhir:family/@value" - ) - assert inst.test[0].action[7].assert_fhir.warningOnly is False - assert ( - inst.test[0].action[8].assert_fhir.compareToSourceId == "fixture-patient-create" - ) - assert ( - inst.test[0].action[8].assert_fhir.compareToSourcePath - == "fhir:Patient/fhir:name/fhir:given/@value" - ) - assert ( - inst.test[0].action[8].assert_fhir.path - == "fhir:Patient/fhir:name/fhir:given/@value" - ) - assert inst.test[0].action[8].assert_fhir.sourceId == "fixture-patient-read" - assert inst.test[0].action[8].assert_fhir.warningOnly is False - assert inst.test[0].action[9].assert_fhir.description == ( - "Confirm that the returned resource contains the expected " - "retained elements and values. Warning only to provide users " - "with reviewable results." - ) - assert inst.test[0].action[9].assert_fhir.minimumId == "fixture-patient-minimum" - assert inst.test[0].action[9].assert_fhir.warningOnly is True - assert inst.test[0].description == "Read a Patient and validate response." - assert inst.test[0].id == "01-ReadPatient" - assert inst.test[0].name == "Read Patient" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/TestScript/testscript-example" - assert inst.useContext[0].code.code == "focus" - assert ( - inst.useContext[0].code.system - == "http://terminology.hl7.org/CodeSystem/usage-context-type" - ) - assert inst.useContext[0].valueCodeableConcept.coding[0].code == "positive" - assert ( - inst.useContext[0].valueCodeableConcept.coding[0].system - == "http://terminology.hl7.org/CodeSystem/variant-state" - ) - assert inst.variable[0].name == "createResourceId" - assert inst.variable[0].path == "Patient/id" - assert inst.variable[0].sourceId == "fixture-patient-create" - assert inst.version == "1.0" - - -def test_testscript_5(base_settings): - """No. 5 tests collection for TestScript. - Test File: testscript-example.json - """ - filename = base_settings["unittest_data_dir"] / "testscript-example.json" - inst = testscript.TestScript.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "TestScript" == inst.resource_type - - impl_testscript_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "TestScript" == data["resourceType"] - - inst2 = testscript.TestScript(**data) - impl_testscript_5(inst2) - - -def impl_testscript_6(inst): - assert inst.contact[0].name == "Support" - assert inst.contact[0].telecom[0].system == "email" - assert inst.contact[0].telecom[0].use == "work" - assert inst.contact[0].telecom[0].value == "support@HL7.org" - assert inst.copyright == "© HL7.org 2011+" - assert inst.date == fhirtypes.DateTime.validate("2017-01-18") - assert inst.description == ( - "TestScript example resource with ported Sprinkler basic read" - " tests R001, R002, R003, R004. The read tests will utilize " - "user defined dynamic variables that will hold the Patient " - "resource id values." - ) - assert inst.experimental is True - assert inst.id == "testscript-example-readtest" - assert inst.identifier.system == "urn:ietf:rfc:3986" - assert inst.identifier.value == "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9879" - assert inst.jurisdiction[0].coding[0].code == "US" - assert inst.jurisdiction[0].coding[0].display == "United States of America (the)" - assert inst.jurisdiction[0].coding[0].system == "urn:iso:std:iso:3166" - assert inst.metadata.capability[0].capabilities == "CapabilityStatement/example" - assert inst.metadata.capability[0].description == "Patient Read Operation" - assert inst.metadata.capability[0].link[0] == "http://hl7.org/fhir/http.html#read" - assert inst.metadata.capability[0].required is True - assert inst.metadata.capability[0].validated is False - assert inst.metadata.link[0].description == ( - "Demographics and other administrative information about an " - "individual or animal receiving care or other health-related " - "services." - ) - assert inst.metadata.link[0].url == "http://hl7.org/fhir/patient.html" - assert inst.name == "TestScript Example Read Test" - assert inst.profile[0].id == "patient-profile" - assert ( - inst.profile[0].reference == "http://hl7.org/fhir/StructureDefinition/Patient" - ) - assert inst.publisher == "HL7" - assert inst.purpose == "Patient Read Operation" - assert inst.status == "draft" - assert inst.test[0].action[0].operation.accept == "xml" - assert inst.test[0].action[0].operation.description == ( - "Read the known Patient resource on the destination test " - "system using the user defined dynamic variable " - "${KnownPatientResourceId}." - ) - assert inst.test[0].action[0].operation.encodeRequestUrl is True - assert inst.test[0].action[0].operation.params == "/${KnownPatientResourceId}" - assert inst.test[0].action[0].operation.resource == "Patient" - assert inst.test[0].action[0].operation.type.code == "read" - assert inst.test[0].action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.test[0].action[1].assert_fhir.description - == "Confirm that the returned HTTP status is 200(OK)." - ) - assert inst.test[0].action[1].assert_fhir.response == "okay" - assert inst.test[0].action[1].assert_fhir.warningOnly is False - assert inst.test[0].action[2].assert_fhir.contentType == "xml" - assert ( - inst.test[0].action[2].assert_fhir.description - == "Confirm that the returned format is XML." - ) - assert inst.test[0].action[2].assert_fhir.warningOnly is False - assert inst.test[0].action[3].assert_fhir.description == ( - "Confirm that the returned HTTP Header Last-Modified is " - "present. Warning only as the server might not support " - "versioning." - ) - assert inst.test[0].action[3].assert_fhir.headerField == "Last-Modified" - assert inst.test[0].action[3].assert_fhir.operator == "notEmpty" - assert inst.test[0].action[3].assert_fhir.warningOnly is True - assert ( - inst.test[0].action[4].assert_fhir.description - == "Confirm that the returned resource type is Patient." - ) - assert inst.test[0].action[4].assert_fhir.resource == "Patient" - assert inst.test[0].action[4].assert_fhir.warningOnly is False - assert inst.test[0].action[5].assert_fhir.description == ( - "Confirm that the returned Patient conforms to the base FHIR " "specification." - ) - assert inst.test[0].action[5].assert_fhir.validateProfileId == "patient-profile" - assert inst.test[0].action[5].assert_fhir.warningOnly is False - assert inst.test[0].description == "Read a known Patient and validate response." - assert inst.test[0].id == "R001" - assert inst.test[0].name == "Sprinkler Read Test R001" - assert inst.test[1].action[0].operation.accept == "xml" - assert inst.test[1].action[0].operation.encodeRequestUrl is True - assert inst.test[1].action[0].operation.params == "/1" - assert inst.test[1].action[0].operation.resource == "Patient" - assert inst.test[1].action[0].operation.type.code == "read" - assert inst.test[1].action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.test[1].action[1].assert_fhir.description - == "Confirm that the returned HTTP status is 404(Not Found)." - ) - assert inst.test[1].action[1].assert_fhir.response == "notFound" - assert inst.test[1].action[1].assert_fhir.warningOnly is False - assert ( - inst.test[1].description - == "Read an unknown Resource Type and validate response." - ) - assert inst.test[1].id == "R002" - assert inst.test[1].name == "Sprinkler Read Test R002" - assert inst.test[2].action[0].operation.accept == "xml" - assert inst.test[2].action[0].operation.description == ( - "Attempt to read the non-existing Patient resource on the " - "destination test system using the user defined dynamic " - "variable ${NonExistsPatientResourceId}." - ) - assert inst.test[2].action[0].operation.encodeRequestUrl is True - assert inst.test[2].action[0].operation.params == "/${NonExistsPatientResourceId}" - assert inst.test[2].action[0].operation.resource == "Patient" - assert inst.test[2].action[0].operation.type.code == "read" - assert inst.test[2].action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.test[2].action[1].assert_fhir.description - == "Confirm that the returned HTTP status is 404(Not Found)." - ) - assert inst.test[2].action[1].assert_fhir.response == "notFound" - assert inst.test[2].action[1].assert_fhir.warningOnly is False - assert ( - inst.test[2].description - == "Read a known, non-existing Patient and validate response." - ) - assert inst.test[2].id == "R003" - assert inst.test[2].name == "Sprinkler Read Test R003" - assert inst.test[3].action[0].operation.accept == "xml" - assert inst.test[3].action[0].operation.description == ( - "Attempt to read a Patient resource on the destination test " - "system using known bad formatted resource id." - ) - assert inst.test[3].action[0].operation.encodeRequestUrl is True - assert inst.test[3].action[0].operation.params == "/ID-may-not-contain-CAPITALS" - assert inst.test[3].action[0].operation.resource == "Patient" - assert inst.test[3].action[0].operation.type.code == "read" - assert inst.test[3].action[0].operation.type.system == ( - "http://terminology.hl7.org/CodeSystem/testscript-operation-" "codes" - ) - assert ( - inst.test[3].action[1].assert_fhir.description - == "Confirm that the returned HTTP status is 400(Bad Request)." - ) - assert inst.test[3].action[1].assert_fhir.response == "bad" - assert inst.test[3].action[1].assert_fhir.warningOnly is False - assert inst.test[3].description == ( - "Read a Patient using a known bad formatted resource id and " - "validate response." - ) - assert inst.test[3].id == "R004" - assert inst.test[3].name == "Sprinkler Read Test R004" - assert inst.text.status == "generated" - assert inst.url == "http://hl7.org/fhir/TestScript/testscript-example-readtest" - assert inst.variable[0].defaultValue == "example" - assert inst.variable[0].name == "KnownPatientResourceId" - assert inst.variable[1].defaultValue == "does-not-exist" - assert inst.variable[1].name == "NonExistsPatientResourceId" - assert inst.version == "1.0" - - -def test_testscript_6(base_settings): - """No. 6 tests collection for TestScript. - Test File: testscript-example-readtest.json - """ - filename = base_settings["unittest_data_dir"] / "testscript-example-readtest.json" - inst = testscript.TestScript.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "TestScript" == inst.resource_type - - impl_testscript_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "TestScript" == data["resourceType"] - - inst2 = testscript.TestScript(**data) - impl_testscript_6(inst2) diff --git a/fhir/resources/tests/test_valueset.py b/fhir/resources/tests/test_valueset.py deleted file mode 100644 index bdd07417..00000000 --- a/fhir/resources/tests/test_valueset.py +++ /dev/null @@ -1,661 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ValueSet -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import valueset - - -def impl_valueset_1(inst): - assert ( - inst.compose.include[0].system - == "http://terminology.hl7.org/CodeSystem/device-status-reason" - ) - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "The availability status reason of the device." - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "oo" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 2 - assert inst.id == "device-status-reason" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.3.1081" - assert inst.immutable is True - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablevalueset" - ) - assert inst.name == "FHIRDeviceStatusReason" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "FHIRDeviceStatusReason" - assert inst.url == "http://hl7.org/fhir/ValueSet/device-status-reason" - assert inst.version == "4.0.1" - - -def test_valueset_1(base_settings): - """No. 1 tests collection for ValueSet. - Test File: valueset-device-status-reason.json - """ - filename = base_settings["unittest_data_dir"] / "valueset-device-status-reason.json" - inst = valueset.ValueSet.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ValueSet" == inst.resource_type - - impl_valueset_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ValueSet" == data["resourceType"] - - inst2 = valueset.ValueSet(**data) - impl_valueset_1(inst2) - - -def impl_valueset_2(inst): - assert ( - inst.compose.include[0].system - == "http://hl7.org/fhir/definition-resource-types" - ) - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == ( - "A list of all the definition resource types defined in this " - "version of the FHIR specification." - ) - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "vocab" - assert inst.id == "definition-resource-types" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.3.1056" - assert inst.immutable is True - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablevalueset" - ) - assert inst.name == "DefinitionResourceType" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "DefinitionResourceType" - assert inst.url == "http://hl7.org/fhir/ValueSet/definition-resource-types" - assert inst.version == "4.0.1" - - -def test_valueset_2(base_settings): - """No. 2 tests collection for ValueSet. - Test File: valueset-definition-resource-types.json - """ - filename = ( - base_settings["unittest_data_dir"] / "valueset-definition-resource-types.json" - ) - inst = valueset.ValueSet.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ValueSet" == inst.resource_type - - impl_valueset_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ValueSet" == data["resourceType"] - - inst2 = valueset.ValueSet(**data) - impl_valueset_2(inst2) - - -def impl_valueset_3(inst): - assert inst.compose.include[0].concept[0].code == "419161000" - assert inst.compose.include[0].concept[0].display == "Unilateral left" - assert inst.compose.include[0].concept[1].code == "419465000" - assert inst.compose.include[0].concept[1].display == "Unilateral right" - assert inst.compose.include[0].concept[2].code == "51440002" - assert inst.compose.include[0].concept[2].display == "Bilateral" - assert inst.compose.include[0].concept[3].code == "261183002" - assert inst.compose.include[0].concept[3].display == "Upper" - assert inst.compose.include[0].concept[4].code == "261122009" - assert inst.compose.include[0].concept[4].display == "Lower" - assert inst.compose.include[0].concept[5].code == "255561001" - assert inst.compose.include[0].concept[5].display == "Medial" - assert inst.compose.include[0].concept[6].code == "49370004" - assert inst.compose.include[0].concept[6].display == "Lateral" - assert inst.compose.include[0].concept[7].code == "264217000" - assert inst.compose.include[0].concept[7].display == "Superior" - assert inst.compose.include[0].concept[8].code == "261089000" - assert inst.compose.include[0].concept[8].display == "Inferior" - assert inst.compose.include[0].concept[9].code == "255551008" - assert inst.compose.include[0].concept[9].display == "Posterior" - assert inst.compose.include[0].system == "http://snomed.info/sct" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "SNOMED-CT concepts modifying the anatomic location" - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "oo" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "draft" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 1 - assert inst.id == "bodystructure-relative-location" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.3.140" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablevalueset" - ) - assert inst.name == "BodystructureLocationQualifier" - assert inst.publisher == "Order and Observation Workgroup" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "Bodystructure Location Qualifier" - assert inst.url == "http://hl7.org/fhir/ValueSet/bodystructure-relative-location" - assert inst.version == "4.0.1" - - -def test_valueset_3(base_settings): - """No. 3 tests collection for ValueSet. - Test File: valueset-bodystructure-relative-location.json - """ - filename = ( - base_settings["unittest_data_dir"] - / "valueset-bodystructure-relative-location.json" - ) - inst = valueset.ValueSet.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ValueSet" == inst.resource_type - - impl_valueset_3(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ValueSet" == data["resourceType"] - - inst2 = valueset.ValueSet(**data) - impl_valueset_3(inst2) - - -def impl_valueset_4(inst): - assert inst.compose.include[0].system == "http://hl7.org/fhir/encounter-status" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "Current state of the encounter." - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "pa" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 2 - assert inst.id == "encounter-status" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.3.246" - assert inst.immutable is True - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablevalueset" - ) - assert inst.name == "EncounterStatus" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "EncounterStatus" - assert inst.url == "http://hl7.org/fhir/ValueSet/encounter-status" - assert inst.version == "4.0.1" - - -def test_valueset_4(base_settings): - """No. 4 tests collection for ValueSet. - Test File: valueset-encounter-status.json - """ - filename = base_settings["unittest_data_dir"] / "valueset-encounter-status.json" - inst = valueset.ValueSet.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ValueSet" == inst.resource_type - - impl_valueset_4(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ValueSet" == data["resourceType"] - - inst2 = valueset.ValueSet(**data) - impl_valueset_4(inst2) - - -def impl_valueset_5(inst): - assert ( - inst.compose.include[0].system - == "http://terminology.hl7.org/CodeSystem/consentscope" - ) - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.copyright == "This is an example set." - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "This value set includes the four Consent scope codes." - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "cbcc" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 2 - assert inst.id == "consent-scope" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.3.761" - assert inst.immutable is True - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablevalueset" - ) - assert inst.name == "ConsentScopeCodes" - assert inst.publisher == "CBCC" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "Consent Scope Codes" - assert inst.url == "http://hl7.org/fhir/ValueSet/consent-scope" - assert inst.version == "4.0.1" - - -def test_valueset_5(base_settings): - """No. 5 tests collection for ValueSet. - Test File: valueset-consent-scope.json - """ - filename = base_settings["unittest_data_dir"] / "valueset-consent-scope.json" - inst = valueset.ValueSet.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ValueSet" == inst.resource_type - - impl_valueset_5(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ValueSet" == data["resourceType"] - - inst2 = valueset.ValueSet(**data) - impl_valueset_5(inst2) - - -def impl_valueset_6(inst): - assert inst.compose.include[0].system == "http://hl7.org/fhir/report-status-codes" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "The current status of the test report." - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "fhir" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 0 - assert inst.id == "report-status-codes" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.3.724" - assert inst.immutable is True - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablevalueset" - ) - assert inst.name == "TestReportStatus" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "TestReportStatus" - assert inst.url == "http://hl7.org/fhir/ValueSet/report-status-codes" - assert inst.version == "4.0.1" - - -def test_valueset_6(base_settings): - """No. 6 tests collection for ValueSet. - Test File: valueset-report-status-codes.json - """ - filename = base_settings["unittest_data_dir"] / "valueset-report-status-codes.json" - inst = valueset.ValueSet.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ValueSet" == inst.resource_type - - impl_valueset_6(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ValueSet" == data["resourceType"] - - inst2 = valueset.ValueSet(**data) - impl_valueset_6(inst2) - - -def impl_valueset_7(inst): - assert inst.compose.include[0].system == "http://hl7.org/fhir/note-type" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "The presentation types of notes." - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "fm" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "trial-use" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 2 - assert inst.id == "note-type" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.3.15" - assert inst.immutable is True - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablevalueset" - ) - assert inst.name == "NoteType" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "NoteType" - assert inst.url == "http://hl7.org/fhir/ValueSet/note-type" - assert inst.version == "4.0.1" - - -def test_valueset_7(base_settings): - """No. 7 tests collection for ValueSet. - Test File: valueset-note-type.json - """ - filename = base_settings["unittest_data_dir"] / "valueset-note-type.json" - inst = valueset.ValueSet.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ValueSet" == inst.resource_type - - impl_valueset_7(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ValueSet" == data["resourceType"] - - inst2 = valueset.ValueSet(**data) - impl_valueset_7(inst2) - - -def impl_valueset_8(inst): - assert inst.compose.include[0].system == "https://precision.fda.gov/apps/" - assert inst.compose.include[1].system == "https://precision.fda.gov/jobs/" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "This value set includes sequence quality method" - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "cg" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "draft" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 1 - assert inst.id == "sequence-quality-method" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.3.223" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablevalueset" - ) - assert inst.name == "FDA-Method" - assert inst.publisher == "FHIR Project team" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "F d a- method" - assert inst.url == "http://hl7.org/fhir/ValueSet/sequence-quality-method" - assert inst.version == "4.0.1" - - -def test_valueset_8(base_settings): - """No. 8 tests collection for ValueSet. - Test File: valueset-sequence-quality-method.json - """ - filename = ( - base_settings["unittest_data_dir"] / "valueset-sequence-quality-method.json" - ) - inst = valueset.ValueSet.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ValueSet" == inst.resource_type - - impl_valueset_8(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ValueSet" == data["resourceType"] - - inst2 = valueset.ValueSet(**data) - impl_valueset_8(inst2) - - -def impl_valueset_9(inst): - assert inst.compose.include[0].system == "http://hl7.org/fhir/issue-severity" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.contact[0].telecom[1].system == "email" - assert inst.contact[0].telecom[1].value == "fhir@lists.hl7.org" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "How the issue affects the success of the action." - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "fhir" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "normative" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "normative-version" - ) - assert inst.extension[2].valueCode == "4.0.0" - assert inst.extension[3].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[3].valueInteger == 5 - assert inst.id == "issue-severity" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.3.408" - assert inst.immutable is True - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablevalueset" - ) - assert inst.name == "IssueSeverity" - assert inst.publisher == "HL7 (FHIR Project)" - assert inst.status == "active" - assert inst.text.status == "generated" - assert inst.title == "IssueSeverity" - assert inst.url == "http://hl7.org/fhir/ValueSet/issue-severity" - assert inst.version == "4.0.1" - - -def test_valueset_9(base_settings): - """No. 9 tests collection for ValueSet. - Test File: valueset-issue-severity.json - """ - filename = base_settings["unittest_data_dir"] / "valueset-issue-severity.json" - inst = valueset.ValueSet.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ValueSet" == inst.resource_type - - impl_valueset_9(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ValueSet" == data["resourceType"] - - inst2 = valueset.ValueSet(**data) - impl_valueset_9(inst2) - - -def impl_valueset_10(inst): - assert inst.compose.include[0].system == "http://www.ensembl.org" - assert inst.compose.include[1].system == "http://www.ncbi.nlm.nih.gov/nuccore" - assert inst.contact[0].telecom[0].system == "url" - assert inst.contact[0].telecom[0].value == "http://hl7.org/fhir" - assert inst.date == fhirtypes.DateTime.validate("2019-11-01T09:29:23+11:00") - assert inst.description == "This value set includes all Reference codes" - assert inst.experimental is False - assert inst.extension[0].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "wg" - ) - assert inst.extension[0].valueCode == "cg" - assert inst.extension[1].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" - "standards-status" - ) - assert inst.extension[1].valueCode == "draft" - assert inst.extension[2].url == ( - "http://hl7.org/fhir/StructureDefinition/structuredefinition-" "fmm" - ) - assert inst.extension[2].valueInteger == 1 - assert inst.id == "sequence-referenceSeq" - assert inst.identifier[0].system == "urn:ietf:rfc:3986" - assert inst.identifier[0].value == "urn:oid:2.16.840.1.113883.4.642.3.221" - assert inst.meta.lastUpdated == fhirtypes.Instant.validate( - "2019-11-01T09:29:23.356+11:00" - ) - assert ( - inst.meta.profile[0] - == "http://hl7.org/fhir/StructureDefinition/shareablevalueset" - ) - assert inst.name == "ENSEMBL" - assert inst.publisher == "FHIR Project team" - assert inst.status == "draft" - assert inst.text.status == "generated" - assert inst.title == "E n s e m b l" - assert inst.url == "http://hl7.org/fhir/ValueSet/sequence-referenceSeq" - assert inst.version == "4.0.1" - - -def test_valueset_10(base_settings): - """No. 10 tests collection for ValueSet. - Test File: valueset-sequence-referenceSeq.json - """ - filename = ( - base_settings["unittest_data_dir"] / "valueset-sequence-referenceSeq.json" - ) - inst = valueset.ValueSet.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "ValueSet" == inst.resource_type - - impl_valueset_10(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "ValueSet" == data["resourceType"] - - inst2 = valueset.ValueSet(**data) - impl_valueset_10(inst2) diff --git a/fhir/resources/tests/test_verificationresult.py b/fhir/resources/tests/test_verificationresult.py deleted file mode 100644 index 400bd693..00000000 --- a/fhir/resources/tests/test_verificationresult.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/VerificationResult -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import verificationresult - - -def impl_verificationresult_1(inst): - assert inst.id == "example" - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.status == "attested" - assert inst.text.div == ( - '

Generated ' - "Narrative with Details

id: " - "example

status: attested

" - ) - assert inst.text.status == "generated" - - -def test_verificationresult_1(base_settings): - """No. 1 tests collection for VerificationResult. - Test File: verificationresult-example.json - """ - filename = base_settings["unittest_data_dir"] / "verificationresult-example.json" - inst = verificationresult.VerificationResult.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "VerificationResult" == inst.resource_type - - impl_verificationresult_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "VerificationResult" == data["resourceType"] - - inst2 = verificationresult.VerificationResult(**data) - impl_verificationresult_1(inst2) diff --git a/fhir/resources/tests/test_visionprescription.py b/fhir/resources/tests/test_visionprescription.py deleted file mode 100644 index 5c966005..00000000 --- a/fhir/resources/tests/test_visionprescription.py +++ /dev/null @@ -1,153 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/VisionPrescription -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -from pydantic.validators import bytes_validator # noqa: F401 - -from .. import fhirtypes # noqa: F401 -from .. import visionprescription - - -def impl_visionprescription_1(inst): - assert inst.created == fhirtypes.DateTime.validate("2014-06-15") - assert inst.dateWritten == fhirtypes.DateTime.validate("2014-06-15") - assert inst.encounter.reference == "Encounter/f001" - assert inst.id == "33124" - assert inst.identifier[0].system == "http://www.happysight.com/prescription" - assert inst.identifier[0].value == "15014" - assert float(inst.lensSpecification[0].add) == float(1.75) - assert inst.lensSpecification[0].axis == 160 - assert float(inst.lensSpecification[0].backCurve) == float(8.7) - assert inst.lensSpecification[0].brand == "OphthaGuard" - assert inst.lensSpecification[0].color == "green" - assert float(inst.lensSpecification[0].cylinder) == float(-2.25) - assert float(inst.lensSpecification[0].diameter) == float(14.0) - assert inst.lensSpecification[0].duration.code == "month" - assert inst.lensSpecification[0].duration.system == "http://unitsofmeasure.org" - assert inst.lensSpecification[0].duration.unit == "month" - assert float(inst.lensSpecification[0].duration.value) == float(1) - assert inst.lensSpecification[0].eye == "right" - assert ( - inst.lensSpecification[0].note[0].text - == "Shade treatment for extreme light sensitivity" - ) - assert float(inst.lensSpecification[0].power) == float(-2.75) - assert inst.lensSpecification[0].product.coding[0].code == "contact" - assert inst.lensSpecification[0].product.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/ex-" "visionprescriptionproduct" - ) - assert float(inst.lensSpecification[1].add) == float(1.75) - assert inst.lensSpecification[1].axis == 160 - assert float(inst.lensSpecification[1].backCurve) == float(8.7) - assert inst.lensSpecification[1].brand == "OphthaGuard" - assert inst.lensSpecification[1].color == "green" - assert float(inst.lensSpecification[1].cylinder) == float(-3.5) - assert float(inst.lensSpecification[1].diameter) == float(14.0) - assert inst.lensSpecification[1].duration.code == "month" - assert inst.lensSpecification[1].duration.system == "http://unitsofmeasure.org" - assert inst.lensSpecification[1].duration.unit == "month" - assert float(inst.lensSpecification[1].duration.value) == float(1) - assert inst.lensSpecification[1].eye == "left" - assert ( - inst.lensSpecification[1].note[0].text - == "Shade treatment for extreme light sensitivity" - ) - assert float(inst.lensSpecification[1].power) == float(-2.75) - assert inst.lensSpecification[1].product.coding[0].code == "contact" - assert inst.lensSpecification[1].product.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/ex-" "visionprescriptionproduct" - ) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.prescriber.reference == "Practitioner/example" - assert inst.status == "active" - assert inst.text.div == ( - '
Sample Contract ' - "Lens prescription
" - ) - assert inst.text.status == "generated" - - -def test_visionprescription_1(base_settings): - """No. 1 tests collection for VisionPrescription. - Test File: visionprescription-example-1.json - """ - filename = base_settings["unittest_data_dir"] / "visionprescription-example-1.json" - inst = visionprescription.VisionPrescription.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "VisionPrescription" == inst.resource_type - - impl_visionprescription_1(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "VisionPrescription" == data["resourceType"] - - inst2 = visionprescription.VisionPrescription(**data) - impl_visionprescription_1(inst2) - - -def impl_visionprescription_2(inst): - assert inst.created == fhirtypes.DateTime.validate("2014-06-15") - assert inst.dateWritten == fhirtypes.DateTime.validate("2014-06-15") - assert inst.id == "33123" - assert inst.identifier[0].system == "http://www.happysight.com/prescription" - assert inst.identifier[0].value == "15013" - assert float(inst.lensSpecification[0].add) == float(2.0) - assert inst.lensSpecification[0].eye == "right" - assert float(inst.lensSpecification[0].prism[0].amount) == float(0.5) - assert inst.lensSpecification[0].prism[0].base == "down" - assert inst.lensSpecification[0].product.coding[0].code == "lens" - assert inst.lensSpecification[0].product.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/ex-" "visionprescriptionproduct" - ) - assert float(inst.lensSpecification[0].sphere) == float(-2.0) - assert float(inst.lensSpecification[1].add) == float(2.0) - assert inst.lensSpecification[1].axis == 180 - assert float(inst.lensSpecification[1].cylinder) == float(-0.5) - assert inst.lensSpecification[1].eye == "left" - assert float(inst.lensSpecification[1].prism[0].amount) == float(0.5) - assert inst.lensSpecification[1].prism[0].base == "up" - assert inst.lensSpecification[1].product.coding[0].code == "lens" - assert inst.lensSpecification[1].product.coding[0].system == ( - "http://terminology.hl7.org/CodeSystem/ex-" "visionprescriptionproduct" - ) - assert float(inst.lensSpecification[1].sphere) == float(-1.0) - assert inst.meta.tag[0].code == "HTEST" - assert inst.meta.tag[0].display == "test health data" - assert ( - inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" - ) - assert inst.patient.reference == "Patient/example" - assert inst.prescriber.reference == "Practitioner/example" - assert inst.status == "active" - assert inst.text.status == "generated" - - -def test_visionprescription_2(base_settings): - """No. 2 tests collection for VisionPrescription. - Test File: visionprescription-example.json - """ - filename = base_settings["unittest_data_dir"] / "visionprescription-example.json" - inst = visionprescription.VisionPrescription.parse_file( - filename, content_type="application/json", encoding="utf-8" - ) - assert "VisionPrescription" == inst.resource_type - - impl_visionprescription_2(inst) - - # testing reverse by generating data from itself and create again. - data = inst.dict() - assert "VisionPrescription" == data["resourceType"] - - inst2 = visionprescription.VisionPrescription(**data) - impl_visionprescription_2(inst2) diff --git a/fhir/resources/testscript.py b/fhir/resources/testscript.py deleted file mode 100644 index 13f8243a..00000000 --- a/fhir/resources/testscript.py +++ /dev/null @@ -1,2529 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/TestScript -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class TestScript(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Describes a set of tests. - A structured set of tests against a FHIR server or client implementation to - determine compliance against the FHIR specification. - """ - - resource_type = Field("TestScript", const=True) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the test script and/or its contents." - " Copyright statements are generally legal restrictions on the use and " - "publishing of the test script." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the test script was published. " - "The date must change when the business version changes and it must " - "change if the status code changes. In addition, it should change when " - "the substantive content of the test script changes." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the test script", - description=( - "A free text natural language description of the test script from a " - "consumer's perspective." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - destination: typing.List[fhirtypes.TestScriptDestinationType] = Field( - None, - alias="destination", - title=( - "An abstract server representing a destination or receiver in a message" - " exchange" - ), - description=( - "An abstract server used in operations within this test script in the " - "destination element." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this test script is authored for " - "testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - fixture: typing.List[fhirtypes.TestScriptFixtureType] = Field( - None, - alias="fixture", - title="Fixture in the test script - by reference (uri)", - description=( - "Fixture in the test script - by reference (uri). All fixtures are " - "required for the test script to execute." - ), - # if property is element of this resource. - element_property=True, - ) - - identifier: fhirtypes.IdentifierType = Field( - None, - alias="identifier", - title="Additional identifier for the test script", - description=( - "A formal identifier that is used to identify this test script when it " - "is represented in other formats, or referenced in a specification, " - "model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for test script (if applicable)", - description=( - "A legal or geographic region in which the test script is intended to " - "be used." - ), - # if property is element of this resource. - element_property=True, - ) - - metadata: fhirtypes.TestScriptMetadataType = Field( - None, - alias="metadata", - title=( - "Required capability that is assumed to function correctly on the FHIR " - "server being tested" - ), - description=( - "The required capability must exist and are assumed to function " - "correctly on the FHIR server being tested." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this test script (computer friendly)", - description=( - "A natural language name identifying the test script. This name should " - "be usable as an identifier for the module by machine processing " - "applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - origin: typing.List[fhirtypes.TestScriptOriginType] = Field( - None, - alias="origin", - title=( - "An abstract server representing a client or sender in a message " - "exchange" - ), - description=( - "An abstract server used in operations within this test script in the " - "origin element." - ), - # if property is element of this resource. - element_property=True, - ) - - profile: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="profile", - title="Reference of the validation profile", - description="Reference to the profile to be used for validation.", - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the test " - "script." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this test script is defined", - description=( - "Explanation of why this test script is needed and why it has been " - "designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - setup: fhirtypes.TestScriptSetupType = Field( - None, - alias="setup", - title="A series of required setup operations before tests are executed", - description=None, - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this test script. Enables tracking the life-cycle of the" - " content." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - teardown: fhirtypes.TestScriptTeardownType = Field( - None, - alias="teardown", - title="A series of required clean up steps", - description=( - "A series of operations required to clean up after all the tests are " - "executed (successfully or otherwise)." - ), - # if property is element of this resource. - element_property=True, - ) - - test: typing.List[fhirtypes.TestScriptTestType] = Field( - None, - alias="test", - title="A test in this script", - description=None, - # if property is element of this resource. - element_property=True, - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this test script (human friendly)", - description="A short, descriptive, user-friendly title for the test script.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this test script, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this test script when it is " - "referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this test script is (or will be) published. This URL can " - "be the target of a canonical reference. It SHALL remain the same when " - "the test script is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate test script instances." - ), - # if property is element of this resource. - element_property=True, - ) - - variable: typing.List[fhirtypes.TestScriptVariableType] = Field( - None, - alias="variable", - title="Placeholder for evaluated elements", - description=( - "Variable is set based either on element value in response body or on " - "header field value in the response headers." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the test script", - description=( - "The identifier that is used to identify this version of the test " - "script when it is referenced in a specification, model, design or " - "instance. This is an arbitrary value managed by the test script author" - " and is not expected to be globally unique. For example, it might be a" - " timestamp (e.g. yyyymmdd) if a managed version is not available. " - "There is also no expectation that versions can be placed in a " - "lexicographical sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScript`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "purpose", - "copyright", - "origin", - "destination", - "metadata", - "fixture", - "profile", - "variable", - "setup", - "test", - "teardown", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1245( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("name", "name__ext"), - ("status", "status__ext"), - ("url", "url__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestScriptDestination(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An abstract server representing a destination or receiver in a message - exchange. - An abstract server used in operations within this test script in the - destination element. - """ - - resource_type = Field("TestScriptDestination", const=True) - - index: fhirtypes.Integer = Field( - None, - alias="index", - title="The index of the abstract destination server starting at 1", - description=( - "Abstract name given to a destination server in this test script. The " - "name is provided as a number starting at 1." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - index__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_index", title="Extension field for ``index``." - ) - - profile: fhirtypes.CodingType = Field( - ..., - alias="profile", - title=( - "FHIR-Server | FHIR-SDC-FormManager | FHIR-SDC-FormReceiver | FHIR-SDC-" - "FormProcessor" - ), - description="The type of destination profile the test system supports.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptDestination`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "index", "profile"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2393( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("index", "index__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestScriptFixture(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Fixture in the test script - by reference (uri). - Fixture in the test script - by reference (uri). All fixtures are required - for the test script to execute. - """ - - resource_type = Field("TestScriptFixture", const=True) - - autocreate: bool = Field( - None, - alias="autocreate", - title="Whether or not to implicitly create the fixture during setup", - description=( - "Whether or not to implicitly create the fixture during setup. If true," - " the fixture is automatically created on each server being tested " - "during setup, therefore no create operation is required for this " - "fixture in the TestScript.setup section." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - autocreate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_autocreate", title="Extension field for ``autocreate``." - ) - - autodelete: bool = Field( - None, - alias="autodelete", - title="Whether or not to implicitly delete the fixture during teardown", - description=( - "Whether or not to implicitly delete the fixture during teardown. If " - "true, the fixture is automatically deleted on each server being tested" - " during teardown, therefore no delete operation is required for this " - "fixture in the TestScript.teardown section." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - autodelete__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_autodelete", title="Extension field for ``autodelete``." - ) - - resource: fhirtypes.ReferenceType = Field( - None, - alias="resource", - title="Reference of the resource", - description=( - "Reference to the resource (containing the contents of the resource " - "needed for operations)." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptFixture`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "autocreate", - "autodelete", - "resource", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1973( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("autocreate", "autocreate__ext"), - ("autodelete", "autodelete__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestScriptMetadata(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Required capability that is assumed to function correctly on the FHIR - server being tested. - The required capability must exist and are assumed to function correctly on - the FHIR server being tested. - """ - - resource_type = Field("TestScriptMetadata", const=True) - - capability: typing.List[fhirtypes.TestScriptMetadataCapabilityType] = Field( - ..., - alias="capability", - title=( - "Capabilities that are assumed to function correctly on the FHIR " - "server being tested" - ), - description=( - "Capabilities that must exist and are assumed to function correctly on " - "the FHIR server being tested." - ), - # if property is element of this resource. - element_property=True, - ) - - link: typing.List[fhirtypes.TestScriptMetadataLinkType] = Field( - None, - alias="link", - title="Links to the FHIR specification", - description="A link to the FHIR specification that this test is covering.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptMetadata`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "link", "capability"] - - -class TestScriptMetadataCapability(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Capabilities that are assumed to function correctly on the FHIR server - being tested. - Capabilities that must exist and are assumed to function correctly on the - FHIR server being tested. - """ - - resource_type = Field("TestScriptMetadataCapability", const=True) - - capabilities: fhirtypes.Canonical = Field( - None, - alias="capabilities", - title="Required Capability Statement", - description=( - "Minimum capabilities required of server for test script to execute " - "successfully. If server does not meet at a minimum the referenced " - "capability statement, then all tests in this script are skipped." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["CapabilityStatement"], - ) - capabilities__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_capabilities", title="Extension field for ``capabilities``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="The expected capabilities of the server", - description=( - "Description of the capabilities that this test script is requiring the" - " server to support." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - destination: fhirtypes.Integer = Field( - None, - alias="destination", - title="Which server these requirements apply to", - description=None, - # if property is element of this resource. - element_property=True, - ) - destination__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_destination", title="Extension field for ``destination``." - ) - - link: typing.List[fhirtypes.Uri] = Field( - None, - alias="link", - title="Links to the FHIR specification", - description=( - "Links to the FHIR specification that describes this interaction and " - "the resources involved in more detail." - ), - # if property is element of this resource. - element_property=True, - ) - link__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_link", title="Extension field for ``link``.") - - origin: typing.List[fhirtypes.Integer] = Field( - None, - alias="origin", - title="Which origin server these requirements apply to", - description=None, - # if property is element of this resource. - element_property=True, - ) - origin__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_origin", title="Extension field for ``origin``.") - - required: bool = Field( - None, - alias="required", - title="Are the capabilities required?", - description=( - "Whether or not the test execution will require the given capabilities " - "of the server in order for this test script to execute." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - required__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_required", title="Extension field for ``required``." - ) - - validated: bool = Field( - None, - alias="validated", - title="Are the capabilities validated?", - description=( - "Whether or not the test execution will validate the given capabilities" - " of the server in order for this test script to execute." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - validated__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_validated", title="Extension field for ``validated``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptMetadataCapability`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "required", - "validated", - "description", - "origin", - "destination", - "link", - "capabilities", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3077( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("capabilities", "capabilities__ext"), - ("required", "required__ext"), - ("validated", "validated__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestScriptMetadataLink(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Links to the FHIR specification. - A link to the FHIR specification that this test is covering. - """ - - resource_type = Field("TestScriptMetadataLink", const=True) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Short description", - description="Short description of the link.", - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title="URL to the specification", - description=( - "URL to a particular requirement or feature within the FHIR " - "specification." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptMetadataLink`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "url", "description"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2435( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("url", "url__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestScriptOrigin(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - An abstract server representing a client or sender in a message exchange. - An abstract server used in operations within this test script in the origin - element. - """ - - resource_type = Field("TestScriptOrigin", const=True) - - index: fhirtypes.Integer = Field( - None, - alias="index", - title="The index of the abstract origin server starting at 1", - description=( - "Abstract name given to an origin server in this test script. The name" - " is provided as a number starting at 1." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - index__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_index", title="Extension field for ``index``." - ) - - profile: fhirtypes.CodingType = Field( - ..., - alias="profile", - title="FHIR-Client | FHIR-SDC-FormFiller", - description="The type of origin profile the test system supports.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptOrigin`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "index", "profile"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1855( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("index", "index__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestScriptSetup(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A series of required setup operations before tests are executed. - """ - - resource_type = Field("TestScriptSetup", const=True) - - action: typing.List[fhirtypes.TestScriptSetupActionType] = Field( - ..., - alias="action", - title="A setup operation or assert to perform", - description="Action would contain either an operation or an assertion.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptSetup`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "action"] - - -class TestScriptSetupAction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A setup operation or assert to perform. - Action would contain either an operation or an assertion. - """ - - resource_type = Field("TestScriptSetupAction", const=True) - - assert_fhir: fhirtypes.TestScriptSetupActionAssertType = Field( - None, - alias="assert", - title="The assertion to perform", - description=( - "Evaluates the results of previous operations to determine if the " - "server under test behaves appropriately." - ), - # if property is element of this resource. - element_property=True, - ) - - operation: fhirtypes.TestScriptSetupActionOperationType = Field( - None, - alias="operation", - title="The setup operation to perform", - description="The operation to perform.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptSetupAction`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "operation", "assert"] - - -class TestScriptSetupActionAssert(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The assertion to perform. - Evaluates the results of previous operations to determine if the server - under test behaves appropriately. - """ - - resource_type = Field("TestScriptSetupActionAssert", const=True) - - compareToSourceExpression: fhirtypes.String = Field( - None, - alias="compareToSourceExpression", - title="The FHIRPath expression to evaluate against the source fixture", - description=( - "The FHIRPath expression to evaluate against the source fixture. When " - "compareToSourceId is defined, either compareToSourceExpression or " - "compareToSourcePath must be defined, but not both." - ), - # if property is element of this resource. - element_property=True, - ) - compareToSourceExpression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_compareToSourceExpression", - title="Extension field for ``compareToSourceExpression``.", - ) - - compareToSourceId: fhirtypes.String = Field( - None, - alias="compareToSourceId", - title="Id of the source fixture to be evaluated", - description=( - "Id of the source fixture used as the contents to be evaluated by " - 'either the "source/expression" or "sourceId/path" definition.' - ), - # if property is element of this resource. - element_property=True, - ) - compareToSourceId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_compareToSourceId", - title="Extension field for ``compareToSourceId``.", - ) - - compareToSourcePath: fhirtypes.String = Field( - None, - alias="compareToSourcePath", - title="XPath or JSONPath expression to evaluate against the source fixture", - description=( - "XPath or JSONPath expression to evaluate against the source fixture. " - "When compareToSourceId is defined, either compareToSourceExpression or" - " compareToSourcePath must be defined, but not both." - ), - # if property is element of this resource. - element_property=True, - ) - compareToSourcePath__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_compareToSourcePath", - title="Extension field for ``compareToSourcePath``.", - ) - - contentType: fhirtypes.Code = Field( - None, - alias="contentType", - title="Mime type to compare against the 'Content-Type' header", - description=( - "The mime-type contents to compare against the request or response " - "message 'Content-Type' header." - ), - # if property is element of this resource. - element_property=True, - ) - contentType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_contentType", title="Extension field for ``contentType``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Tracking/reporting assertion description", - description=( - "The description would be used by test engines for tracking and " - "reporting purposes." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - direction: fhirtypes.Code = Field( - None, - alias="direction", - title="response | request", - description="The direction to use for the assertion.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["response", "request"], - ) - direction__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_direction", title="Extension field for ``direction``." - ) - - expression: fhirtypes.String = Field( - None, - alias="expression", - title="The FHIRPath expression to be evaluated", - description=( - "The FHIRPath expression to be evaluated against the request or " - "response message contents - HTTP headers and payload." - ), - # if property is element of this resource. - element_property=True, - ) - expression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expression", title="Extension field for ``expression``." - ) - - headerField: fhirtypes.String = Field( - None, - alias="headerField", - title="HTTP header field name", - description="The HTTP header field name e.g. 'Location'.", - # if property is element of this resource. - element_property=True, - ) - headerField__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_headerField", title="Extension field for ``headerField``." - ) - - label: fhirtypes.String = Field( - None, - alias="label", - title="Tracking/logging assertion label", - description="The label would be used for tracking/logging purposes by test engines.", - # if property is element of this resource. - element_property=True, - ) - label__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_label", title="Extension field for ``label``." - ) - - minimumId: fhirtypes.String = Field( - None, - alias="minimumId", - title="Fixture Id of minimum content resource", - description=( - "The ID of a fixture. Asserts that the response contains at a minimum " - "the fixture specified by minimumId." - ), - # if property is element of this resource. - element_property=True, - ) - minimumId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_minimumId", title="Extension field for ``minimumId``." - ) - - navigationLinks: bool = Field( - None, - alias="navigationLinks", - title="Perform validation on navigation links?", - description=( - "Whether or not the test execution performs validation on the bundle " - "navigation links." - ), - # if property is element of this resource. - element_property=True, - ) - navigationLinks__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_navigationLinks", title="Extension field for ``navigationLinks``." - ) - - operator: fhirtypes.Code = Field( - None, - alias="operator", - title=( - "equals | notEquals | in | notIn | greaterThan | lessThan | empty | " - "notEmpty | contains | notContains | eval" - ), - description=( - "The operator type defines the conditional behavior of the assert. If " - "not defined, the default is equals." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "equals", - "notEquals", - "in", - "notIn", - "greaterThan", - "lessThan", - "empty", - "notEmpty", - "contains", - "notContains", - "eval", - ], - ) - operator__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_operator", title="Extension field for ``operator``." - ) - - path: fhirtypes.String = Field( - None, - alias="path", - title="XPath or JSONPath expression", - description=( - "The XPath or JSONPath expression to be evaluated against the fixture " - "representing the response received from server." - ), - # if property is element of this resource. - element_property=True, - ) - path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_path", title="Extension field for ``path``." - ) - - requestMethod: fhirtypes.Code = Field( - None, - alias="requestMethod", - title="delete | get | options | patch | post | put | head", - description=( - "The request method or HTTP operation code to compare against that used" - " by the client system under test." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["delete", "get", "options", "patch", "post", "put", "head"], - ) - requestMethod__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_requestMethod", title="Extension field for ``requestMethod``." - ) - - requestURL: fhirtypes.String = Field( - None, - alias="requestURL", - title="Request URL comparison value", - description="The value to use in a comparison against the request URL path string.", - # if property is element of this resource. - element_property=True, - ) - requestURL__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_requestURL", title="Extension field for ``requestURL``." - ) - - resource: fhirtypes.Code = Field( - None, - alias="resource", - title="Resource type", - description=( - "The type of the resource. See " "http://build.fhir.org/resourcelist.html." - ), - # if property is element of this resource. - element_property=True, - ) - resource__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_resource", title="Extension field for ``resource``." - ) - - response: fhirtypes.Code = Field( - None, - alias="response", - title=( - "okay | created | noContent | notModified | bad | forbidden | notFound " - "| methodNotAllowed | conflict | gone | preconditionFailed | " - "unprocessable" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "okay", - "created", - "noContent", - "notModified", - "bad", - "forbidden", - "notFound", - "methodNotAllowed", - "conflict", - "gone", - "preconditionFailed", - "unprocessable", - ], - ) - response__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_response", title="Extension field for ``response``." - ) - - responseCode: fhirtypes.String = Field( - None, - alias="responseCode", - title="HTTP response code to test", - description="The value of the HTTP response code to be tested.", - # if property is element of this resource. - element_property=True, - ) - responseCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_responseCode", title="Extension field for ``responseCode``." - ) - - sourceId: fhirtypes.Id = Field( - None, - alias="sourceId", - title="Fixture Id of source expression or headerField", - description=( - "Fixture to evaluate the XPath/JSONPath expression or the headerField " - "against." - ), - # if property is element of this resource. - element_property=True, - ) - sourceId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sourceId", title="Extension field for ``sourceId``." - ) - - validateProfileId: fhirtypes.Id = Field( - None, - alias="validateProfileId", - title="Profile Id of validation profile reference", - description="The ID of the Profile to validate against.", - # if property is element of this resource. - element_property=True, - ) - validateProfileId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_validateProfileId", - title="Extension field for ``validateProfileId``.", - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="The value to compare to", - description=None, - # if property is element of this resource. - element_property=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - warningOnly: bool = Field( - None, - alias="warningOnly", - title="Will this assert produce a warning only on error?", - description=( - "Whether or not the test execution will produce a warning only on error" - " for this assert." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - warningOnly__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_warningOnly", title="Extension field for ``warningOnly``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptSetupActionAssert`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "label", - "description", - "direction", - "compareToSourceId", - "compareToSourceExpression", - "compareToSourcePath", - "contentType", - "expression", - "headerField", - "minimumId", - "navigationLinks", - "operator", - "path", - "requestMethod", - "requestURL", - "resource", - "response", - "responseCode", - "sourceId", - "validateProfileId", - "value", - "warningOnly", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3006( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("warningOnly", "warningOnly__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestScriptSetupActionOperation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - The setup operation to perform. - The operation to perform. - """ - - resource_type = Field("TestScriptSetupActionOperation", const=True) - - accept: fhirtypes.Code = Field( - None, - alias="accept", - title="Mime type to accept in the payload of the response, with charset etc.", - description="The mime-type to use for RESTful operation in the 'Accept' header.", - # if property is element of this resource. - element_property=True, - ) - accept__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_accept", title="Extension field for ``accept``." - ) - - contentType: fhirtypes.Code = Field( - None, - alias="contentType", - title="Mime type of the request payload contents, with charset etc.", - description=( - "The mime-type to use for RESTful operation in the 'Content-Type' " - "header." - ), - # if property is element of this resource. - element_property=True, - ) - contentType__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_contentType", title="Extension field for ``contentType``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Tracking/reporting operation description", - description=( - "The description would be used by test engines for tracking and " - "reporting purposes." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - destination: fhirtypes.Integer = Field( - None, - alias="destination", - title="Server responding to the request", - description=( - "The server where the request message is destined for. Must be one of " - "the server numbers listed in TestScript.destination section." - ), - # if property is element of this resource. - element_property=True, - ) - destination__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_destination", title="Extension field for ``destination``." - ) - - encodeRequestUrl: bool = Field( - None, - alias="encodeRequestUrl", - title="Whether or not to send the request url in encoded format", - description=( - "Whether or not to implicitly send the request url in encoded format. " - "The default is true to match the standard RESTful client behavior. Set" - " to false when communicating with a server that does not support " - "encoded url paths." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - encodeRequestUrl__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_encodeRequestUrl", - title="Extension field for ``encodeRequestUrl``.", - ) - - label: fhirtypes.String = Field( - None, - alias="label", - title="Tracking/logging operation label", - description="The label would be used for tracking/logging purposes by test engines.", - # if property is element of this resource. - element_property=True, - ) - label__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_label", title="Extension field for ``label``." - ) - - method: fhirtypes.Code = Field( - None, - alias="method", - title="delete | get | options | patch | post | put | head", - description=( - "The HTTP method the test engine MUST use for this operation regardless" - " of any other operation details." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["delete", "get", "options", "patch", "post", "put", "head"], - ) - method__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_method", title="Extension field for ``method``." - ) - - origin: fhirtypes.Integer = Field( - None, - alias="origin", - title="Server initiating the request", - description=( - "The server where the request message originates from. Must be one of " - "the server numbers listed in TestScript.origin section." - ), - # if property is element of this resource. - element_property=True, - ) - origin__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_origin", title="Extension field for ``origin``." - ) - - params: fhirtypes.String = Field( - None, - alias="params", - title="Explicitly defined path parameters", - description=( - "Path plus parameters after [type]. Used to set parts of the request " - "URL explicitly." - ), - # if property is element of this resource. - element_property=True, - ) - params__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_params", title="Extension field for ``params``." - ) - - requestHeader: typing.List[ - fhirtypes.TestScriptSetupActionOperationRequestHeaderType - ] = Field( - None, - alias="requestHeader", - title="Each operation can have one or more header elements", - description="Header elements would be used to set HTTP headers.", - # if property is element of this resource. - element_property=True, - ) - - requestId: fhirtypes.Id = Field( - None, - alias="requestId", - title="Fixture Id of mapped request", - description="The fixture id (maybe new) to map to the request.", - # if property is element of this resource. - element_property=True, - ) - requestId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_requestId", title="Extension field for ``requestId``." - ) - - resource: fhirtypes.Code = Field( - None, - alias="resource", - title="Resource type", - description=( - "The type of the resource. See " "http://build.fhir.org/resourcelist.html." - ), - # if property is element of this resource. - element_property=True, - ) - resource__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_resource", title="Extension field for ``resource``." - ) - - responseId: fhirtypes.Id = Field( - None, - alias="responseId", - title="Fixture Id of mapped response", - description="The fixture id (maybe new) to map to the response.", - # if property is element of this resource. - element_property=True, - ) - responseId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_responseId", title="Extension field for ``responseId``." - ) - - sourceId: fhirtypes.Id = Field( - None, - alias="sourceId", - title="Fixture Id of body for PUT and POST requests", - description="The id of the fixture used as the body of a PUT or POST request.", - # if property is element of this resource. - element_property=True, - ) - sourceId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sourceId", title="Extension field for ``sourceId``." - ) - - targetId: fhirtypes.Id = Field( - None, - alias="targetId", - title=( - "Id of fixture used for extracting the [id], [type], and [vid] for GET" - " requests" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - targetId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_targetId", title="Extension field for ``targetId``." - ) - - type: fhirtypes.CodingType = Field( - None, - alias="type", - title="The operation code type that will be executed", - description="Server interaction or operation type.", - # if property is element of this resource. - element_property=True, - ) - - url: fhirtypes.String = Field( - None, - alias="url", - title="Request URL", - description="Complete request URL.", - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptSetupActionOperation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "type", - "resource", - "label", - "description", - "accept", - "contentType", - "destination", - "encodeRequestUrl", - "method", - "origin", - "params", - "requestHeader", - "requestId", - "responseId", - "sourceId", - "targetId", - "url", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3319( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("encodeRequestUrl", "encodeRequestUrl__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestScriptSetupActionOperationRequestHeader(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Each operation can have one or more header elements. - Header elements would be used to set HTTP headers. - """ - - resource_type = Field("TestScriptSetupActionOperationRequestHeader", const=True) - - field: fhirtypes.String = Field( - None, - alias="field", - title="HTTP header field name", - description='The HTTP header field e.g. "Accept".', - # if property is element of this resource. - element_property=True, - element_required=True, - ) - field__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_field", title="Extension field for ``field``." - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="HTTP headerfield value", - description='The value of the header e.g. "application/fhir+xml".', - # if property is element of this resource. - element_property=True, - element_required=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptSetupActionOperationRequestHeader`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "field", "value"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4653( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("field", "field__ext"), ("value", "value__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class TestScriptTeardown(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A series of required clean up steps. - A series of operations required to clean up after all the tests are - executed (successfully or otherwise). - """ - - resource_type = Field("TestScriptTeardown", const=True) - - action: typing.List[fhirtypes.TestScriptTeardownActionType] = Field( - ..., - alias="action", - title="One or more teardown operations to perform", - description="The teardown action will only contain an operation.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptTeardown`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "action"] - - -class TestScriptTeardownAction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - One or more teardown operations to perform. - The teardown action will only contain an operation. - """ - - resource_type = Field("TestScriptTeardownAction", const=True) - - operation: fhirtypes.TestScriptSetupActionOperationType = Field( - ..., - alias="operation", - title="The teardown operation to perform", - description="An operation would involve a REST request to a server.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptTeardownAction`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "operation"] - - -class TestScriptTest(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A test in this script. - """ - - resource_type = Field("TestScriptTest", const=True) - - action: typing.List[fhirtypes.TestScriptTestActionType] = Field( - ..., - alias="action", - title="A test operation or assert to perform", - description="Action would contain either an operation or an assertion.", - # if property is element of this resource. - element_property=True, - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Tracking/reporting short description of the test", - description=( - "A short description of the test used by test engines for tracking and " - "reporting purposes." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Tracking/logging name of this test", - description=( - "The name of this test used for tracking/logging purposes by test " - "engines." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptTest`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "name", "description", "action"] - - -class TestScriptTestAction(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A test operation or assert to perform. - Action would contain either an operation or an assertion. - """ - - resource_type = Field("TestScriptTestAction", const=True) - - assert_fhir: fhirtypes.TestScriptSetupActionAssertType = Field( - None, - alias="assert", - title="The setup assertion to perform", - description=( - "Evaluates the results of previous operations to determine if the " - "server under test behaves appropriately." - ), - # if property is element of this resource. - element_property=True, - ) - - operation: fhirtypes.TestScriptSetupActionOperationType = Field( - None, - alias="operation", - title="The setup operation to perform", - description="An operation would involve a REST request to a server.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptTestAction`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "operation", "assert"] - - -class TestScriptVariable(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Placeholder for evaluated elements. - Variable is set based either on element value in response body or on header - field value in the response headers. - """ - - resource_type = Field("TestScriptVariable", const=True) - - defaultValue: fhirtypes.String = Field( - None, - alias="defaultValue", - title="Default, hard-coded, or user-defined value for this variable", - description="A default, hard-coded, or user-defined value for this variable.", - # if property is element of this resource. - element_property=True, - ) - defaultValue__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_defaultValue", title="Extension field for ``defaultValue``." - ) - - description: fhirtypes.String = Field( - None, - alias="description", - title="Natural language description of the variable", - description=( - "A free text natural language description of the variable and its " - "purpose." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - expression: fhirtypes.String = Field( - None, - alias="expression", - title="The FHIRPath expression against the fixture body", - description=( - "The FHIRPath expression to evaluate against the fixture body. When " - "variables are defined, only one of either expression, headerField or " - "path must be specified." - ), - # if property is element of this resource. - element_property=True, - ) - expression__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_expression", title="Extension field for ``expression``." - ) - - headerField: fhirtypes.String = Field( - None, - alias="headerField", - title="HTTP header field name for source", - description=( - "Will be used to grab the HTTP header field value from the headers that" - " sourceId is pointing to." - ), - # if property is element of this resource. - element_property=True, - ) - headerField__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_headerField", title="Extension field for ``headerField``." - ) - - hint: fhirtypes.String = Field( - None, - alias="hint", - title="Hint help text for default value to enter", - description=( - "Displayable text string with hint help information to the user when " - "entering a default value." - ), - # if property is element of this resource. - element_property=True, - ) - hint__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_hint", title="Extension field for ``hint``." - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Descriptive name for this variable", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - path: fhirtypes.String = Field( - None, - alias="path", - title="XPath or JSONPath against the fixture body", - description=( - "XPath or JSONPath to evaluate against the fixture body. When " - "variables are defined, only one of either expression, headerField or " - "path must be specified." - ), - # if property is element of this resource. - element_property=True, - ) - path__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_path", title="Extension field for ``path``." - ) - - sourceId: fhirtypes.Id = Field( - None, - alias="sourceId", - title="Fixture Id of source expression or headerField within this variable", - description=( - "Fixture to evaluate the XPath/JSONPath expression or the headerField " - "against within this variable." - ), - # if property is element of this resource. - element_property=True, - ) - sourceId__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sourceId", title="Extension field for ``sourceId``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TestScriptVariable`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "defaultValue", - "description", - "expression", - "headerField", - "hint", - "path", - "sourceId", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2036( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values diff --git a/fhir/resources/timing.py b/fhir/resources/timing.py deleted file mode 100644 index d18b2c6e..00000000 --- a/fhir/resources/timing.py +++ /dev/null @@ -1,422 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/Timing -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import backboneelement, element, fhirtypes - - -class Timing(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A timing schedule that specifies an event that may occur multiple times. - Specifies an event that may occur multiple times. Timing schedules are used - to record when things are planned, expected or requested to occur. The most - common usage is in dosage instructions for medications. They are also used - when planning care of various kinds, and may be used for reporting the - schedule to which past regular activities were carried out. - """ - - resource_type = Field("Timing", const=True) - - code: fhirtypes.CodeableConceptType = Field( - None, - alias="code", - title="BID | TID | QID | AM | PM | QD | QOD | +", - description=( - "A code for the timing schedule (or just text in code.text). Some codes" - " such as BID are ubiquitous, but many institutions define their own " - "additional codes. If a code is provided, the code is understood to be " - "a complete statement of whatever is specified in the structured timing" - " data, and either the code or the data may be used to interpret the " - "Timing, with the exception that .repeat.bounds still applies over the " - "code (and is not contained in the code)." - ), - # if property is element of this resource. - element_property=True, - ) - - event: typing.List[fhirtypes.DateTime] = Field( - None, - alias="event", - title="When the event occurs", - description="Identifies specific times when the event occurs.", - # if property is element of this resource. - element_property=True, - ) - event__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_event", title="Extension field for ``event``.") - - repeat: fhirtypes.TimingRepeatType = Field( - None, - alias="repeat", - title="When the event is to occur", - description="A set of rules that describe when the event is scheduled.", - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``Timing`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "event", "repeat", "code"] - - -class TimingRepeat(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - When the event is to occur. - A set of rules that describe when the event is scheduled. - """ - - resource_type = Field("TimingRepeat", const=True) - - boundsDuration: fhirtypes.DurationType = Field( - None, - alias="boundsDuration", - title="Length/Range of lengths, or (Start and/or end) limits", - description=( - "Either a duration for the length of the timing schedule, a range of " - "possible length, or outer bounds for start and/or end limits of the " - "timing schedule." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e bounds[x] - one_of_many="bounds", - one_of_many_required=False, - ) - - boundsPeriod: fhirtypes.PeriodType = Field( - None, - alias="boundsPeriod", - title="Length/Range of lengths, or (Start and/or end) limits", - description=( - "Either a duration for the length of the timing schedule, a range of " - "possible length, or outer bounds for start and/or end limits of the " - "timing schedule." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e bounds[x] - one_of_many="bounds", - one_of_many_required=False, - ) - - boundsRange: fhirtypes.RangeType = Field( - None, - alias="boundsRange", - title="Length/Range of lengths, or (Start and/or end) limits", - description=( - "Either a duration for the length of the timing schedule, a range of " - "possible length, or outer bounds for start and/or end limits of the " - "timing schedule." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e bounds[x] - one_of_many="bounds", - one_of_many_required=False, - ) - - count: fhirtypes.PositiveInt = Field( - None, - alias="count", - title="Number of times to repeat", - description=( - "A total count of the desired number of repetitions across the duration" - " of the entire timing specification. If countMax is present, this " - "element indicates the lower bound of the allowed range of count " - "values." - ), - # if property is element of this resource. - element_property=True, - ) - count__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_count", title="Extension field for ``count``." - ) - - countMax: fhirtypes.PositiveInt = Field( - None, - alias="countMax", - title="Maximum number of times to repeat", - description=( - "If present, indicates that the count is a range - so to perform the " - "action between [count] and [countMax] times." - ), - # if property is element of this resource. - element_property=True, - ) - countMax__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_countMax", title="Extension field for ``countMax``." - ) - - dayOfWeek: typing.List[fhirtypes.Code] = Field( - None, - alias="dayOfWeek", - title="mon | tue | wed | thu | fri | sat | sun", - description=( - "If one or more days of week is provided, then the action happens only " - "on the specified day(s)." - ), - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["mon", "tue", "wed", "thu", "fri", "sat", "sun"], - ) - dayOfWeek__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_dayOfWeek", title="Extension field for ``dayOfWeek``.") - - duration: fhirtypes.Decimal = Field( - None, - alias="duration", - title="How long when it happens", - description=( - "How long this thing happens for when it happens. If durationMax is " - "present, this element indicates the lower bound of the allowed range " - "of the duration." - ), - # if property is element of this resource. - element_property=True, - ) - duration__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_duration", title="Extension field for ``duration``." - ) - - durationMax: fhirtypes.Decimal = Field( - None, - alias="durationMax", - title="How long when it happens (Max)", - description=( - "If present, indicates that the duration is a range - so to perform the" - " action between [duration] and [durationMax] time length." - ), - # if property is element of this resource. - element_property=True, - ) - durationMax__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_durationMax", title="Extension field for ``durationMax``." - ) - - durationUnit: fhirtypes.Code = Field( - None, - alias="durationUnit", - title="s | min | h | d | wk | mo | a - unit of time (UCUM)", - description="The units of time for the duration, in UCUM units.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["s", "min", "h", "d", "wk", "mo", "a"], - ) - durationUnit__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_durationUnit", title="Extension field for ``durationUnit``." - ) - - frequency: fhirtypes.PositiveInt = Field( - None, - alias="frequency", - title="Event occurs frequency times per period", - description=( - "The number of times to repeat the action within the specified period. " - "If frequencyMax is present, this element indicates the lower bound of " - "the allowed range of the frequency." - ), - # if property is element of this resource. - element_property=True, - ) - frequency__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_frequency", title="Extension field for ``frequency``." - ) - - frequencyMax: fhirtypes.PositiveInt = Field( - None, - alias="frequencyMax", - title="Event occurs up to frequencyMax times per period", - description=( - "If present, indicates that the frequency is a range - so to repeat " - "between [frequency] and [frequencyMax] times within the period or " - "period range." - ), - # if property is element of this resource. - element_property=True, - ) - frequencyMax__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_frequencyMax", title="Extension field for ``frequencyMax``." - ) - - offset: fhirtypes.UnsignedInt = Field( - None, - alias="offset", - title="Minutes from event (before or after)", - description=( - "The number of minutes from the event. If the event code does not " - "indicate whether the minutes is before or after the event, then the " - "offset is assumed to be after the event." - ), - # if property is element of this resource. - element_property=True, - ) - offset__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_offset", title="Extension field for ``offset``." - ) - - period: fhirtypes.Decimal = Field( - None, - alias="period", - title="Event occurs frequency times per period", - description=( - "Indicates the duration of time over which repetitions are to occur; " - 'e.g. to express "3 times per day", 3 would be the frequency and "1 ' - 'day" would be the period. If periodMax is present, this element ' - "indicates the lower bound of the allowed range of the period length." - ), - # if property is element of this resource. - element_property=True, - ) - period__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_period", title="Extension field for ``period``." - ) - - periodMax: fhirtypes.Decimal = Field( - None, - alias="periodMax", - title="Upper limit of period (3-4 hours)", - description=( - "If present, indicates that the period is a range from [period] to " - '[periodMax], allowing expressing concepts such as "do this once every ' - "3-5 days." - ), - # if property is element of this resource. - element_property=True, - ) - periodMax__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_periodMax", title="Extension field for ``periodMax``." - ) - - periodUnit: fhirtypes.Code = Field( - None, - alias="periodUnit", - title="s | min | h | d | wk | mo | a - unit of time (UCUM)", - description="The units of time for the period in UCUM units.", - # if property is element of this resource. - element_property=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["s", "min", "h", "d", "wk", "mo", "a"], - ) - periodUnit__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_periodUnit", title="Extension field for ``periodUnit``." - ) - - timeOfDay: typing.List[fhirtypes.Time] = Field( - None, - alias="timeOfDay", - title="Time of day for action", - description="Specified time of day for action to take place.", - # if property is element of this resource. - element_property=True, - ) - timeOfDay__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_timeOfDay", title="Extension field for ``timeOfDay``.") - - when: typing.List[fhirtypes.Code] = Field( - None, - alias="when", - title="Code for time period of occurrence", - description=( - "An approximate time period during the day, potentially linked to an " - "event of daily living that indicates when the action should occur." - ), - # if property is element of this resource. - element_property=True, - ) - when__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_when", title="Extension field for ``when``.") - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TimingRepeat`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "boundsDuration", - "boundsRange", - "boundsPeriod", - "count", - "countMax", - "duration", - "durationMax", - "durationUnit", - "frequency", - "frequencyMax", - "period", - "periodMax", - "periodUnit", - "dayOfWeek", - "timeOfDay", - "when", - "offset", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1425( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "bounds": ["boundsDuration", "boundsPeriod", "boundsRange"] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/triggerdefinition.py b/fhir/resources/triggerdefinition.py deleted file mode 100644 index 4164009a..00000000 --- a/fhir/resources/triggerdefinition.py +++ /dev/null @@ -1,277 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/TriggerDefinition -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import element, fhirtypes - - -class TriggerDefinition(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Defines an expected trigger for a module. - A description of a triggering event. Triggering events can be named events, - data events, or periodic, as determined by the type element. - """ - - resource_type = Field("TriggerDefinition", const=True) - - condition: fhirtypes.ExpressionType = Field( - None, - alias="condition", - title="Whether the event triggers (boolean expression)", - description=( - "A boolean-valued expression that is evaluated in the context of the " - "container of the trigger definition and returns whether or not the " - "trigger fires." - ), - # if property is element of this resource. - element_property=True, - ) - - data: typing.List[fhirtypes.DataRequirementType] = Field( - None, - alias="data", - title="Triggering data of the event (multiple = 'and')", - description=( - "The triggering data of the event (if this is a data trigger). If more " - "than one data is requirement is specified, then all the data " - "requirements must be true." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name or URI that identifies the event", - description=( - "A formal name for the event. This may be an absolute URI that " - "identifies the event formally (e.g. from a trigger registry), or a " - "simple relative URI that identifies the event in a local context." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - timingDate: fhirtypes.Date = Field( - None, - alias="timingDate", - title="Timing of the event", - description="The timing of the event (if this is a periodic trigger).", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - timingDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timingDate", title="Extension field for ``timingDate``." - ) - - timingDateTime: fhirtypes.DateTime = Field( - None, - alias="timingDateTime", - title="Timing of the event", - description="The timing of the event (if this is a periodic trigger).", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - timingDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timingDateTime", title="Extension field for ``timingDateTime``." - ) - - timingReference: fhirtypes.ReferenceType = Field( - None, - alias="timingReference", - title="Timing of the event", - description="The timing of the event (if this is a periodic trigger).", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Schedule"], - ) - - timingTiming: fhirtypes.TimingType = Field( - None, - alias="timingTiming", - title="Timing of the event", - description="The timing of the event (if this is a periodic trigger).", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e timing[x] - one_of_many="timing", - one_of_many_required=False, - ) - - type: fhirtypes.Code = Field( - None, - alias="type", - title=( - "named-event | periodic | data-changed | data-added | data-modified | " - "data-removed | data-accessed | data-access-ended" - ), - description="The type of triggering event.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "named-event", - "periodic", - "data-changed", - "data-added", - "data-modified", - "data-removed", - "data-accessed", - "data-access-ended", - ], - ) - type__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_type", title="Extension field for ``type``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``TriggerDefinition`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "type", - "name", - "timingTiming", - "timingReference", - "timingDate", - "timingDateTime", - "data", - "condition", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1951( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("type", "type__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1951( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "timing": [ - "timingDate", - "timingDateTime", - "timingReference", - "timingTiming", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/usagecontext.py b/fhir/resources/usagecontext.py deleted file mode 100644 index 81a844eb..00000000 --- a/fhir/resources/usagecontext.py +++ /dev/null @@ -1,171 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/UsageContext -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator - -from . import element, fhirtypes - - -class UsageContext(element.Element): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Describes the context of use for a conformance or knowledge resource. - Specifies clinical/business/etc. metadata that can be used to retrieve, - index and/or categorize an artifact. This metadata can either be specific - to the applicable population (e.g., age category, DRG) or the specific - context of care (e.g., venue, care setting, provider of care). - """ - - resource_type = Field("UsageContext", const=True) - - code: fhirtypes.CodingType = Field( - ..., - alias="code", - title="Type of context being specified", - description=( - "A code that identifies the type of context being specified by this " - "usage context." - ), - # if property is element of this resource. - element_property=True, - ) - - valueCodeableConcept: fhirtypes.CodeableConceptType = Field( - None, - alias="valueCodeableConcept", - title="Value that defines the context", - description=( - "A value that defines the context specified in this context of use. The" - " interpretation of the value is defined by the code." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueQuantity: fhirtypes.QuantityType = Field( - None, - alias="valueQuantity", - title="Value that defines the context", - description=( - "A value that defines the context specified in this context of use. The" - " interpretation of the value is defined by the code." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueRange: fhirtypes.RangeType = Field( - None, - alias="valueRange", - title="Value that defines the context", - description=( - "A value that defines the context specified in this context of use. The" - " interpretation of the value is defined by the code." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - ) - - valueReference: fhirtypes.ReferenceType = Field( - None, - alias="valueReference", - title="Value that defines the context", - description=( - "A value that defines the context specified in this context of use. The" - " interpretation of the value is defined by the code." - ), - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=[ - "PlanDefinition", - "ResearchStudy", - "InsurancePlan", - "HealthcareService", - "Group", - "Location", - "Organization", - ], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``UsageContext`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "code", - "valueCodeableConcept", - "valueQuantity", - "valueRange", - "valueReference", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_1443( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueCodeableConcept", - "valueQuantity", - "valueRange", - "valueReference", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/valueset.py b/fhir/resources/valueset.py deleted file mode 100644 index 8e24ba88..00000000 --- a/fhir/resources/valueset.py +++ /dev/null @@ -1,1584 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/ValueSet -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class ValueSet(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A set of codes drawn from one or more code systems. - A ValueSet resource instance specifies a set of codes drawn from one or - more code systems, intended for use in a particular context. Value sets - link between [CodeSystem](codesystem.html) definitions and their use in - [coded elements](terminologies.html). - """ - - resource_type = Field("ValueSet", const=True) - - compose: fhirtypes.ValueSetComposeType = Field( - None, - alias="compose", - title="Content logical definition of the value set (CLD)", - description=( - "A set of criteria that define the contents of the value set by " - "including or excluding codes selected from the specified code " - "system(s) that the value set draws from. This is also known as the " - "Content Logical Definition (CLD)." - ), - # if property is element of this resource. - element_property=True, - ) - - contact: typing.List[fhirtypes.ContactDetailType] = Field( - None, - alias="contact", - title="Contact details for the publisher", - description=( - "Contact details to assist a user in finding and communicating with the" - " publisher." - ), - # if property is element of this resource. - element_property=True, - ) - - copyright: fhirtypes.Markdown = Field( - None, - alias="copyright", - title="Use and/or publishing restrictions", - description=( - "A copyright statement relating to the value set and/or its contents. " - "Copyright statements are generally legal restrictions on the use and " - "publishing of the value set." - ), - # if property is element of this resource. - element_property=True, - ) - copyright__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_copyright", title="Extension field for ``copyright``." - ) - - date: fhirtypes.DateTime = Field( - None, - alias="date", - title="Date last changed", - description=( - "The date (and optionally time) when the value set was created or " - "revised (e.g. the 'content logical definition')." - ), - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - description: fhirtypes.Markdown = Field( - None, - alias="description", - title="Natural language description of the value set", - description=( - "A free text natural language description of the value set from a " - "consumer's perspective. The textual description specifies the span of " - "meanings for concepts to be included within the Value Set Expansion, " - "and also may specify the intended use and limitations of the Value " - "Set." - ), - # if property is element of this resource. - element_property=True, - ) - description__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_description", title="Extension field for ``description``." - ) - - expansion: fhirtypes.ValueSetExpansionType = Field( - None, - alias="expansion", - title='Used when the value set is "expanded"', - description=( - 'A value set can also be "expanded", where the value set is turned into' - " a simple collection of enumerated codes. This element holds the " - "expansion, if it has been performed." - ), - # if property is element of this resource. - element_property=True, - ) - - experimental: bool = Field( - None, - alias="experimental", - title="For testing purposes, not real usage", - description=( - "A Boolean value to indicate that this value set is authored for " - "testing purposes (or education/evaluation/marketing) and is not " - "intended to be used for genuine usage." - ), - # if property is element of this resource. - element_property=True, - ) - experimental__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_experimental", title="Extension field for ``experimental``." - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Additional identifier for the value set (business identifier)", - description=( - "A formal identifier that is used to identify this value set when it is" - " represented in other formats, or referenced in a specification, " - "model, design or an instance." - ), - # if property is element of this resource. - element_property=True, - ) - - immutable: bool = Field( - None, - alias="immutable", - title=( - "Indicates whether or not any change to the content logical definition " - "may occur" - ), - description=( - "If this is set to 'true', then no new versions of the content logical " - "definition can be created. Note: Other metadata might still change." - ), - # if property is element of this resource. - element_property=True, - ) - immutable__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_immutable", title="Extension field for ``immutable``." - ) - - jurisdiction: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="jurisdiction", - title="Intended jurisdiction for value set (if applicable)", - description=( - "A legal or geographic region in which the value set is intended to be " - "used." - ), - # if property is element of this resource. - element_property=True, - ) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name for this value set (computer friendly)", - description=( - "A natural language name identifying the value set. This name should be" - " usable as an identifier for the module by machine processing " - "applications such as code generation." - ), - # if property is element of this resource. - element_property=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - publisher: fhirtypes.String = Field( - None, - alias="publisher", - title="Name of the publisher (organization or individual)", - description=( - "The name of the organization or individual that published the value " - "set." - ), - # if property is element of this resource. - element_property=True, - ) - publisher__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_publisher", title="Extension field for ``publisher``." - ) - - purpose: fhirtypes.Markdown = Field( - None, - alias="purpose", - title="Why this value set is defined", - description=( - "Explanation of why this value set is needed and why it has been " - "designed as it has." - ), - # if property is element of this resource. - element_property=True, - ) - purpose__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_purpose", title="Extension field for ``purpose``." - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="draft | active | retired | unknown", - description=( - "The status of this value set. Enables tracking the life-cycle of the " - "content. The status of the value set applies to the value set " - "definition (ValueSet.compose) and the associated ValueSet metadata. " - "Expansions do not have a state." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["draft", "active", "retired", "unknown"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - title: fhirtypes.String = Field( - None, - alias="title", - title="Name for this value set (human friendly)", - description="A short, descriptive, user-friendly title for the value set.", - # if property is element of this resource. - element_property=True, - ) - title__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_title", title="Extension field for ``title``." - ) - - url: fhirtypes.Uri = Field( - None, - alias="url", - title=( - "Canonical identifier for this value set, represented as a URI " - "(globally unique)" - ), - description=( - "An absolute URI that is used to identify this value set when it is " - "referenced in a specification, model, design or an instance; also " - "called its canonical identifier. This SHOULD be globally unique and " - "SHOULD be a literal address at which at which an authoritative " - "instance of this value set is (or will be) published. This URL can be " - "the target of a canonical reference. It SHALL remain the same when the" - " value set is stored on different servers." - ), - # if property is element of this resource. - element_property=True, - ) - url__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_url", title="Extension field for ``url``." - ) - - useContext: typing.List[fhirtypes.UsageContextType] = Field( - None, - alias="useContext", - title="The context that the content is intended to support", - description=( - "The content was developed with a focus and intent of supporting the " - "contexts that are listed. These contexts may be general categories " - "(gender, age, ...) or may be references to specific programs " - "(insurance plans, studies, ...) and may be used to assist with " - "indexing and searching for appropriate value set instances." - ), - # if property is element of this resource. - element_property=True, - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Business version of the value set", - description=( - "The identifier that is used to identify this version of the value set " - "when it is referenced in a specification, model, design or instance. " - "This is an arbitrary value managed by the value set author and is not " - "expected to be globally unique. For example, it might be a timestamp " - "(e.g. yyyymmdd) if a managed version is not available. There is also " - "no expectation that versions can be placed in a lexicographical " - "sequence." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ValueSet`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "url", - "identifier", - "version", - "name", - "title", - "status", - "experimental", - "date", - "publisher", - "contact", - "description", - "useContext", - "jurisdiction", - "immutable", - "purpose", - "copyright", - "compose", - "expansion", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1011( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ValueSetCompose(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Content logical definition of the value set (CLD). - A set of criteria that define the contents of the value set by including or - excluding codes selected from the specified code system(s) that the value - set draws from. This is also known as the Content Logical Definition (CLD). - """ - - resource_type = Field("ValueSetCompose", const=True) - - exclude: typing.List[fhirtypes.ValueSetComposeIncludeType] = Field( - None, - alias="exclude", - title="Explicitly exclude codes from a code system or other value sets", - description=( - "Exclude one or more codes from the value set based on code system " - "filters and/or other value sets." - ), - # if property is element of this resource. - element_property=True, - ) - - inactive: bool = Field( - None, - alias="inactive", - title="Whether inactive codes are in the value set", - description=( - "Whether inactive codes - codes that are not approved for current use -" - " are in the value set. If inactive = true, inactive codes are to be " - "included in the expansion, if inactive = false, the inactive codes " - "will not be included in the expansion. If absent, the behavior is " - "determined by the implementation, or by the applicable $expand " - "parameters (but generally, inactive codes would be expected to be " - "included)." - ), - # if property is element of this resource. - element_property=True, - ) - inactive__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_inactive", title="Extension field for ``inactive``." - ) - - include: typing.List[fhirtypes.ValueSetComposeIncludeType] = Field( - ..., - alias="include", - title="Include one or more codes from a code system or other value set(s)", - description=None, - # if property is element of this resource. - element_property=True, - ) - - lockedDate: fhirtypes.Date = Field( - None, - alias="lockedDate", - title="Fixed date for references with no specified version (transitive)", - description=( - "The Locked Date is the effective date that is used to determine the " - "version of all referenced Code Systems and Value Set Definitions " - "included in the compose that are not already tied to a specific " - "version." - ), - # if property is element of this resource. - element_property=True, - ) - lockedDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lockedDate", title="Extension field for ``lockedDate``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ValueSetCompose`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "lockedDate", - "inactive", - "include", - "exclude", - ] - - -class ValueSetComposeInclude(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Include one or more codes from a code system or other value set(s). - """ - - resource_type = Field("ValueSetComposeInclude", const=True) - - concept: typing.List[fhirtypes.ValueSetComposeIncludeConceptType] = Field( - None, - alias="concept", - title="A concept defined in the system", - description="Specifies a concept to be included or excluded.", - # if property is element of this resource. - element_property=True, - ) - - filter: typing.List[fhirtypes.ValueSetComposeIncludeFilterType] = Field( - None, - alias="filter", - title="Select codes/concepts by their properties (including relationships)", - description=( - "Select concepts by specify a matching criterion based on the " - "properties (including relationships) defined by the system, or on " - "filters defined by the system. If multiple filters are specified, they" - " SHALL all be true." - ), - # if property is element of this resource. - element_property=True, - ) - - system: fhirtypes.Uri = Field( - None, - alias="system", - title="The system the codes come from", - description=( - "An absolute URI which is the code system from which the selected codes" - " come from." - ), - # if property is element of this resource. - element_property=True, - ) - system__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_system", title="Extension field for ``system``." - ) - - valueSet: typing.List[fhirtypes.Canonical] = Field( - None, - alias="valueSet", - title="Select the contents included in this value set", - description=( - "Selects the concepts found in this value set (based on its value set " - "definition). This is an absolute URI that is a reference to " - "ValueSet.url. If multiple value sets are specified this includes the " - "union of the contents of all of the referenced value sets." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["ValueSet"], - ) - valueSet__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field(None, alias="_valueSet", title="Extension field for ``valueSet``.") - - version: fhirtypes.String = Field( - None, - alias="version", - title="Specific version of the code system referred to", - description=( - "The version of the code system that the codes are selected from, or " - "the special version '*' for all versions." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ValueSetComposeInclude`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "system", - "version", - "concept", - "filter", - "valueSet", - ] - - -class ValueSetComposeIncludeConcept(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - A concept defined in the system. - Specifies a concept to be included or excluded. - """ - - resource_type = Field("ValueSetComposeIncludeConcept", const=True) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Code or expression from system", - description="Specifies a code for the concept to be included or excluded.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - designation: typing.List[ - fhirtypes.ValueSetComposeIncludeConceptDesignationType - ] = Field( - None, - alias="designation", - title="Additional representations for this concept", - description=( - "Additional representations for this concept when used in this value " - "set - other languages, aliases, specialized purposes, used for " - "particular purposes, etc." - ), - # if property is element of this resource. - element_property=True, - ) - - display: fhirtypes.String = Field( - None, - alias="display", - title="Text to display for this code for this value set in this valueset", - description=( - "The text to display to the user for this concept in the context of " - "this valueset. If no display is provided, then applications using the " - "value set use the display specified for the code by the system." - ), - # if property is element of this resource. - element_property=True, - ) - display__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_display", title="Extension field for ``display``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ValueSetComposeIncludeConcept`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "code", - "display", - "designation", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3161( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("code", "code__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ValueSetComposeIncludeConceptDesignation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Additional representations for this concept. - Additional representations for this concept when used in this value set - - other languages, aliases, specialized purposes, used for particular - purposes, etc. - """ - - resource_type = Field("ValueSetComposeIncludeConceptDesignation", const=True) - - language: fhirtypes.Code = Field( - None, - alias="language", - title="Human language of the designation", - description="The language this designation is defined for.", - # if property is element of this resource. - element_property=True, - ) - language__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_language", title="Extension field for ``language``." - ) - - use: fhirtypes.CodingType = Field( - None, - alias="use", - title="Types of uses of designations", - description="A code that represents types of uses of designations.", - # if property is element of this resource. - element_property=True, - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="The text value for this designation", - description=None, - # if property is element of this resource. - element_property=True, - element_required=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ValueSetComposeIncludeConceptDesignation`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "language", "use", "value"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4296( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("value", "value__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ValueSetComposeIncludeFilter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Select codes/concepts by their properties (including relationships). - Select concepts by specify a matching criterion based on the properties - (including relationships) defined by the system, or on filters defined by - the system. If multiple filters are specified, they SHALL all be true. - """ - - resource_type = Field("ValueSetComposeIncludeFilter", const=True) - - op: fhirtypes.Code = Field( - None, - alias="op", - title=( - "= | is-a | descendent-of | is-not-a | regex | in | not-in | " - "generalizes | exists" - ), - description="The kind of operation to perform as a part of the filter criteria.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "=", - "is-a", - "descendent-of", - "is-not-a", - "regex", - "in", - "not-in", - "generalizes", - "exists", - ], - ) - op__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_op", title="Extension field for ``op``." - ) - - property: fhirtypes.Code = Field( - None, - alias="property", - title="A property/filter defined by the code system", - description=( - "A code that identifies a property or a filter defined in the code " - "system." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - property__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_property", title="Extension field for ``property``." - ) - - value: fhirtypes.String = Field( - None, - alias="value", - title="Code from the system, or regex criteria, or boolean value for exists", - description=( - "The match value may be either a code defined by the system, or a " - "string value, which is a regex match on the literal string of the " - "property value (if the filter represents a property defined in " - "CodeSystem) or of the system filter value (if the filter represents a " - "filter defined in CodeSystem) when the operation is 'regex', or one of" - " the values (true and false), when the operation is 'exists'." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - value__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_value", title="Extension field for ``value``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ValueSetComposeIncludeFilter`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "property", "op", "value"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3057( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("op", "op__ext"), - ("property", "property__ext"), - ("value", "value__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ValueSetExpansion(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Used when the value set is "expanded". - A value set can also be "expanded", where the value set is turned into a - simple collection of enumerated codes. This element holds the expansion, if - it has been performed. - """ - - resource_type = Field("ValueSetExpansion", const=True) - - contains: typing.List[fhirtypes.ValueSetExpansionContainsType] = Field( - None, - alias="contains", - title="Codes in the value set", - description="The codes that are contained in the value set expansion.", - # if property is element of this resource. - element_property=True, - ) - - identifier: fhirtypes.Uri = Field( - None, - alias="identifier", - title="Identifies the value set expansion (business identifier)", - description=( - "An identifier that uniquely identifies this expansion of the valueset," - " based on a unique combination of the provided parameters, the system " - "default parameters, and the underlying system code system versions " - "etc. Systems may re-use the same identifier as long as those factors " - "remain the same, and the expansion is the same, but are not required " - "to do so. This is a business identifier." - ), - # if property is element of this resource. - element_property=True, - ) - identifier__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_identifier", title="Extension field for ``identifier``." - ) - - offset: fhirtypes.Integer = Field( - None, - alias="offset", - title="Offset at which this resource starts", - description=( - "If paging is being used, the offset at which this resource starts. " - "I.e. this resource is a partial view into the expansion. If paging is " - "not being used, this element SHALL NOT be present." - ), - # if property is element of this resource. - element_property=True, - ) - offset__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_offset", title="Extension field for ``offset``." - ) - - parameter: typing.List[fhirtypes.ValueSetExpansionParameterType] = Field( - None, - alias="parameter", - title="Parameter that controlled the expansion process", - description=( - "A parameter that controlled the expansion process. These parameters " - "may be used by users of expanded value sets to check whether the " - "expansion is suitable for a particular purpose, or to pick the correct" - " expansion." - ), - # if property is element of this resource. - element_property=True, - ) - - timestamp: fhirtypes.DateTime = Field( - None, - alias="timestamp", - title="Time ValueSet expansion happened", - description="The time at which the expansion was produced by the expanding system.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - timestamp__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_timestamp", title="Extension field for ``timestamp``." - ) - - total: fhirtypes.Integer = Field( - None, - alias="total", - title="Total number of codes in the expansion", - description=( - "The total number of concepts in the expansion. If the number of " - "concept nodes in this resource is less than the stated number, then " - "the server can return more using the offset parameter." - ), - # if property is element of this resource. - element_property=True, - ) - total__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_total", title="Extension field for ``total``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ValueSetExpansion`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "identifier", - "timestamp", - "total", - "offset", - "parameter", - "contains", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_1954( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("timestamp", "timestamp__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class ValueSetExpansionContains(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Codes in the value set. - The codes that are contained in the value set expansion. - """ - - resource_type = Field("ValueSetExpansionContains", const=True) - - abstract: bool = Field( - None, - alias="abstract", - title="If user cannot select this entry", - description=( - "If true, this entry is included in the expansion for navigational " - "purposes, and the user cannot select the code directly as a proper " - "value." - ), - # if property is element of this resource. - element_property=True, - ) - abstract__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_abstract", title="Extension field for ``abstract``." - ) - - code: fhirtypes.Code = Field( - None, - alias="code", - title="Code - if blank, this is not a selectable code", - description=( - "The code for this item in the expansion hierarchy. If this code is " - "missing the entry in the hierarchy is a place holder (abstract) and " - "does not represent a valid code in the value set." - ), - # if property is element of this resource. - element_property=True, - ) - code__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_code", title="Extension field for ``code``." - ) - - contains: typing.List[fhirtypes.ValueSetExpansionContainsType] = Field( - None, - alias="contains", - title="Codes contained under this entry", - description="Other codes and entries contained under this entry in the hierarchy.", - # if property is element of this resource. - element_property=True, - ) - - designation: typing.List[ - fhirtypes.ValueSetComposeIncludeConceptDesignationType - ] = Field( - None, - alias="designation", - title="Additional representations for this item", - description=( - "Additional representations for this item - other languages, aliases, " - "specialized purposes, used for particular purposes, etc. These are " - "relevant when the conditions of the expansion do not fix to a single " - "correct representation." - ), - # if property is element of this resource. - element_property=True, - ) - - display: fhirtypes.String = Field( - None, - alias="display", - title="User display for the concept", - description="The recommended display for this item in the expansion.", - # if property is element of this resource. - element_property=True, - ) - display__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_display", title="Extension field for ``display``." - ) - - inactive: bool = Field( - None, - alias="inactive", - title="If concept is inactive in the code system", - description=( - "If the concept is inactive in the code system that defines it. " - "Inactive codes are those that are no longer to be used, but are " - "maintained by the code system for understanding legacy data. It might " - "not be known or specified whether an concept is inactive (and it may " - "depend on the context of use)." - ), - # if property is element of this resource. - element_property=True, - ) - inactive__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_inactive", title="Extension field for ``inactive``." - ) - - system: fhirtypes.Uri = Field( - None, - alias="system", - title="System value for the code", - description=( - "An absolute URI which is the code system in which the code for this " - "item in the expansion is defined." - ), - # if property is element of this resource. - element_property=True, - ) - system__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_system", title="Extension field for ``system``." - ) - - version: fhirtypes.String = Field( - None, - alias="version", - title="Version in which this code/display is defined", - description=( - "The version of the code system from this code was taken. Note that a " - "well-maintained code system does not need the version reported, " - "because the meaning of codes is consistent across versions. However " - "this cannot consistently be assured, and when the meaning is not " - "guaranteed to be consistent, the version SHOULD be exchanged." - ), - # if property is element of this resource. - element_property=True, - ) - version__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_version", title="Extension field for ``version``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ValueSetExpansionContains`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "system", - "abstract", - "inactive", - "version", - "code", - "display", - "designation", - "contains", - ] - - -class ValueSetExpansionParameter(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Parameter that controlled the expansion process. - A parameter that controlled the expansion process. These parameters may be - used by users of expanded value sets to check whether the expansion is - suitable for a particular purpose, or to pick the correct expansion. - """ - - resource_type = Field("ValueSetExpansionParameter", const=True) - - name: fhirtypes.String = Field( - None, - alias="name", - title="Name as assigned by the client or server", - description=( - "Name of the input parameter to the $expand operation; may be a server-" - "assigned name for additional default or other server-supplied " - "parameters used to control the expansion process." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - ) - name__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_name", title="Extension field for ``name``." - ) - - valueBoolean: bool = Field( - None, - alias="valueBoolean", - title="Value of the named parameter", - description="The value of the parameter.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueBoolean__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueBoolean", title="Extension field for ``valueBoolean``." - ) - - valueCode: fhirtypes.Code = Field( - None, - alias="valueCode", - title="Value of the named parameter", - description="The value of the parameter.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueCode__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueCode", title="Extension field for ``valueCode``." - ) - - valueDateTime: fhirtypes.DateTime = Field( - None, - alias="valueDateTime", - title="Value of the named parameter", - description="The value of the parameter.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueDateTime__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDateTime", title="Extension field for ``valueDateTime``." - ) - - valueDecimal: fhirtypes.Decimal = Field( - None, - alias="valueDecimal", - title="Value of the named parameter", - description="The value of the parameter.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueDecimal__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueDecimal", title="Extension field for ``valueDecimal``." - ) - - valueInteger: fhirtypes.Integer = Field( - None, - alias="valueInteger", - title="Value of the named parameter", - description="The value of the parameter.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueInteger__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueInteger", title="Extension field for ``valueInteger``." - ) - - valueString: fhirtypes.String = Field( - None, - alias="valueString", - title="Value of the named parameter", - description="The value of the parameter.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueString__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueString", title="Extension field for ``valueString``." - ) - - valueUri: fhirtypes.Uri = Field( - None, - alias="valueUri", - title="Value of the named parameter", - description="The value of the parameter.", - # if property is element of this resource. - element_property=True, - # Choice of Data Types. i.e value[x] - one_of_many="value", - one_of_many_required=False, - ) - valueUri__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_valueUri", title="Extension field for ``valueUri``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``ValueSetExpansionParameter`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "name", - "valueString", - "valueBoolean", - "valueInteger", - "valueDecimal", - "valueUri", - "valueCode", - "valueDateTime", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2887( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("name", "name__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - @root_validator(pre=True, allow_reuse=True) - def validate_one_of_many_2887( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/formats.html#choice - A few elements have a choice of more than one data type for their content. - All such elements have a name that takes the form nnn[x]. - The "nnn" part of the name is constant, and the "[x]" is replaced with - the title-cased name of the type that is actually used. - The table view shows each of these names explicitly. - - Elements that have a choice of data type cannot repeat - they must have a - maximum cardinality of 1. When constructing an instance of an element with a - choice of types, the authoring system must create a single element with a - data type chosen from among the list of permitted data types. - """ - one_of_many_fields = { - "value": [ - "valueBoolean", - "valueCode", - "valueDateTime", - "valueDecimal", - "valueInteger", - "valueString", - "valueUri", - ] - } - for prefix, fields in one_of_many_fields.items(): - assert cls.__fields__[fields[0]].field_info.extra["one_of_many"] == prefix - required = ( - cls.__fields__[fields[0]].field_info.extra["one_of_many_required"] - is True - ) - found = False - for field in fields: - if field in values and values[field] is not None: - if found is True: - raise ValueError( - "Any of one field value is expected from " - f"this list {fields}, but got multiple!" - ) - else: - found = True - if required is True and found is False: - raise ValueError(f"Expect any of field value from this list {fields}.") - - return values diff --git a/fhir/resources/verificationresult.py b/fhir/resources/verificationresult.py deleted file mode 100644 index f2772b76..00000000 --- a/fhir/resources/verificationresult.py +++ /dev/null @@ -1,600 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/VerificationResult -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class VerificationResult(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Describes validation requirements, source(s), status and dates for one or - more elements. - """ - - resource_type = Field("VerificationResult", const=True) - - attestation: fhirtypes.VerificationResultAttestationType = Field( - None, - alias="attestation", - title="Information about the entity attesting to information", - description=None, - # if property is element of this resource. - element_property=True, - ) - - failureAction: fhirtypes.CodeableConceptType = Field( - None, - alias="failureAction", - title="fatal | warn | rec-only | none", - description="The result if validation fails (fatal; warning; record only; none).", - # if property is element of this resource. - element_property=True, - ) - - frequency: fhirtypes.TimingType = Field( - None, - alias="frequency", - title="Frequency of revalidation", - description=None, - # if property is element of this resource. - element_property=True, - ) - - lastPerformed: fhirtypes.DateTime = Field( - None, - alias="lastPerformed", - title=( - "The date/time validation was last completed (including failed " - "validations)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - lastPerformed__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_lastPerformed", title="Extension field for ``lastPerformed``." - ) - - need: fhirtypes.CodeableConceptType = Field( - None, - alias="need", - title="none | initial | periodic", - description=( - "The frequency with which the target must be validated (none; initial; " - "periodic)." - ), - # if property is element of this resource. - element_property=True, - ) - - nextScheduled: fhirtypes.Date = Field( - None, - alias="nextScheduled", - title="The date when target is next validated, if appropriate", - description=None, - # if property is element of this resource. - element_property=True, - ) - nextScheduled__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_nextScheduled", title="Extension field for ``nextScheduled``." - ) - - primarySource: typing.List[fhirtypes.VerificationResultPrimarySourceType] = Field( - None, - alias="primarySource", - title="Information about the primary source(s) involved in validation", - description=None, - # if property is element of this resource. - element_property=True, - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title=( - "attested | validated | in-process | req-revalid | val-fail | reval-" "fail" - ), - description=( - "The validation status of the target (attested; validated; in process; " - "requires revalidation; validation failed; revalidation failed)." - ), - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=[ - "attested", - "validated", - "in-process", - "req-revalid", - "val-fail", - "reval-fail", - ], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - statusDate: fhirtypes.DateTime = Field( - None, - alias="statusDate", - title="When the validation status was updated", - description=None, - # if property is element of this resource. - element_property=True, - ) - statusDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_statusDate", title="Extension field for ``statusDate``." - ) - - target: typing.List[fhirtypes.ReferenceType] = Field( - None, - alias="target", - title="A resource that was validated", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Resource"], - ) - - targetLocation: typing.List[typing.Optional[fhirtypes.String]] = Field( - None, - alias="targetLocation", - title="The fhirpath location(s) within the resource that was validated", - description=None, - # if property is element of this resource. - element_property=True, - ) - targetLocation__ext: typing.List[ - typing.Union[fhirtypes.FHIRPrimitiveExtensionType, None] - ] = Field( - None, alias="_targetLocation", title="Extension field for ``targetLocation``." - ) - - validationProcess: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="validationProcess", - title=( - "The primary process by which the target is validated (edit check; " - "value set; primary source; multiple sources; standalone; in context)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - validationType: fhirtypes.CodeableConceptType = Field( - None, - alias="validationType", - title="nothing | primary | multiple", - description=( - "What the target is validated against (nothing; primary source; " - "multiple sources)." - ), - # if property is element of this resource. - element_property=True, - ) - - validator: typing.List[fhirtypes.VerificationResultValidatorType] = Field( - None, - alias="validator", - title="Information about the entity validating information", - description=None, - # if property is element of this resource. - element_property=True, - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``VerificationResult`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "target", - "targetLocation", - "need", - "status", - "statusDate", - "validationType", - "validationProcess", - "frequency", - "lastPerformed", - "nextScheduled", - "failureAction", - "primarySource", - "attestation", - "validator", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2092( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("status", "status__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class VerificationResultAttestation(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about the entity attesting to information. - """ - - resource_type = Field("VerificationResultAttestation", const=True) - - communicationMethod: fhirtypes.CodeableConceptType = Field( - None, - alias="communicationMethod", - title="The method by which attested information was submitted/retrieved", - description=( - "The method by which attested information was submitted/retrieved " - "(manual; API; Push)." - ), - # if property is element of this resource. - element_property=True, - ) - - date: fhirtypes.Date = Field( - None, - alias="date", - title="The date the information was attested to", - description=None, - # if property is element of this resource. - element_property=True, - ) - date__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_date", title="Extension field for ``date``." - ) - - onBehalfOf: fhirtypes.ReferenceType = Field( - None, - alias="onBehalfOf", - title=( - "When the who is asserting on behalf of another (organization or " - "individual)" - ), - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization", "Practitioner", "PractitionerRole"], - ) - - proxyIdentityCertificate: fhirtypes.String = Field( - None, - alias="proxyIdentityCertificate", - title=( - "A digital identity certificate associated with the proxy entity " - "submitting attested information on behalf of the attestation source" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - proxyIdentityCertificate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_proxyIdentityCertificate", - title="Extension field for ``proxyIdentityCertificate``.", - ) - - proxySignature: fhirtypes.SignatureType = Field( - None, - alias="proxySignature", - title="Proxy signature", - description=( - "Signed assertion by the proxy entity indicating that they have the " - "right to submit attested information on behalf of the attestation " - "source." - ), - # if property is element of this resource. - element_property=True, - ) - - sourceIdentityCertificate: fhirtypes.String = Field( - None, - alias="sourceIdentityCertificate", - title="A digital identity certificate associated with the attestation source", - description=None, - # if property is element of this resource. - element_property=True, - ) - sourceIdentityCertificate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_sourceIdentityCertificate", - title="Extension field for ``sourceIdentityCertificate``.", - ) - - sourceSignature: fhirtypes.SignatureType = Field( - None, - alias="sourceSignature", - title="Attester signature", - description=( - "Signed assertion by the attestation source that they have attested to " - "the information." - ), - # if property is element of this resource. - element_property=True, - ) - - who: fhirtypes.ReferenceType = Field( - None, - alias="who", - title="The individual or organization attesting to information", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole", "Organization"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``VerificationResultAttestation`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "who", - "onBehalfOf", - "communicationMethod", - "date", - "sourceIdentityCertificate", - "proxyIdentityCertificate", - "proxySignature", - "sourceSignature", - ] - - -class VerificationResultPrimarySource(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about the primary source(s) involved in validation. - """ - - resource_type = Field("VerificationResultPrimarySource", const=True) - - canPushUpdates: fhirtypes.CodeableConceptType = Field( - None, - alias="canPushUpdates", - title="yes | no | undetermined", - description=( - "Ability of the primary source to push updates/alerts (yes; no; " - "undetermined)." - ), - # if property is element of this resource. - element_property=True, - ) - - communicationMethod: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="communicationMethod", - title="Method for exchanging information with the primary source", - description="Method for communicating with the primary source (manual; API; Push).", - # if property is element of this resource. - element_property=True, - ) - - pushTypeAvailable: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="pushTypeAvailable", - title="specific | any | source", - description=( - "Type of alerts/updates the primary source can send (specific requested" - " changes; any changes; as defined by source)." - ), - # if property is element of this resource. - element_property=True, - ) - - type: typing.List[fhirtypes.CodeableConceptType] = Field( - None, - alias="type", - title=( - "Type of primary source (License Board; Primary Education; Continuing " - "Education; Postal Service; Relationship owner; Registration Authority;" - " legal source; issuing source; authoritative source)" - ), - description=None, - # if property is element of this resource. - element_property=True, - ) - - validationDate: fhirtypes.DateTime = Field( - None, - alias="validationDate", - title="When the target was validated against the primary source", - description=None, - # if property is element of this resource. - element_property=True, - ) - validationDate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_validationDate", title="Extension field for ``validationDate``." - ) - - validationStatus: fhirtypes.CodeableConceptType = Field( - None, - alias="validationStatus", - title="successful | failed | unknown", - description=( - "Status of the validation of the target against the primary source " - "(successful; failed; unknown)." - ), - # if property is element of this resource. - element_property=True, - ) - - who: fhirtypes.ReferenceType = Field( - None, - alias="who", - title="Reference to the primary source", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization", "Practitioner", "PractitionerRole"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``VerificationResultPrimarySource`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "who", - "type", - "communicationMethod", - "validationStatus", - "validationDate", - "canPushUpdates", - "pushTypeAvailable", - ] - - -class VerificationResultValidator(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Information about the entity validating information. - """ - - resource_type = Field("VerificationResultValidator", const=True) - - attestationSignature: fhirtypes.SignatureType = Field( - None, - alias="attestationSignature", - title="Validator signature", - description=( - "Signed assertion by the validator that they have validated the " - "information." - ), - # if property is element of this resource. - element_property=True, - ) - - identityCertificate: fhirtypes.String = Field( - None, - alias="identityCertificate", - title="A digital identity certificate associated with the validator", - description=None, - # if property is element of this resource. - element_property=True, - ) - identityCertificate__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, - alias="_identityCertificate", - title="Extension field for ``identityCertificate``.", - ) - - organization: fhirtypes.ReferenceType = Field( - ..., - alias="organization", - title="Reference to the organization validating information", - description=None, - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Organization"], - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``VerificationResultValidator`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "organization", - "identityCertificate", - "attestationSignature", - ] diff --git a/fhir/resources/visionprescription.py b/fhir/resources/visionprescription.py deleted file mode 100644 index 9ef20590..00000000 --- a/fhir/resources/visionprescription.py +++ /dev/null @@ -1,596 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Profile: http://hl7.org/fhir/StructureDefinition/VisionPrescription -Release: R4 -Version: 4.0.1 -Build ID: 9346c8cc45 -Last updated: 2019-11-01T09:29:23.356+11:00 -""" -import typing - -from pydantic import Field, root_validator -from pydantic.error_wrappers import ErrorWrapper, ValidationError -from pydantic.errors import MissingError, NoneIsNotAllowedError - -from . import backboneelement, domainresource, fhirtypes - - -class VisionPrescription(domainresource.DomainResource): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Prescription for vision correction products for a patient. - An authorization for the provision of glasses and/or contact lenses to a - patient. - """ - - resource_type = Field("VisionPrescription", const=True) - - created: fhirtypes.DateTime = Field( - None, - alias="created", - title="Response creation date", - description="The date this resource was created.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - created__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_created", title="Extension field for ``created``." - ) - - dateWritten: fhirtypes.DateTime = Field( - None, - alias="dateWritten", - title="When prescription was authorized", - description="The date (and perhaps time) when the prescription was written.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - dateWritten__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_dateWritten", title="Extension field for ``dateWritten``." - ) - - encounter: fhirtypes.ReferenceType = Field( - None, - alias="encounter", - title="Created during encounter / admission / stay", - description=( - "A reference to a resource that identifies the particular occurrence of" - " contact between patient and health care provider during which the " - "prescription was issued." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Encounter"], - ) - - identifier: typing.List[fhirtypes.IdentifierType] = Field( - None, - alias="identifier", - title="Business Identifier for vision prescription", - description="A unique identifier assigned to this vision prescription.", - # if property is element of this resource. - element_property=True, - ) - - lensSpecification: typing.List[ - fhirtypes.VisionPrescriptionLensSpecificationType - ] = Field( - ..., - alias="lensSpecification", - title="Vision lens authorization", - description=( - "Contain the details of the individual lens specifications and serves " - "as the authorization for the fullfillment by certified professionals." - ), - # if property is element of this resource. - element_property=True, - ) - - patient: fhirtypes.ReferenceType = Field( - ..., - alias="patient", - title="Who prescription is for", - description=( - "A resource reference to the person to whom the vision prescription " - "applies." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Patient"], - ) - - prescriber: fhirtypes.ReferenceType = Field( - ..., - alias="prescriber", - title="Who authorized the vision prescription", - description=( - "The healthcare professional responsible for authorizing the " - "prescription." - ), - # if property is element of this resource. - element_property=True, - # note: Listed Resource Type(s) should be allowed as Reference. - enum_reference_types=["Practitioner", "PractitionerRole"], - ) - - status: fhirtypes.Code = Field( - None, - alias="status", - title="active | cancelled | draft | entered-in-error", - description="The status of the resource instance.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["active", "cancelled", "draft", "entered-in-error"], - ) - status__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_status", title="Extension field for ``status``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``VisionPrescription`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "meta", - "implicitRules", - "language", - "text", - "contained", - "extension", - "modifierExtension", - "identifier", - "status", - "created", - "patient", - "encounter", - "dateWritten", - "prescriber", - "lensSpecification", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_2110( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [ - ("created", "created__ext"), - ("dateWritten", "dateWritten__ext"), - ("status", "status__ext"), - ] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class VisionPrescriptionLensSpecification(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Vision lens authorization. - Contain the details of the individual lens specifications and serves as - the authorization for the fullfillment by certified professionals. - """ - - resource_type = Field("VisionPrescriptionLensSpecification", const=True) - - add: fhirtypes.Decimal = Field( - None, - alias="add", - title="Added power for multifocal levels", - description=( - "Power adjustment for multifocal lenses measured in dioptres (0.25 " - "units)." - ), - # if property is element of this resource. - element_property=True, - ) - add__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_add", title="Extension field for ``add``." - ) - - axis: fhirtypes.Integer = Field( - None, - alias="axis", - title="Lens meridian which contain no power for astigmatism", - description="Adjustment for astigmatism measured in integer degrees.", - # if property is element of this resource. - element_property=True, - ) - axis__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_axis", title="Extension field for ``axis``." - ) - - backCurve: fhirtypes.Decimal = Field( - None, - alias="backCurve", - title="Contact lens back curvature", - description="Back curvature measured in millimetres.", - # if property is element of this resource. - element_property=True, - ) - backCurve__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_backCurve", title="Extension field for ``backCurve``." - ) - - brand: fhirtypes.String = Field( - None, - alias="brand", - title="Brand required", - description="Brand recommendations or restrictions.", - # if property is element of this resource. - element_property=True, - ) - brand__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_brand", title="Extension field for ``brand``." - ) - - color: fhirtypes.String = Field( - None, - alias="color", - title="Color required", - description="Special color or pattern.", - # if property is element of this resource. - element_property=True, - ) - color__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_color", title="Extension field for ``color``." - ) - - cylinder: fhirtypes.Decimal = Field( - None, - alias="cylinder", - title="Lens power for astigmatism", - description="Power adjustment for astigmatism measured in dioptres (0.25 units).", - # if property is element of this resource. - element_property=True, - ) - cylinder__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_cylinder", title="Extension field for ``cylinder``." - ) - - diameter: fhirtypes.Decimal = Field( - None, - alias="diameter", - title="Contact lens diameter", - description="Contact lens diameter measured in millimetres.", - # if property is element of this resource. - element_property=True, - ) - diameter__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_diameter", title="Extension field for ``diameter``." - ) - - duration: fhirtypes.QuantityType = Field( - None, - alias="duration", - title="Lens wear duration", - description="The recommended maximum wear period for the lens.", - # if property is element of this resource. - element_property=True, - ) - - eye: fhirtypes.Code = Field( - None, - alias="eye", - title="right | left", - description="The eye for which the lens specification applies.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["right", "left"], - ) - eye__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_eye", title="Extension field for ``eye``." - ) - - note: typing.List[fhirtypes.AnnotationType] = Field( - None, - alias="note", - title="Notes for coatings", - description="Notes for special requirements such as coatings and lens materials.", - # if property is element of this resource. - element_property=True, - ) - - power: fhirtypes.Decimal = Field( - None, - alias="power", - title="Contact lens power", - description="Contact lens power measured in dioptres (0.25 units).", - # if property is element of this resource. - element_property=True, - ) - power__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_power", title="Extension field for ``power``." - ) - - prism: typing.List[fhirtypes.VisionPrescriptionLensSpecificationPrismType] = Field( - None, - alias="prism", - title="Eye alignment compensation", - description="Allows for adjustment on two axis.", - # if property is element of this resource. - element_property=True, - ) - - product: fhirtypes.CodeableConceptType = Field( - ..., - alias="product", - title="Product to be supplied", - description=( - "Identifies the type of vision correction product which is required for" - " the patient." - ), - # if property is element of this resource. - element_property=True, - ) - - sphere: fhirtypes.Decimal = Field( - None, - alias="sphere", - title="Power of the lens", - description="Lens power measured in dioptres (0.25 units).", - # if property is element of this resource. - element_property=True, - ) - sphere__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_sphere", title="Extension field for ``sphere``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``VisionPrescriptionLensSpecification`` according specification, - with preserving original sequence order. - """ - return [ - "id", - "extension", - "modifierExtension", - "product", - "eye", - "sphere", - "cylinder", - "axis", - "prism", - "add", - "power", - "backCurve", - "diameter", - "duration", - "color", - "brand", - "note", - ] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_3857( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("eye", "eye__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values - - -class VisionPrescriptionLensSpecificationPrism(backboneelement.BackboneElement): - """Disclaimer: Any field name ends with ``__ext`` doesn't part of - Resource StructureDefinition, instead used to enable Extensibility feature - for FHIR Primitive Data Types. - - Eye alignment compensation. - Allows for adjustment on two axis. - """ - - resource_type = Field("VisionPrescriptionLensSpecificationPrism", const=True) - - amount: fhirtypes.Decimal = Field( - None, - alias="amount", - title="Amount of adjustment", - description="Amount of prism to compensate for eye alignment in fractional units.", - # if property is element of this resource. - element_property=True, - element_required=True, - ) - amount__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_amount", title="Extension field for ``amount``." - ) - - base: fhirtypes.Code = Field( - None, - alias="base", - title="up | down | in | out", - description="The relative base, or reference lens edge, for the prism.", - # if property is element of this resource. - element_property=True, - element_required=True, - # note: Enum values can be used in validation, - # but use in your own responsibilities, read official FHIR documentation. - enum_values=["up", "down", "in", "out"], - ) - base__ext: fhirtypes.FHIRPrimitiveExtensionType = Field( - None, alias="_base", title="Extension field for ``base``." - ) - - @classmethod - def elements_sequence(cls): - """returning all elements names from - ``VisionPrescriptionLensSpecificationPrism`` according specification, - with preserving original sequence order. - """ - return ["id", "extension", "modifierExtension", "amount", "base"] - - @root_validator(pre=True, allow_reuse=True) - def validate_required_primitive_elements_4379( - cls, values: typing.Dict[str, typing.Any] - ) -> typing.Dict[str, typing.Any]: - """https://www.hl7.org/fhir/extensibility.html#Special-Case - In some cases, implementers might find that they do not have appropriate data for - an element with minimum cardinality = 1. In this case, the element must be present, - but unless the resource or a profile on it has made the actual value of the primitive - data type mandatory, it is possible to provide an extension that explains why - the primitive value is not present. - """ - required_fields = [("amount", "amount__ext"), ("base", "base__ext")] - _missing = object() - - def _fallback(): - return "" - - errors: typing.List["ErrorWrapper"] = [] - for name, ext in required_fields: - field = cls.__fields__[name] - ext_field = cls.__fields__[ext] - value = values.get(field.alias, _missing) - if value not in (_missing, None): - continue - ext_value = values.get(ext_field.alias, _missing) - missing_ext = True - if ext_value not in (_missing, None): - if isinstance(ext_value, dict): - missing_ext = len(ext_value.get("extension", [])) == 0 - elif ( - getattr(ext_value.__class__, "get_resource_type", _fallback)() - == "FHIRPrimitiveExtension" - ): - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - else: - validate_pass = True - for validator in ext_field.type_.__get_validators__(): - try: - ext_value = validator(v=ext_value) - except ValidationError as exc: - errors.append(ErrorWrapper(exc, loc=ext_field.alias)) - validate_pass = False - if not validate_pass: - continue - if ext_value.extension and len(ext_value.extension) > 0: - missing_ext = False - if missing_ext: - if value is _missing: - errors.append(ErrorWrapper(MissingError(), loc=field.alias)) - else: - errors.append( - ErrorWrapper(NoneIsNotAllowedError(), loc=field.alias) - ) - if len(errors) > 0: - raise ValidationError(errors, cls) # type: ignore - - return values