mikee6290
11/07/2023, 3:40 PMrahul1
11/07/2023, 6:44 PMObservation resources. The Observation is a point in time measurement for some clinical quantity of a patient.
Check out our guide here: https://www.medplum.com/docs/charting/capturing-vital-signs
I think it will be very informativemikee6290
11/07/2023, 6:47 PMrahul1
11/07/2023, 6:51 PMmikee6290
11/08/2023, 3:28 PMnode5585
11/09/2023, 4:58 AMrahul1
11/09/2023, 5:51 AMObservation resource is meant to record any "point-in-time" medical observation. This means you can use it to capture body-fat percentage, measured at a point in timerahul1
11/09/2023, 5:53 AMnode5585
11/09/2023, 1:20 PMmikee6290
11/09/2023, 4:05 PMnode5585
11/10/2023, 3:09 PMmikee6290
11/10/2023, 6:01 PMrahul1
11/10/2023, 6:42 PMrahul1
11/10/2023, 6:43 PMmikee6290
11/10/2023, 6:43 PMmikee6290
11/10/2023, 6:44 PMrahul1
11/10/2023, 6:48 PMmikee6290
11/10/2023, 6:48 PMrahul1
11/10/2023, 6:49 PMmikee6290
11/13/2023, 7:27 PM>>>>> Error: Constraint bdl-8 not met: fullUrl cannot be a version specific reference ({"fhirpath":"fullUrl.contains('/_history/').not()"}) (Bundle.entry); Constraint bdl-8 not met: fullUrl cannot be a version specific reference ({"fhirpath":"fullUrl.contains('/_history/').not()"}) (Bundle.entry); Missing required property (Bundle.entry.resource.code); Invalid additional property "resource" (Bundle.entry.resource.subject.resource); Invalid additional property "coding" (Bundle.entry.resource.coding); Missing required property (Bundle.entry.resource.code); Invalid additional property "resource" (Bundle.entry.resource.subject.resource); Invalid additional property "coding" (Bundle.entry.resource.coding)mikee6290
11/13/2023, 7:28 PMmikee6290
11/13/2023, 7:29 PMconst login = medplum.getActiveLogin();
const patientId = login?.profile.reference?.split("/")[1];mikee6290
11/13/2023, 7:30 PMawait medplum.createResource({
resourceType: "Bundle",
type: "batch",
entry: [
{
resource: {
resourceType: "Observation",
status: 'preliminary',
coding: [
{
system: "http://loinc.org",
code: "8302-2",
display: "Body Height",
},
],
subject: {
resource: {
resourceType: "Patient",
id: patientId,
},
},
valueQuantity: {
value: Number(firstQuizData?.height),
unit: "cm",
system: "http://unitsofmeasure.org/",
code: "cm",
},
},
request: {
method: "POST",
url: "Observation",
},
},
{
resource: {
resourceType: "Observation",
status: 'preliminary',
coding: [
{
system: "http://loinc.org",
code: "29463-7",
display: "Body Weight",
},
],
subject: {
resource: {
resourceType: "Patient",
id: patientId,
},
},
valueQuantity: {
value: Number(firstQuizData?.weight),
unit: "lbs",
system: "http://unitsofmeasure.org/",
code: "lbs",
},
},
request: {
method: "POST",
url: "Observation",
},
},
],
});mikee6290
11/13/2023, 7:50 PMcode: {
coding: [
{
system: "http://loinc.org",
code: "8302-2",
display: "Body Height",
},
],
},node5585
11/13/2023, 9:41 PMpatientId is not working as expected
You should use createReference from @medplum/core
typescript
import { createReference } from '@medplum/core';
createReference(login.profile)
Also, I notice you're using optional chaining on the firstQuizData .. is height & weight optional? If they are, you may want to prevent creating the Observation if you don't have the data.mikee6290
11/13/2023, 11:30 PMmikee6290
11/13/2023, 11:31 PMmikee6290
11/14/2023, 1:23 AMmikee6290
11/14/2023, 3:50 PM>>>>> Error: Forbiddenmikee6290
11/14/2023, 3:50 PMmikee6290
11/14/2023, 3:50 PMurn:uuid:${patientId},
resource: {
resourceType: "Observation",
status: "preliminary",
code: {
coding: [
{
system: "http://loinc.org",
code: "8302-2",
display: "Body Height",
},
],
},
subject: {
reference: "Patient/" + patientId,
},
valueQuantity: {
value: Number(firstQuizData?.height),
unit: "cm",
system: "http://unitsofmeasure.org/",
code: "cm",
},
},
request: {
method: "POST",
url: "Observation",
},
},
],
});
console.log(result);
} catch (error) {
console.log(">>>>>", error);
}`rahul1
11/14/2023, 7:54 PMmikee6290
11/14/2023, 7:55 PM{
"resource": [
{
"resourceType": "Patient"
},
{
"resourceType": "Observation"
},
{
"resourceType": "StructureDefinition"
},
{
"resourceType": "SearchParameter"
},
{
"resourceType": "ValueSet"
},
{
"resourceType": "Questionnaire"
},
{
"resourceType": "DiagnosticReport"
},
{
"resourceType": "MedicationRequest"
},
{
"resourceType": "Coverage"
},
{
"resourceType": "PaymentNotice"
},
{
"resourceType": "CarePlan"
},
{
"resourceType": "Immunization"
},
{
"resourceType": "Communication"
},
{
"resourceType": "Organization",
"readonly": true
},
{
"resourceType": "Practitioner",
"readonly": false
},
{
"resourceType": "Schedule",
"readonly": true
},
{
"resourceType": "Slot",
"readonly": true
},
{
"resourceType": "Binary"
}
],
"resourceType": "AccessPolicy",
"name": "defaultPatientAccessPolicy",
"id": "63847d87-2bb2-4c2a-85b5-4ef279c728e8",
"meta": {
"versionId": "a5216012-0c29-4b59-b46f-4b1876139f52",
"lastUpdated": "2023-10-05T17:05:37.217Z",
"author": {
"reference": "Practitioner/6c14b083-2771-406c-9709-bd56e1869440",
"display": "Michael Kleyman"
},
"project": "b0aa142c-85e2-4fb3-a62c-fe949a0b0573",
"compartment": [
{
"reference": "Project/b0aa142c-85e2-4fb3-a62c-fe949a0b0573"
}
]
}
}rahul1
11/14/2023, 8:19 PMfullURL property. This should be unecessary. Since it's referring to a Patient, this might be the cause of the error?mikee6290
11/14/2023, 8:44 PMError: Constraint bdl-8 not met: fullUrl cannot be a version specific reference ({"fhirpath":"fullUrl.contains('/_history/').not()"}) (Bundle.entry); Constraint bdl-8 not met: fullUrl cannot be a version specific reference ({"fhirpath":"fullUrl.contains('/_history/').not()"})mikee6290
11/14/2023, 8:46 PMrahul1
11/15/2023, 5:19 PMrahul1
11/15/2023, 5:19 PMexecuteBatch, not createResourcemikee6290
11/15/2023, 5:25 PMrahul1
11/15/2023, 5:28 PMmikee6290
11/15/2023, 6:45 PMmikee6290
11/15/2023, 6:46 PMmikee6290
11/16/2023, 5:08 PMrahul1
11/16/2023, 5:20 PMbody-water-weight). Just make sure to use a system string that reflects that this is an "internal code" (e.g . http://hilohealth.com)rahul1
11/16/2023, 5:21 PMmikee6290
11/16/2023, 7:19 PMmikee6290
11/16/2023, 7:23 PMmikee6290
11/16/2023, 8:15 PMrahul1
11/16/2023, 8:19 PMlocalhost anyway, so might as well use something that's closer to the real domainmikee6290
11/16/2023, 8:21 PMrahul1
11/16/2023, 8:26 PM